From 2e045e141746a2082507d3310e5716ca94a65e12 Mon Sep 17 00:00:00 2001 From: Erwan Carriou Date: Wed, 12 Jun 2019 22:01:53 +0200 Subject: [PATCH] Bump 3.5.4 --- 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 +- main.js | 6 ++++++ package-lock.json | 14 +++++++------- package.json | 6 +++--- 11 files changed, 24 insertions(+), 18 deletions(-) diff --git a/designer/scripts/diagram.js b/designer/scripts/diagram.js index ff332c3..beb1db7 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.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 +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.4"},"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 var userAgent = navigator.userAgent.toLowerCase();\n \n if (userAgent.indexOf(' electron/') !== -1) {\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, { activate: true }); \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.4"}},"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.4"},"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 17f9a37..9dc51b6 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.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 +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.4"},"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 var userAgent = navigator.userAgent.toLowerCase();\n \n if (userAgent.indexOf(' electron/') !== -1) {\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, { activate: true }); \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.4"}},"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.4"},"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 3bc77c7..3a4e3b9 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.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 +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.4"},"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 var userAgent = navigator.userAgent.toLowerCase();\n \n if (userAgent.indexOf(' electron/') !== -1) {\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, { activate: true }); \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.4"}},"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.4"},"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 a2ea05e..48ecbaa 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.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 +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.4"},"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 var userAgent = navigator.userAgent.toLowerCase();\n \n if (userAgent.indexOf(' electron/') !== -1) {\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, { activate: true }); \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.4"}},"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.4"},"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 b42f652..cbe22cb 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.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 +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.4"},"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 var userAgent = navigator.userAgent.toLowerCase();\n \n if (userAgent.indexOf(' electron/') !== -1) {\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, { activate: true }); \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.4"}},"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.4"},"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 ae81f2e..5e5f6ab 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.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 +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.4"},"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 var userAgent = navigator.userAgent.toLowerCase();\n \n if (userAgent.indexOf(' electron/') !== -1) {\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, { activate: true }); \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.4"}},"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.4"},"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 fd34b76..6ba3b68 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.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 +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.4"},"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 var userAgent = navigator.userAgent.toLowerCase();\n \n if (userAgent.indexOf(' electron/') !== -1) {\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, { activate: true }); \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.4"}},"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.4"},"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 4e0db5b..ac371b0 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.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 +runtime.install({"name":"system-designer","master":true,"version":"3.5.4","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.4"},"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 var userAgent = navigator.userAgent.toLowerCase();\n \n if (userAgent.indexOf(' electron/') !== -1) {\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, { activate: true }); \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.4"}},"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.4"},"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/main.js b/main.js index 85b4593..d05ec3b 100755 --- a/main.js +++ b/main.js @@ -210,6 +210,9 @@ function createWindow() { label: 'Read the documentation', click: () => { let helpWindow = new BrowserWindow({ + webPreferences: { + nodeIntegration: true + }, width: 1024, height: 768 }); @@ -299,6 +302,9 @@ function createWindow() { Menu.setApplicationMenu(menu); mainWindow = new BrowserWindow({ + webPreferences: { + nodeIntegration: true + }, width: 1024, height: 768 }); diff --git a/package-lock.json b/package-lock.json index 7bb0288..b0504c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "system-designer-electron", - "version": "3.5.3", + "version": "3.5.4", "lockfileVersion": 1, "requires": true, "dependencies": { "@types/node": { - "version": "10.14.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.8.tgz", - "integrity": "sha512-I4+DbJEhLEg4/vIy/2gkWDvXBOOtPKV9EnLhYjMoqxcRW+TTZtUftkHktz/a8suoD5mUL7m6ReLrkPvSsCQQmw==", + "version": "10.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.9.tgz", + "integrity": "sha512-NelG/dSahlXYtSoVPErrp06tYFrvzj8XLWmKA+X8x0W//4MqbUyZu++giUG/v0bjAT6/Qxa8IjodrfdACyb0Fg==", "dev": true }, "ajv": { @@ -335,9 +335,9 @@ } }, "electron": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/electron/-/electron-5.0.2.tgz", - "integrity": "sha512-bUHKQhyuOen/q8iHTkrnzqB9CAwBDI+vHbeu21kpq2bqAD+t25yfrmUEcYHaPL4fZOAhk6nnRqskF6/Xd+aZxg==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/electron/-/electron-5.0.3.tgz", + "integrity": "sha512-kgnxPQoTNzu0lKC8ToAktt93mTimgqHZGFCVmTaFjs1G2Bk9VqKHljbQemH+REKAaw1aEgIRn2JCrTe0Dy7fVQ==", "dev": true, "requires": { "@types/node": "^10.12.18", diff --git a/package.json b/package.json index 960c490..d55994b 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "system-designer-electron", "productName": "System Designer", - "version": "3.5.3", - "buildVersion": "353000", + "version": "3.5.4", + "buildVersion": "354000", "description": "System Designer, an IDE for designing systems", "homepage": "https://designfirst.io/systemdesigner/", "author": "erwan carriou", @@ -15,7 +15,7 @@ "windows": "node ./scripts/windows.js" }, "devDependencies": { - "electron": "5.0.2", + "electron": "5.0.3", "electron-packager": "13.1.1", "electron-packager-languages": "0.3.0" }