- "action": "function start() { \n var sysid = '',\n system = '',\n params = '',\n systemID = '';\n \n if (typeof global !== 'undefined' && typeof window === 'undefined') {\n global.require = require;\n }\n\n window.messages = []; // TODO find better way\n window.lastPage = 'index.html'; // TODO find better way\n \n function _getParams() {\n var result = {},\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 result[name] = decodeURIComponent(value);\n });\n }\n return result;\n }\n\n // case of cordova \n if (typeof cordova !== 'undefined') {\n params = _getParams();\n system = null;\n\n if (Object.keys(params).length) {\n system = JSON.parse(params.system);\n this.require('storage').set(system._id, system);\n lastPage = params.ref;\n }\n\n // add back button\n setTimeout(function () {\n if (!document.getElementById('system-designer-back')) {\n var docFragment = null,\n div = null,\n a = null,\n span = null;\n\n docFragment = document.createDocumentFragment();\n div = document.createElement('div');\n div.setAttribute('id', 'system-designer-back');\n div.setAttribute('style', 'top:5px;left:10px;position:absolute;font-size:18px;font-family:Helvetica,Arial,sans-serif;z-index:999999;background-color:white;');\n\n a = document.createElement('a');\n /* jshint -W107 */\n a.setAttribute('href', 'javascript:systemDesignerBack()');\n /* jshint +W107 */\n a.setAttribute('style', 'text-decoration:none; color:#337AB7;');\n\n span = document.createElement('span');\n span.setAttribute('style', \"font-family: 'Helvetica Neue';\");\n span.textContent = ' < System Designer';\n\n a.appendChild(span);\n div.appendChild(a);\n docFragment.appendChild(div);\n\n document.body.appendChild(docFragment);\n }\n }, 1000);\n }\n\n // get system\n sysid = document.location.href.split('#')[1].split('?')[0].split('/')[0];\n system = this.require('storage').get(sysid);\n delete system.classInfo;\n \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, true);\n \n this.require('logger').info('loading the system...');\n systemID = $db.importSystem(system);\n this.require('logger').info('the system is loaded');\n\n document.title = system.name;\n \n this.require('logger').level('debug');\n if (this.require(systemID).start) {\n this.require(systemID).start();\n }\n}",
0 commit comments