function toggleEnable(id) { var sw = $("#"+id+"_cb"); var r = $('#'+id); r.prop('disabled', !sw.is(':checked')); } function findPathInObject(obj, path, modifier={}) { var list = path.split("/"); if(list.length==1) { var o = obj[list[0]]; if(o instanceof Array) { return o; }else if(o instanceof Object){ var x = {}; Object.assign(x, o, modifier); return x; }else if(typeof o == "string"){ if(o[0]=='@' && o[1]=='/') return findPathInObject(obj, o, modifier); else return o; }else{ return o; } } return findPathInObject(obj[list[0]], list.slice(1).join("/"), modifier) } class UIManager { constructor() { this.list={} this.uiClasses={}; this.idIndex=0; } registerUiClass(type, classname){ this.uiClasses[type]=classname; } newUi(type, a, b, c, d) { return new this.uiClasses[type](a, b, c, d); } registerElement(obj) { this.idIndex++; this.list[this.idIndex]=obj; return this.idIndex; } deleteElement(obj) { var id = obj.uiId; delete this.list[id]; } getElementById(id) { return this.list[id]; } } var __uiManager = new UIManager(); function newUiClass(type, a, b, c) { return __uiManager.newUi(type, a, b, c); } function registerUiClass(type, classe) { return __uiManager.registerUiClass(type, classe); } function getUI(uiId) { return __uiManager.getElementById(uiId); } function getUIFromDom(id) { var root = $("#"+id); var uiId = root.data().id; return __uiManager.getElementById(uiId); } function registerUI(obj) { return __uiManager.registerElement(obj); } function deleteUI(obj) { return __uiManager.deleteElement(obj); }