/* ** ccpObject ** - prevent the global variable 'gConfig' be modified by global function 'get_router_info' and 'get_config_obj', so make an object to handle it. ** @author: moa ** @date: 2013-01-05 ** @notice: global function 'get_config_obj', 'get_router_info' and other "similar function" will be delete. ** @param: ccp - specify which ccp (optional) ** act - specify ccp_act (optional) */ var csrf_hash = "471at7f3hAqFvlaP65v7608nFy3lE431"; function ccpObject(ccp,act) { this.gConfig = null; this.errorMSG = null; /* private member below */ var param = {'url':(ccp!=undefined?ccp:''),'arg':''}; var param_arg = []; var ccp_act = (act!=undefined?act:''); var param_arg_event = []; var param_misc = []; var that = this; // Trendnet does not need to set GUI timeout var gui_timeout = false; /** * config_val() : get config value of the input tag name * * Parameter(s) : * name : tag name * * Return : the node value of the input tag name. * **/ this.config_val = function(name) { return get_node_value(this.gConfig, name); } this.config_attr = function(name) { return get_node_attribute(this.gConfig, name); } this.config_inst = function(name) { var attr = this.config_attr(name); var inst = attr.split(","); return inst; } /** * config_str() : Get config string of the input tag name. * It will be shown on page directly. * * Parameter(s) : * name : tag name * * Return : the node string of the input tag name. * **/ this.config_str = function(name) { return document.write(get_node_value(this.gConfig, name)); } this.config_str_multi = function(name) { var obj = $(this.gConfig).find(name); var size = obj.size(); if (size == 0) return null; var i=0; var r = new Array(size); for (i=0; i'+allHostName[i]+'('+allHostIp[i]+')'); } else if(ref == 'mac') { if(allHostMac[i]!= '') document.write(''); } else document.write(''); } } } this.get_host_list = function( ref ) { var allHostName = this.config_str_multi("igdLanHostStatus_HostName_"); var allHostIp = this.config_str_multi("igdLanHostStatus_HostIPv4Address_"); var allHostMac = this.config_str_multi("igdLanHostStatus_HostMACAddress_"); var allHostType = this.config_str_multi("igdLanHostStatus_HostAddressType_"); if(allHostIp != null) { for (var i=0; i'+allHostName[i]+'('+allHostIp[i]+')'); } else if(ref == 'mac') { if(allHostMac[i]!= '') document.write(''); } else document.write(''); } } } this.set_host_list_1 = function( ref ) { var allHostName = this.config_str_multi("igdLanHostStatus_HostName_"); var allHostIp = this.config_str_multi("igdLanHostStatus_HostIPv4Address_"); var allHostMac = this.config_str_multi("igdLanHostStatus_HostMACAddress_"); var allHostType = this.config_str_multi("igdLanHostStatus_HostAddressType_"); var list_str = ""; if(allHostIp != null) { for (var i=0; i'+allHostName[i]+'('+allHostIp[i]+')'; } else if(ref == 'mac') { if(allHostMac[i]!= '') list_str += ''; } else list_str += ''; } } return list_str; } /* this.config_val_by_inst = function(obj_name, param_name, inst) { if ($(gConfig).find(name).size() == 0) return null; var size = $(gConfig).find(name).size() var i=0; for } */ /* ** Date: 2013-05-27 ** Author: Moa Chung ** Reason: Extends the function, we can use more object-oriented to setup the ccp request. ** Note: compare between old and new function // old functional format var unknownObj = new ccpObject(); var paramHost={ 'url': 'get_set.ccp', 'arg': 'ccp_act=get&num_inst=2'+ '&oid_1=IGD_LANDevice_i_ConnectedAddress_i_&inst_1=1100'+ '&oid_2=IGD_LANDevice_i_LANHostConfigManagement_&inst_2=1110' }; unknownObj.get_config_obj(paramHost); // new functional format var unknownObj2 = new ccpObject(); unknownObj2.set_param_url('get_set.ccp'); unknownObj2.set_ccp_act('get'); unknownObj2.add_param_arg('IGD_LANDevice_i_ConnectedAddress_i_', 1100); unknownObj2.add_param_arg('IGD_LANDevice_i_LANHostConfigManagement_', 1110); unknownObj2.get_config_obj(); */ this.set_ccp_act = function(act) { ccp_act = act; }; this.set_param_url = function(url) { param.url = url; }; this.set_param_arg = function(arg) { param_misc.push(arg); }; this.set_param_option = function(key,val) { param_misc.push(key+'='+tryEncodeURI(val)); }; this.set_param_next_page = function(nextPage) { this.set_param_option('html_response_return_page',tryEncodeURI(nextPage)); }; this.set_param_query_page = function(queryPage) { this.set_param_option('queryPage',tryEncodeURI(queryPage)); }; this.add_param_event = function(event) { param_arg_event.push(event); }; this.add_param_arg = function(oid, val) { param_arg.push({'oid':oid,'val':tryEncodeURI(val)}); }; /* ** try EncodeURI to prevent GUI already encode once ** @author: Moa Chung ** @date: 2013-11-15 */ var tryEncodeURI = function(val){ var val_enc; try{ val_enc = encodeURIComponent(decodeURIComponent(val)); }catch(e){ val_enc = encodeURIComponent(val); } return val_enc; } /* private function below */ var parse_param_arg_misc = function(){ for(var i=0;i0)) member_array.push($.extend(obj[key], {'key':key})); } return member_array; } } ccpObject.session_timer = [];