var _ws = null; var _rootId = "0"; var _nextEleId = 0; function set_app_title( suffix, className ) { var ele = document.getElementById('connectTitleId'); ele.innerHTML = suffix ele.className = className } function uiOnError( msg, r) { console.log("Error:" + msg); } function uiGetParent( r ) { parent_ele = document.getElementById(r.parent_id); if( parent_ele == null ) { uiOnError("Parent not found. parent_id:" + r.parent_id,r); } return parent_ele; } function uiCreateEle( r ) { var parent_ele; if((parent_ele = uiGetParent(r)) != null ) { ele = document.createElement(r.ele_type) ele.id = r.ele_id; ele.className = r.value; parent_ele.appendChild(ele) } } function uiRemoveChildren( r ) { ele = document.getElementById(r.ele_id) while (ele.firstChild) { ele.removeChild(ele.firstChild); } } function uiDivCreate( r ) { uiCreateEle(r) } function uiLabelCreate( r ) { var parent_ele; if((parent_ele = uiGetParent(r)) != null ) { ele = document.createElement("label") ele.htmlFor = r.ele_id ele.innerHTML = r.value; parent_ele.appendChild(ele) } } function uiSelectCreate( r ) { uiCreateEle(r) } function uiSelectClear( r ) { uiRemoveChildren(r) } function uiSelectInsert( r ) { var select_ele; if((select_ele = uiGetParent(r)) != null ) { var option = document.createElement('option'); option.id = r.ele_id; option.innerHTML = r.value; option.value = r.ele_id; option.onclick = function() { uiOnSelectClick(this) } select_ele.appendChild(option) } } function uiSelectChoose( r ) { var select_ele; if((select_ele = uiGetParent(r)) != null ) { if( select_ele.hasChildNodes()) { var children = select_ele.childNodes for(var i=0; i 0 ) { var p_ele = dom_create_ele("p") p_ele.innerHTML = d.title div_ele.appendChild( p_ele ) } } return div_ele; } function ui_create_panel_div( parent_ele, d ) { d.type = "div" var div_ele = ui_create_div( parent_ele, d ); if( !d.hasOwnProperty('className') ) div_ele.className = "uiPanel" return div_ele } function ui_create_row_div( parent_ele, d ) { d.type = "div" var div_ele = ui_create_div( parent_ele, d ); if( !d.hasOwnProperty('className') ) div_ele.className = "uiRow" return div_ele } function ui_create_col_div( parent_ele, d ) { d.type = "div" var div_ele = ui_create_div( parent_ele, d ); if( !d.hasOwnProperty('className') ) div_ele.className = "uiCol" return div_ele } function ui_create_title( parent_ele, d ) { var ele = ui_create_ele( parent_ele, "label", d, "uiTitle" ); if( ele != null ) { ele.innerHTML = d.title; } return ele; } function ui_create_button( parent_ele, d ) { var ele = ui_create_ctl( parent_ele, "button", null, d, "uiButton" ); if( ele != null ) { ele.innerHTML = d.title; ele.onclick = function() { ui_send_int_value(this,1); } } return ele; } function ui_create_check( parent_ele, d ) { var ele = ui_create_ctl( parent_ele, "input", d.title, d, "uiCheck" ) if( ele != null ) { ele.type = "checkbox"; ele.onclick = function() { ui_send_bool_value(this,dom_get_checkbox(this.id)); } if( !d.hasOwnProperty('value') ) ui_send_echo(ele) else { dom_set_checkbox(ele.id, d.value ); ui_send_bool_value(ele,dom_get_checkbox(ele.id)) } } return ele; } // // Note: The value of a 'select' widget is always set by the 'appId' // of the selected 'option'. Likewise the 'appId' of the selected // option is returned as the value of the select widget. // function ui_on_select( ele ) { ui_send_int_value(ele,ele.options[ ele.selectedIndex ].appId); } function ui_select_set_from_option_app_id( sel_ele, option_appId ) { var i; for(i=0; i