-{"name":"web","version":"0.1.0","description":"Add behaviors for web","_id":"133421d0c313d2d","schemas":{"12e211d4cd120a6":{"_id":"12e211d4cd120a6","_name":"Runtime","load":"method","ready":"event"}},"models":{"14c7c105b31a160":{"_id":"14c7c105b31a160","_name":"Runtime","load":{"params":[{"name":"url","type":"string"},{"name":"async","type":"boolean","mandatory":false,"default":true}]},"ready":{}}},"types":{},"behaviors":{"1aaee1e6311ff39":{"_id":"1aaee1e6311ff39","component":"runtime","state":"load","action":"function load(url, async) {\n var xhr = null,\n callbackLoad = null;\n xhr = new XMLHttpRequest();\n \n callbackLoad = function callbackLoad(system) {\n var sysId = $db.system(system),\n sys = $component.get(sysId),\n systems = document.querySelectorAll('link[rel=system]'),\n nbSubsystem = $db.RuntimeSystem.find({\n 'subsystem': true\n }); \n if (sys) {\n sys.main();\n } \n if (systems.length + 1 + nbSubsystem.length === $db.RuntimeSystem.count()) {\n $component.get('runtime').ready();\n }\n };\n \n if (async) {\n xhr.open('GET', url, true);\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n callbackLoad(JSON.parse(xhr.response));\n }\n }\n };\n xhr.send(null);\n } else {\n xhr.open('GET', url, false);\n xhr.send(null);\n if (xhr.status === 200) {\n callbackLoad(JSON.parse(xhr.response));\n }\n }\n}","core":true,"useCoreAPI":true},"1f6001773a18791":{"_id":"1f6001773a18791","component":"e89c617b6b15d24","state":"main","action":"function main() {\n var subsystems = [],\n systems = [],\n system = null,\n scripts = [],\n script = null,\n pathToDesigner = '',\n logLevel = 'warn',\n i = 0,\n length = 0;\n \n subsystems = $db.RuntimeSystem.find({\n 'subsystem': true\n });\n subsystems.forEach(function (subsystem) {\n var subsystemId = subsystem._id;\n this.require(subsystemId).main();\n }, this); \n \n if (typeof document !== 'undefined') {\n systems = document.querySelectorAll('link[rel=system]');\n length = systems.length;\n \n // logger\n scripts = document.querySelectorAll('script[log]');\n if (scripts.length) {\n logLevel = scripts[0].getAttribute('log');\n this.require('logger').level(logLevel);\n }\n \n // systems\n for (i = 0; i < length; i++) {\n system = systems[i];\n \n if (system.getAttribute('async') === 'false') {\n this.require('runtime').load(system.href, false);\n } else {\n this.require('runtime').load(system.href, true);\n }\n }\n if (length === 0) {\n this.require('runtime').ready();\n }\n \n // admin\n scripts = document.querySelectorAll('script[designer]');\n if (scripts.length) {\n pathToDesigner = scripts[0].getAttribute('designer');\n this.require('admin').start(pathToDesigner);\n }\n }\n}","core":true,"useCoreAPI":true}},"components":{},"master":false,"subsystem":false}
0 commit comments