(function($) { | |
$.fn.objInternetConn = function(InIt) { | |
var gProto; | |
var gDialSwitch; | |
var gNetworkMode; | |
var gPerferMode; | |
var gNRSupport = 0; | |
var gNRDualMultiMode = 0; | |
var gNREnable = 0; | |
//var gLtePerMode; | |
var gAutoVersionSwithFlag; | |
var gVersionSwitchFlag; | |
var gProfileArr; | |
var gEngModeFlag; | |
/*define array subscript index*/ | |
var gProfileNameEnumIdx = 0; | |
var gPdpTypeEnumIdx = 1; | |
var gConnNumEnumIdx = 2; | |
var gTypeEnumIdx = 3; | |
var gAutoApnEnumIdx = 4; | |
var gConnModeEnumIdx = 5; | |
var gLteDefaultEnumIdx = 6; | |
var gDataOnRoamEnumIdx = 7; | |
var gPdpNameEnumIdx = 8; | |
var gEnabledEnumIdx = 9; | |
var gIpTypeEnumIdx = 10; | |
var gApnEnumIdx = 11; | |
var gLteApnEnumIdx = 12; | |
var gUser23gEnumIdx = 13; | |
var gPsswd23gEnumIdx = 14; | |
var gAuthType23gEnumIdx = 15; | |
var gUser4gEnumIdx = 16; | |
var gPsswd4gEnumIdx = 17; | |
var gAuthType4gEnumIdx = 18; | |
var gMtuEnumIdx = 19; | |
var gsingleMode = 1; | |
this.onLoad = function(flag) { | |
if(flag) { | |
LoadWebPage("html/internet/internet_connection.html"); | |
$("#SelInterConnMode").change(function() { | |
if("cellular" == $(this).val()) { | |
$("#divCellularConn").show(); | |
} else { | |
$("#divCellularConn").hide(); | |
} | |
}); | |
$("#Sel5GSwitch").change(function() { | |
var netMode = $("#selWorkMode").val(); | |
var NRMode = $(this).val(); | |
netWorkAdaptToNR(NRMode, netMode, gNRDualMultiMode); | |
$("#selWorkMode").val(netMode); | |
preferModeAdaptToNR(NRMode, netMode); | |
/* | |
if("1" == $(this).val()) { | |
$("#selWorkMode option[value='2']").remove(); | |
$("#selWorkMode option[value='4']").remove(); | |
$("#selWorkMode option[value='5']").remove(); | |
$("#selWorkMode option[value='6']").remove(); | |
if ($("#selWorkMode option").length <= 2) { | |
$("#selWorkMode").append("<option value='7'>5G only</option>"); | |
} | |
switch (netMode) { | |
case "1": | |
$("#div4G3G2GPrefer").show(); | |
if ($("#sel4G3G2GPreferMode option").length <= 3) | |
$("#sel4G3G2GPreferMode").append("<option value='9'>5G Preferred</option>"); | |
break; | |
case "3": | |
$("#div4G3GPrefer").show(); | |
if ($("#sel4G3GPreferMode option").length <= 2) | |
$("#sel4G3GPreferMode").append("<option value='9'>5G Preferred</option>"); | |
break; | |
} | |
} else { | |
$("#selWorkMode option[value='7']").remove(); | |
if ($("#selWorkMode option").length <= 2) { | |
$("#selWorkMode").append("<option value='2'>4G only</option>"); | |
$("#selWorkMode").append("<option value='4'>3G/2G</option>"); | |
$("#selWorkMode").append("<option value='5'>3G only</option>"); | |
$("#selWorkMode").append("<option value='6'>2G only</option>"); | |
} | |
switch (netMode) { | |
case "1": | |
$("#div4G3G2GPrefer").show(); | |
$("#sel4G3G2GPreferMode option[value='9']").remove(); | |
break; | |
case "3": | |
$("#div4G3GPrefer").show(); | |
$("#sel4G3GPreferMode option[value='9']").remove(); | |
break; | |
} | |
} | |
*/ | |
}); | |
$("#selWorkMode").change(function() { | |
HideNetPerferModeDiv(); | |
var netMode = $(this).val(); | |
var sel5GSwitch = $("#Sel5GSwitch").val(); | |
preferModeAdaptToNR(sel5GSwitch, netMode); | |
switch(netMode) { | |
case "1": | |
$("#div4G3G2GPrefer").show(); | |
/* | |
if (sel5GSwitch == "1") { | |
if ($("#sel4G3G2GPreferMode option").length <= 3) | |
$("#sel4G3G2GPreferMode").append("<option value='9'>5G Preferred</option>"); | |
} | |
else { | |
$("#sel4G3G2GPreferMode option[value='9']").remove(); | |
} | |
*/ | |
break; | |
case "3": | |
$("#div4G3GPrefer").show(); | |
/* | |
if (sel5GSwitch == "1") { | |
if ($("#sel4G3GPreferMode option").length <= 2) | |
$("#sel4G3GPreferMode").append("<option value='9'>5G Preferred</option>"); | |
} | |
else { | |
$("#sel4G3GPreferMode option[value='9']").remove(); | |
} | |
*/ | |
break; | |
/*case "4": | |
$("#div3G2GPrefer").show(); | |
break;*/ | |
} | |
}); | |
/* | |
$("#sel4G3GPreferMode").change(function() { | |
if(3 == $(this).val()) { | |
$("#selLtePreferMode").show(); | |
} else { | |
$("#selLtePreferMode").hide(); | |
} | |
});*/ | |
$("#selPdpProfileName").change(function() { | |
if("default" == $(this).val()) { | |
$("#lt_interCon_delPdpProfile").hide(); | |
} else { | |
$("#lt_interCon_delPdpProfile").show(); | |
} | |
var configMap = new Map(); | |
configMap.put("RGW/wan/profile/profile_name",$(this).val()); | |
configMap.put("RGW/wan/profile/action", 3); | |
var retXml = PostXml("cm","configs_handler",configMap); | |
if("OK" == $(retXml).find("response_status").text()) { | |
showProfilePdpList($(this).val()); | |
} else { | |
alert("switchPdpProfile failed."); | |
} | |
}); | |
$("#lt_interCon_addPdpProfile").click(function() { | |
ShowDlg("divAddPdpProfileNameDlg",400,100); | |
$("#txtPdpProfileName").click(function() { | |
$("#lPdpProfileNameError").hide(); | |
}); | |
$("#lt_btnAddPdpProfile").click(function() { | |
var profieName = $("#txtPdpProfileName").val(); | |
if("" == profieName) { | |
$("#lPdpProfileNameError").show().text(jQuery.i18n.prop("EMPTY_PROFILE_NAME")); | |
return; | |
} | |
if( !deviceNameValidation(profieName)|| !IsEnglishLetter(profieName[0])) { | |
$("#lPdpProfileNameError").show().text(jQuery.i18n.prop("lPdpProfileNameFormatError")); | |
return; | |
} | |
/*Check whether the added profile name is exists or not*/ | |
var bFound = false; | |
$("#selPdpProfileName option").each(function() { | |
if(profieName == $(this).val()) { | |
$("#lPdpProfileNameError").show().text(jQuery.i18n.prop("lPdpProfileNameRepeatError")); | |
bFound = true; | |
} | |
}); | |
if(bFound) return; | |
CloseDlg(); | |
var configMap = new Map(); | |
configMap.put("RGW/wan/profile/profile_name",profieName); | |
configMap.put("RGW/wan/profile/action", 1); | |
var retXml = PostXml("cm","configs_handler",configMap); | |
if("OK" == $(retXml).find("response_status").text()) { | |
GetWanConfig(); | |
} else { | |
alert("addPdpProfile failed."); | |
} | |
}); | |
}); | |
$("#lt_interCon_delPdpProfile").click(function() { | |
var profileName = $("#selPdpProfileName").val(); | |
var strMsg = "Are you sure to delete profile name \"" + profileName + " \""; | |
if(confirm(strMsg)) { | |
var configMap = new Map(); | |
configMap.put("RGW/wan/profile/profile_name",profileName); | |
configMap.put("RGW/wan/profile/action", 2); | |
var retXml = PostXml("cm","configs_handler",configMap); | |
if("OK" == $(retXml).find("response_status").text()) { | |
GetWanConfig(); | |
} else { | |
alert("delPdpProfile failed."); | |
} | |
} | |
}); | |
$("#lt_interCon_addPdpItem").click(function() { | |
AddPdp(); | |
}); | |
} //end flag | |
GetWanConfig(); | |
GetNetworkMode(); | |
if (GetAutoSwithInfo()) | |
GetVersionSwitch(); | |
GetEngMode(); | |
} | |
this.SaveData = function() { | |
SetWanConfig(); | |
SetNetworkMode(); | |
if (gsingleMode == 0) { | |
SetVersionSwitch(); | |
SetAutoSwith(); | |
} | |
SetEngMode(); | |
//this.onLoad(false); | |
} | |
function GetAutoSwithInfo() { | |
var retXml = PostXml("cm","get_auto_switch"); | |
gAutoVersionSwithFlag = $(retXml).find("enable").text(); | |
if (gAutoVersionSwithFlag == '2') { | |
$("#divVersionSwitch").hide(); | |
gsingleMode = 1; | |
return false; | |
} | |
else { | |
$("#divVersionSwitch").show(); | |
$("#SelAutoVersionSwitch").val(gAutoVersionSwithFlag); | |
gsingleMode = 0; | |
return true; | |
} | |
} | |
function SetAutoSwith() { | |
if("cellular" != $("#SelInterConnMode").val() || | |
gAutoVersionSwithFlag == $("#SelAutoVersionSwitch").val()) { | |
return; | |
} | |
var mapConfig = new Map(); | |
mapConfig.put("RGW/wan/enable",$("#SelAutoVersionSwitch").val()); | |
PostXml("cm","set_auto_switch",mapConfig); | |
GetAutoSwithInfo(); | |
} | |
function GetEngMode() { | |
var retXml = PostXml("cm","get_wan_configs"); | |
gEngModeFlag = $(retXml).find("eng_mode").text(); | |
$("#SelEngModeSwitch").val(gEngModeFlag); | |
} | |
function SetEngMode() { | |
if("cellular" != $("#SelInterConnMode").val() || | |
gEngModeFlag == $("#SelEngModeSwitch").val()) { | |
return; | |
} | |
var mapConfig = new Map(); | |
mapConfig.put("RGW/wan/mode",$("#SelEngModeSwitch").val()); | |
PostXml("cm","set_eng_mode",mapConfig); | |
GetEngMode(); | |
} | |
function AddPdp() { | |
ShowDlg("divPDPSetting",400,600); | |
$("#lt_btnSave").click(function() { | |
//don't allow to add the same type pdp. | |
var bFound = false; | |
for(var profileIdx = 0; profileIdx < gProfileArr.length; ++profileIdx) { | |
for(var pdpIdx = 0; pdpIdx < gProfileArr[profileIdx].length; ++pdpIdx) { | |
if($("#selPdpProfileName").val() != gProfileArr[profileIdx][pdpIdx][gProfileNameEnumIdx] | |
&& $("#selPdpType").val() != gProfileArr[profileIdx][pdpIdx][gPdpTypeEnumIdx]) { | |
bFound = true; | |
} | |
break; | |
} | |
if(bFound) { | |
break; | |
} | |
} | |
if(bFound) { | |
var strMsg="pdp type \"" + $("#selPdpType").val() + "\" have existed, please add other type."; | |
alert(strMsg); | |
return; | |
} | |
if(!ValideMtu()) { | |
$("#lPdpSetError").show().text(jQuery.i18n.prop("lMtuInvalidTip")); | |
return; | |
} | |
var configMap = new Map(); | |
var apnType = $("#selPdpType").val(); | |
configMap.put("RGW/wan/profile/profile_name",$("#selPdpProfileName").val()); | |
configMap.put("RGW/wan/profile/action",4); | |
configMap.put("RGW/wan/profile/connection_num",GetConnNumFromPdpType(apnType)); | |
configMap.put("RGW/wan/profile/type",apnType); | |
configMap.put("RGW/wan/pdp_info/connection_num", GetConnNumFromPdpType(apnType)); | |
configMap.put("RGW/wan/pdp_info/type",apnType); | |
configMap.put("RGW/wan/pdp_info/auto_apn",$("#selAutoApnSwitch").val()); | |
configMap.put("RGW/wan/pdp_info/connect_mode",$("#SelConnMode").val()); | |
configMap.put("RGW/wan/pdp_info/lte_default",$("#selLteDefault").val()); | |
configMap.put("RGW/wan/pdp_info/data_on_roaming",$("#selDialInRoaming").val()); | |
configMap.put("RGW/wan/pdp_info/pdp_name",$("#txtPdpName").val()); | |
configMap.put("RGW/wan/pdp_info/enable",$("#selEnabledPdp").val()); | |
configMap.put("RGW/wan/pdp_info/ip_type", $("#SelIpType").val()); | |
configMap.put("RGW/wan/pdp_info/apn",$("#txtAPNname").val()); | |
configMap.put("RGW/wan/pdp_info/lte_apn",$("#txtLteAPNname").val()); | |
configMap.put("RGW/wan/pdp_info/authtype_2g3g", $("#Sel2G3GAuthType").val()); | |
configMap.put("RGW/wan/pdp_info/pswd_2g3g",$("#txt2G3GPassword").val()); | |
configMap.put("RGW/wan/pdp_info/usr_2g3g",$("#txt2G3GUser").val()); | |
configMap.put("RGW/wan/pdp_info/usr_4g", $("#txt4GUser").val()); | |
configMap.put("RGW/wan/pdp_info/pswd_4g",$("#txt4GPassword").val()); | |
configMap.put("RGW/wan/pdp_info/authtype_4g",$("#Sel4GAuthType").val()); | |
configMap.put("RGW/wan/pdp_info/mtu",$("#txtMtuValue").val()); | |
CloseDlg(); | |
var retXml = PostXml("cm","configs_handler",configMap); | |
if("OK" == $(retXml).find("response_status").text()) { | |
GetWanConfig(); | |
} else { | |
alert("add pdp failed."); | |
} | |
}); | |
} | |
function SetWanConfig() { | |
if( gProto == $("#SelInterConnMode").val()) { | |
return; | |
} | |
var configMap = new Map(); | |
configMap.put("RGW/wan/connect_switch/proto",$("#SelInterConnMode").val()); | |
configMap.put("RGW/wan/connect_switch/dial_switch",gDialSwitch); | |
var retXml = PostXml("cm","connection_switch",configMap); | |
if("OK" != $(retXml).find("response_status").text()) { | |
alert("SetWanConfig failed."); | |
} | |
var retXml = PostXml("cm","get_wan_configs"); | |
gProto = $(retXml).find("proto").text(); | |
$("#SelInterConnMode").val(gProto); | |
if("cellular" == gProto) { | |
$("#divCellularConn").show(); | |
} else { | |
$("#divCellularConn").hide(); | |
} | |
} | |
function netWorkAdaptToNR(NRMode, netMode, NRDualMultiMode) { | |
if(("1" == NRMode) && ("2" == NRDualMultiMode)) { | |
$("#selWorkMode option[value='1']").remove(); | |
$("#selWorkMode").append("<option id ='lt_interCon_dropdownNRMultimode' value='1'>5G/4G/3G/2G multimode</option>"); | |
$("#selWorkMode option[value='2']").remove(); | |
$("#selWorkMode option[value='3']").remove(); | |
$("#selWorkMode").append("<option id ='lt_interCon_dropdownNR43Gonly' value='3'>5G/4G/3G</option>"); | |
//$("#selWorkMode option[value='4']").remove(); | |
$("#selWorkMode option[value='5']").remove(); | |
$("#selWorkMode option[value='6']").remove(); | |
if ($("#selWorkMode option").length <= 2) { | |
$("#selWorkMode").append("<option value='7'>5G only</option>"); | |
$("#selWorkMode").append("<option value='8'>5G/4G</option>"); | |
} | |
} else if(("1" == NRMode) && ("1" == NRDualMultiMode)) { | |
$("#selWorkMode option[value='1']").remove(); | |
$("#selWorkMode option[value='2']").remove(); | |
$("#selWorkMode option[value='3']").remove(); | |
//$("#selWorkMode option[value='4']").remove(); | |
$("#selWorkMode option[value='5']").remove(); | |
$("#selWorkMode option[value='6']").remove(); | |
if ($("#selWorkMode option").length <= 0) { | |
$("#selWorkMode").append("<option value='7'>5G only</option>"); | |
$("#selWorkMode").append("<option value='8'>5G/4G</option>"); | |
} | |
} else if(("0" == NRMode) && (("2" == NRDualMultiMode) || ("0" == NRDualMultiMode))) { | |
$("#selWorkMode option[value='1']").remove(); | |
$("#selWorkMode").append("<option id ='lt_interCon_dropdownMultimode' value='1'>4G/3G/2G multimode</option>"); | |
$("#selWorkMode option[value='2']").remove(); | |
$("#selWorkMode option[value='3']").remove(); | |
$("#selWorkMode").append("<option id ='lt_interCon_dropdown43Gonly' value='3'>4G/3G</option>"); | |
//$("#selWorkMode option[value='4']").remove(); | |
$("#selWorkMode option[value='5']").remove(); | |
$("#selWorkMode option[value='6']").remove(); | |
$("#selWorkMode option[value='7']").remove(); | |
$("#selWorkMode option[value='8']").remove(); | |
if ($("#selWorkMode option").length <= 2) { | |
$("#selWorkMode").append("<option value='2'>4G only</option>"); | |
//$("#selWorkMode").append("<option value='4'>3G/2G</option>"); | |
$("#selWorkMode").append("<option value='5'>3G only</option>"); | |
$("#selWorkMode").append("<option value='6'>2G only</option>"); | |
} | |
} else if(("0" == NRMode) && ("1" == NRDualMultiMode)) { | |
$("#selWorkMode option[value='1']").remove(); | |
$("#selWorkMode option[value='2']").remove(); | |
$("#selWorkMode option[value='3']").remove(); | |
//$("#selWorkMode option[value='4']").remove(); | |
$("#selWorkMode option[value='5']").remove(); | |
$("#selWorkMode option[value='6']").remove(); | |
$("#selWorkMode option[value='7']").remove(); | |
$("#selWorkMode option[value='8']").remove(); | |
if ($("#selWorkMode option").length <= 0) { | |
$("#selWorkMode").append("<option value='2'>4G only</option>"); | |
} | |
} | |
} | |
function preferModeAdaptToNR(NRMode, netMode) { | |
if("1" == NRMode) { | |
switch (netMode) { | |
case "1": | |
$("#div4G3G2GPrefer").show(); | |
if ($("#sel4G3G2GPreferMode option").length <= 3) | |
$("#sel4G3G2GPreferMode").append("<option value='9'>5G Preferred</option>"); | |
break; | |
case "3": | |
$("#div4G3GPrefer").show(); | |
if ($("#sel4G3GPreferMode option").length <= 2) | |
$("#sel4G3GPreferMode").append("<option value='9'>5G Preferred</option>"); | |
break; | |
case "8": | |
$("#div5G4GPrefer").show(); | |
break; | |
} | |
} | |
else { | |
switch (netMode) { | |
case "1": | |
$("#div4G3G2GPrefer").show(); | |
$("#sel4G3G2GPreferMode option[value='9']").remove(); | |
break; | |
case "3": | |
$("#div4G3GPrefer").show(); | |
$("#sel4G3GPreferMode option[value='9']").remove(); | |
break; | |
case "8": | |
$("#div5G4GPrefer").hide(); | |
break; | |
} | |
} | |
} | |
function GetNetworkMode() { | |
HideNetPerferModeDiv(); | |
var retXml = PostXml("util_wan","get_network_mode"); | |
gNetworkMode = $(retXml).find("nw_mode").text(); | |
gPerferMode = $(retXml).find("prefer_mode").text(); | |
gNRSupport = $(retXml).find("nr_support").text(); | |
gNRDualMultiMode = $(retXml).find("nr_dual_multi_mode").text(); | |
gNREnable = $(retXml).find("nr_enable").text(); | |
//gLtePerMode = $(retXml).find("prefer_lte_type").text(); | |
if (gNRSupport == 1) { | |
$("#div5GSwitch").show(); | |
$("#Sel5GSwitch").val(gNREnable); | |
} | |
else { | |
$("#div5GSwitch").hide(); | |
} | |
netWorkAdaptToNR(gNREnable, gNetworkMode, gNRDualMultiMode); | |
$("#selWorkMode").val(gNetworkMode); | |
preferModeAdaptToNR(gNREnable, gNetworkMode); | |
switch(gNetworkMode) { | |
case "1": | |
$("#div4G3G2GPrefer").show(); | |
$("#sel4G3G2GPreferMode").val(gPerferMode); | |
/*if(1 == gPerferMode) { | |
$("#selLtePreferMode").show(); | |
$("#selLtePreferMode").val(gLtePerMode); | |
}*/ | |
break; | |
case "3": | |
$("#div4G3GPrefer").show(); | |
$("#sel4G3GPreferMode").val(gPerferMode); | |
/*if(3 == gPerferMode) { | |
$("#selLtePreferMode").show(); | |
$("#selLtePreferMode").val(gLtePerMode); | |
}*/ | |
break; | |
/*case "4": | |
if (5 != gPerferMode && 9 != gPerferMode) { | |
gPerferMode = 6; | |
} | |
$("#div3G2GPrefer").show(); | |
$("#sel3G2GPreferMode").val(gPerferMode); | |
break;*/ | |
case "8": | |
$("#div5G4GPrefer").show(); | |
$("#sel5G4GPreferMode").val(gPerferMode); | |
/*if(3 == gPerferMode) { | |
$("#selLtePreferMode").show(); | |
$("#selLtePreferMode").val(gLtePerMode); | |
}*/ | |
break; | |
} | |
} | |
function SetNetworkMode() { | |
if("cellular" != $("#SelInterConnMode").val()) { | |
return; | |
} | |
var NetworkMode = $("#selWorkMode").val(); | |
var preferMode; | |
var nr_enable = $("#Sel5GSwitch").val(); | |
//var ltePreferMode; | |
switch(NetworkMode) { | |
case "1": | |
preferMode = $("#sel4G3G2GPreferMode").val(); | |
//ltePreferMode = $("#selLtePreferMode").val(); | |
break; | |
case "3": | |
preferMode = $("#sel4G3GPreferMode").val(); | |
//ltePreferMode = $("#selLtePreferMode").val(); | |
break; | |
/*case "4": | |
preferMode = $("#sel3G2GPreferMode").val(); | |
break;*/ | |
case "8": | |
preferMode = $("#sel5G4GPreferMode").val(); | |
break; | |
} | |
var configMap = new Map() | |
if((gNetworkMode != NetworkMode) || (gPerferMode != preferMode) || (gNREnable != nr_enable)) { | |
configMap.put("RGW/wan/nw_mode",NetworkMode); | |
configMap.put("RGW/wan/prefer_mode",preferMode); | |
configMap.put("RGW/wan/nr_enable",nr_enable); | |
} | |
/*if(1==preferMode || 3==preferMode) | |
if(gLtePerMode != ltePreferMode) { | |
configMap.put("RGW/wan/prefer_lte_type",ltePreferMode); | |
}*/ | |
if(configMap.size() == 0) { | |
return; | |
} | |
var retXml = PostXml("util_wan","set_network_mode",configMap); | |
if("ERROR" == $(retXml).find("setting_response").text()) { | |
alert("SetNetworkMode failed."); | |
} else { | |
GetNetworkMode(); | |
} | |
} | |
function GetWanConfig() { | |
var retXml = PostXml("cm","get_wan_configs"); | |
gProto = $(retXml).find("proto").text(); | |
gDialSwitch = $(retXml).find("dial_switch").text(); | |
var activeProfile = $(retXml).find("actived_profile").text(); | |
var profile_names = $(retXml).find("profile_names").text(); | |
var engmode = $(retXml).find("mode").text(); | |
if("," == profile_names.substr(profile_names.length-1,1)) { | |
profile_names = profile_names.substr(0,profile_names.length-1) | |
} | |
var profileNameArr = profile_names.split(","); | |
gProfileArr = new Array(); | |
for(var profileIdx = 0; profileIdx < profileNameArr.length; ++ profileIdx) { | |
gProfileArr[profileIdx] = new Array(); | |
var pdpIdx = 0; | |
$(retXml).find(profileNameArr[profileIdx]).each(function() { | |
$(this).find("Item").each(function() { | |
var ptype = $(this).children()[0].nodeName; | |
gProfileArr[profileIdx][pdpIdx] = new Array(); | |
gProfileArr[profileIdx][pdpIdx][gProfileNameEnumIdx] = profileNameArr[profileIdx]; | |
gProfileArr[profileIdx][pdpIdx][gPdpTypeEnumIdx] = ptype; | |
gProfileArr[profileIdx][pdpIdx][gConnNumEnumIdx] = $(this).find("connection_num").text(); | |
gProfileArr[profileIdx][pdpIdx][gTypeEnumIdx] = $(this).find("type").text(); | |
gProfileArr[profileIdx][pdpIdx][gAutoApnEnumIdx] = $(this).find("auto_apn").text(); | |
gProfileArr[profileIdx][pdpIdx][gConnModeEnumIdx] = $(this).find("connect_mode").text(); | |
gProfileArr[profileIdx][pdpIdx][gLteDefaultEnumIdx] = $(this).find("lte_default").text(); | |
gProfileArr[profileIdx][pdpIdx][gDataOnRoamEnumIdx] = $(this).find("data_on_roaming").text(); | |
gProfileArr[profileIdx][pdpIdx][gPdpNameEnumIdx] = $(this).find("pdp_name").text(); | |
gProfileArr[profileIdx][pdpIdx][gEnabledEnumIdx] = $(this).find("enable").text(); | |
gProfileArr[profileIdx][pdpIdx][gIpTypeEnumIdx] = $(this).find("ip_type").text(); | |
gProfileArr[profileIdx][pdpIdx][gApnEnumIdx] = $(this).find("apn").text(); | |
gProfileArr[profileIdx][pdpIdx][gLteApnEnumIdx] = $(this).find("lte_apn").text(); | |
gProfileArr[profileIdx][pdpIdx][gUser23gEnumIdx] = $(this).find("usr_2g3g").text(); | |
gProfileArr[profileIdx][pdpIdx][gPsswd23gEnumIdx] = $(this).find("pswd_2g3g").text(); | |
gProfileArr[profileIdx][pdpIdx][gAuthType23gEnumIdx] = $(this).find("authtype_2g3g").text(); | |
gProfileArr[profileIdx][pdpIdx][gUser4gEnumIdx] = $(this).find("usr_4g").text(); | |
gProfileArr[profileIdx][pdpIdx][gPsswd4gEnumIdx] = $(this).find("pswd_4g").text(); | |
gProfileArr[profileIdx][pdpIdx][gAuthType4gEnumIdx] = $(this).find("authtype_4g").text(); | |
gProfileArr[profileIdx][pdpIdx][gMtuEnumIdx] = $(this).find("mtu").text(); | |
++pdpIdx; | |
}); | |
}); | |
} | |
$("#SelInterConnMode").val(gProto); | |
if("cellular" == gProto) { | |
$("#divCellularConn").show(); | |
} else { | |
$("#divCellularConn").hide(); | |
} | |
$("#selPdpProfileName").empty(); | |
for(var profileIdx = 0; profileIdx < profileNameArr.length; ++profileIdx) { | |
var optHtml = "<option value=" + profileNameArr[profileIdx] + ">" + profileNameArr[profileIdx] + "</option>"; | |
$("#selPdpProfileName").append(optHtml); | |
} | |
$("#selPdpProfileName").val(activeProfile); | |
if("default" == activeProfile) { | |
$("#lt_interCon_delPdpProfile").hide(); | |
} else { | |
$("#lt_interCon_delPdpProfile").show(); | |
} | |
showProfilePdpList(activeProfile); | |
} | |
function showProfilePdpList(activeProfile) { | |
$("#lsPdpInfoListtree").empty(); | |
for(var profileIdx = 0; profileIdx < gProfileArr.length; ++profileIdx) { | |
for(var pdpIdx = 0; pdpIdx < gProfileArr[profileIdx].length; ++pdpIdx) { | |
if(activeProfile != gProfileArr[profileIdx][pdpIdx][gProfileNameEnumIdx]) { | |
continue; | |
} | |
var pdptype = gProfileArr[profileIdx][pdpIdx][gPdpTypeEnumIdx]; | |
var strLiHtml; | |
if("default" == activeProfile) { | |
strLiHtml = "<li style='list-style-type: none;' name='" + pdptype + "'><input type='checkbox' style='display:inline;margin-right:5px;'><a><strong>" | |
+ GetNameForPdpType(pdptype) + "</strong></a></li>"; | |
} else { | |
strLiHtml = "<li style='list-style-type: none;' name='" + pdptype + "'><input type='checkbox' style='display:inline;margin-right:5px;'><a><strong>" | |
+ GetNameForPdpType(pdptype) + "</strong></a><a class='delPdp'>" + jQuery.i18n.prop("lt_interCon_deletePdpItem") + "</a></li>"; | |
} | |
$("#lsPdpInfoListtree").append(strLiHtml); | |
if(1 == gProfileArr[profileIdx][pdpIdx][gEnabledEnumIdx]) { | |
$("#lsPdpInfoListtree li:last input").attr("checked",true); | |
} else { | |
$("#lsPdpInfoListtree li:last input").attr("checked",false); | |
} | |
$("#lsPdpInfoListtree li:last input").click(function() { | |
EnabledPdp($(this).parent().attr("name"),$(this).attr("checked")?1:0); | |
}); | |
if("default" != activeProfile) { | |
$("#lsPdpInfoListtree li:last a:last").click(function() { | |
DelPdp($(this).parents("li:first").attr("name")); | |
}); | |
} | |
$("#lsPdpInfoListtree li:last a:first").click(function() { | |
EditPdp($(this).parents("li:first").attr("name")); | |
}); | |
} | |
} | |
} | |
function GetSelectedPdpInfo(pdpType) { | |
var pdpArr=null; | |
var bFound = false; | |
for(var profileIdx = 0; profileIdx < gProfileArr.length; ++profileIdx) { | |
for(var pdpIdx = 0; pdpIdx < gProfileArr[profileIdx].length; ++pdpIdx) { | |
if($("#selPdpProfileName").val() != gProfileArr[profileIdx][pdpIdx][gProfileNameEnumIdx] | |
|| pdpType != gProfileArr[profileIdx][pdpIdx][gPdpTypeEnumIdx]) { | |
continue; | |
} | |
pdpArr = gProfileArr[profileIdx][pdpIdx]; | |
bFound = true; | |
break; | |
} | |
if(bFound) { | |
break; | |
} | |
} | |
return pdpArr; | |
} | |
function EnabledPdp(pdpType,enabledStatus) { | |
var pdpArr =GetSelectedPdpInfo(pdpType); | |
var configMap = new Map(); | |
configMap.put("RGW/wan/profile/profile_name",pdpArr[gProfileNameEnumIdx]); | |
configMap.put("RGW/wan/profile/action",6); | |
configMap.put("RGW/wan/profile/connection_num",pdpArr[gConnNumEnumIdx]); | |
configMap.put("RGW/wan/profile/type",pdpArr[gPdpTypeEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/connection_num", pdpArr[gConnNumEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/type",pdpArr[gTypeEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/auto_apn",pdpArr[gAutoApnEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/connect_mode",pdpArr[gConnModeEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/lte_default",pdpArr[gLteDefaultEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/data_on_roaming",pdpArr[gDataOnRoamEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/pdp_name",pdpArr[gPdpNameEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/enable",enabledStatus); | |
configMap.put("RGW/wan/pdp_info/ip_type", pdpArr[gIpTypeEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/apn",pdpArr[gApnEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/lte_apn",pdpArr[gLteApnEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/authtype_2g3g", pdpArr[gAuthType23gEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/pswd_2g3g",pdpArr[gPsswd23gEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/usr_2g3g",pdpArr[gUser23gEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/usr_4g", pdpArr[gUser4gEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/pswd_4g",pdpArr[gPsswd4gEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/authtype_4g",pdpArr[gAuthType4gEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/mtu",pdpArr[gMtuEnumIdx]); | |
CloseDlg(); | |
var retXml = PostXml("cm","configs_handler",configMap); | |
if("OK" == $(retXml).find("response_status").text()) { | |
GetWanConfig(); | |
} else { | |
alert("enabled pdp failed."); | |
} | |
} | |
function ValideMtu() { | |
if("" == $("#txtMtuValue").val()) { | |
return false; | |
} | |
var mtuValue = parseInt($("#txtMtuValue").val()); | |
if(mtuValue < 1000 || mtuValue > 1500) { | |
return false; | |
} | |
return true; | |
} | |
function DisableEnablePDPParam(disable_flag) { | |
if (disable_flag == "1") { | |
$("#SelConnMode").attr("disabled", true); | |
$("#selLteDefault").attr("disabled", true); | |
$("#selDialInRoaming").attr("disabled", true); | |
$("#txtPdpName").attr("disabled", true); | |
$("#selEnabledPdp").attr("disabled", true); | |
$("#SelIpType").attr("disabled", true); | |
$("#txtAPNname").attr("disabled", true); | |
$("#txtLteAPNname").attr("disabled", true); | |
$("#txt2G3GUser").attr("disabled", true); | |
$("#txt2G3GPassword").attr("disabled", true); | |
$("#Sel2G3GAuthType").attr("disabled", true); | |
$("#txt4GUser").attr("disabled", true); | |
$("#txt4GPassword").attr("disabled", true); | |
$("#Sel4GAuthType").attr("disabled", true); | |
$("#txtMtuValue").attr("disabled", true); | |
} else { | |
$("#SelConnMode").attr("disabled", false); | |
$("#selLteDefault").attr("disabled", false); | |
$("#selDialInRoaming").attr("disabled", false); | |
$("#txtPdpName").attr("disabled", false); | |
$("#selEnabledPdp").attr("disabled", false); | |
$("#SelIpType").attr("disabled", false); | |
$("#txtAPNname").attr("disabled", false); | |
$("#txtLteAPNname").attr("disabled", false); | |
$("#txt2G3GUser").attr("disabled", false); | |
$("#txt2G3GPassword").attr("disabled", false); | |
$("#Sel2G3GAuthType").attr("disabled", false); | |
$("#txt4GUser").attr("disabled", false); | |
$("#txt4GPassword").attr("disabled", false); | |
$("#Sel4GAuthType").attr("disabled", false); | |
$("#txtMtuValue").attr("disabled", false); | |
} | |
} | |
function EditPdp(pdpType) { | |
var pdpArr =GetSelectedPdpInfo(pdpType); | |
ShowDlg("divPDPSetting",400,600); | |
$("#selPdpType").attr("readonly","readonly").attr("disabled","disabled"); | |
$("#selPdpType").val(pdpArr[gPdpTypeEnumIdx]); | |
$("#selAutoApnSwitch").val(pdpArr[gAutoApnEnumIdx]); | |
$("#SelConnMode").val(pdpArr[gConnModeEnumIdx]); | |
$("#selLteDefault").val(pdpArr[gLteDefaultEnumIdx]); | |
$("#selDialInRoaming").val(pdpArr[gDataOnRoamEnumIdx]); | |
$("#txtPdpName").val(pdpArr[gPdpNameEnumIdx]); | |
$("#selEnabledPdp").val(pdpArr[gEnabledEnumIdx]); | |
$("#SelIpType").val(pdpArr[gIpTypeEnumIdx]); | |
$("#txtAPNname").val(pdpArr[gApnEnumIdx]); | |
$("#txtLteAPNname").val(pdpArr[gLteApnEnumIdx]); | |
$("#txt2G3GUser").val(pdpArr[gUser23gEnumIdx]); | |
$("#txt2G3GPassword").val(pdpArr[gPsswd23gEnumIdx]); | |
$("#Sel2G3GAuthType").val(pdpArr[gAuthType23gEnumIdx]); | |
$("#txt4GUser").val(pdpArr[gUser4gEnumIdx]); | |
$("#txt4GPassword").val(pdpArr[gPsswd4gEnumIdx]); | |
$("#Sel4GAuthType").val(pdpArr[gAuthType4gEnumIdx]); | |
$("#txtMtuValue").val(pdpArr[gMtuEnumIdx]); | |
DisableEnablePDPParam(pdpArr[gAutoApnEnumIdx]); | |
$("#selAutoApnSwitch").change(function() { | |
DisableEnablePDPParam($(this).val()); | |
}); | |
$("#lt_btnSave").click(function() { | |
if(!ValideMtu()) { | |
$("#lPdpSetError").show().text(jQuery.i18n.prop("lMtuInvalidTip")); | |
return; | |
} | |
var configMap = new Map(); | |
configMap.put("RGW/wan/profile/profile_name",pdpArr[gProfileNameEnumIdx]); | |
configMap.put("RGW/wan/profile/action",6); | |
configMap.put("RGW/wan/profile/connection_num",pdpArr[gConnNumEnumIdx]); | |
configMap.put("RGW/wan/profile/type",pdpArr[gPdpTypeEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/connection_num", pdpArr[gConnNumEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/type",pdpArr[gPdpTypeEnumIdx]); | |
configMap.put("RGW/wan/pdp_info/auto_apn",$("#selAutoApnSwitch").val()); | |
configMap.put("RGW/wan/pdp_info/connect_mode",$("#SelConnMode").val()); | |
configMap.put("RGW/wan/pdp_info/lte_default",$("#selLteDefault").val()); | |
configMap.put("RGW/wan/pdp_info/data_on_roaming",$("#selDialInRoaming").val()); | |
configMap.put("RGW/wan/pdp_info/pdp_name",$("#txtPdpName").val()); | |
configMap.put("RGW/wan/pdp_info/enable",$("#selEnabledPdp").val()); | |
configMap.put("RGW/wan/pdp_info/ip_type", $("#SelIpType").val()); | |
configMap.put("RGW/wan/pdp_info/apn",$("#txtAPNname").val()); | |
configMap.put("RGW/wan/pdp_info/lte_apn",$("#txtLteAPNname").val()); | |
configMap.put("RGW/wan/pdp_info/authtype_2g3g", $("#Sel2G3GAuthType").val()); | |
configMap.put("RGW/wan/pdp_info/pswd_2g3g",$("#txt2G3GPassword").val()); | |
configMap.put("RGW/wan/pdp_info/usr_2g3g",$("#txt2G3GUser").val()); | |
configMap.put("RGW/wan/pdp_info/usr_4g", $("#txt4GUser").val()); | |
configMap.put("RGW/wan/pdp_info/pswd_4g",$("#txt4GPassword").val()); | |
configMap.put("RGW/wan/pdp_info/authtype_4g",$("#Sel4GAuthType").val()); | |
configMap.put("RGW/wan/pdp_info/mtu",$("#txtMtuValue").val()); | |
CloseDlg(); | |
var retXml = PostXml("cm","configs_handler",configMap); | |
if("OK" == $(retXml).find("response_status").text()) { | |
GetWanConfig(); | |
} else { | |
alert("edit pdp failed."); | |
} | |
}); | |
} | |
function DelPdp(pdpType) { | |
var pdpArr =GetSelectedPdpInfo(pdpType); | |
var strMsg = "Are you sure to delete \"" + GetNameForPdpType(pdpType) + "\"?"; | |
if(!confirm(strMsg)) { | |
return; | |
} | |
var configMap = new Map(); | |
configMap.put("RGW/wan/profile/profile_name",pdpArr[gProfileNameEnumIdx]); | |
configMap.put("RGW/wan/profile/action", 5); | |
configMap.put("RGW/wan/profile/connection_num", pdpArr[gConnNumEnumIdx]); | |
configMap.put("RGW/wan/profile/type", pdpType); | |
var retXml = PostXml("cm","configs_handler",configMap); | |
if("OK" == $(retXml).find("response_status").text()) { | |
GetWanConfig(); | |
} else { | |
alert("delPdp failed."); | |
} | |
} | |
function GetVersionSwitch() { | |
var retXml = PostXml("cm","cm_get_image_type"); | |
gVersionSwitchFlag = $(retXml).find("Image_type").text(); | |
$("#SelVersionSwitch").val(gVersionSwitchFlag); | |
} | |
function SetVersionSwitch() { | |
if("cellular" != $("#SelInterConnMode").val() || | |
gVersionSwitchFlag == $("#SelVersionSwitch").val()) | |
return; | |
var mapConfig = new Map(); | |
mapConfig.put("RGW/wan/Image_type",$("#SelVersionSwitch").val()); | |
PostXml("cm","cm_set_image_type",mapConfig); | |
GetVersionSwitch(); | |
} | |
function HideNetPerferModeDiv() { | |
$("#div4G3G2GPrefer").hide(); | |
$("#div3G2GPrefer").hide(); | |
$("#div4G3GPrefer").hide(); | |
$("#div5G4GPrefer").hide(); | |
} | |
function GetConnNumFromPdpType(type) { | |
var connNum; | |
switch(type) { | |
case "default": | |
connNum = 0x00; | |
break; | |
case "ims": | |
connNum = 0x10; | |
break; | |
case "mms": | |
connNum = 0x20; | |
break; | |
case "supl": | |
connNum = 0x30; | |
break; | |
case "fota": | |
connNum = 0x40; | |
break; | |
case "bip": | |
connNum = 0x40; | |
break; | |
} | |
return connNum; | |
} | |
function GetNameForPdpType(pdptype) { | |
var strPdpTypeName=""; | |
switch(pdptype) { | |
case "default": | |
strPdpTypeName = "Internet PDP"; | |
break; | |
case "ims": | |
strPdpTypeName = "IMS PDP"; | |
break; | |
case "mms": | |
strPdpTypeName = "MMS PDP"; | |
break; | |
case "supl": | |
strPdpTypeName = "SUPL PDP"; | |
break; | |
case "fota": | |
strPdpTypeName = "FOTA PDP"; | |
break; | |
case "bip": | |
strPdpTypeName = "BIP PDP"; | |
break; | |
} | |
return strPdpTypeName; | |
} | |
return this; | |
} | |
})(jQuery); | |