blob: 471628ccfa07d3ad331a7bde8d7895ef3ee86489 [file] [log] [blame]
(function($) {
$.fn.objdashboard = function(oInit) {
var gWanConfigProto;
var internet_autoapn;
this.onLoad = function(flag) {
if(flag) {
$("#mainColumn").html(CallHtmlFile("html/dashboard.html"));
LocalAllElement();
$("#lChangeConnStatus").click(function() {
var configMap = new Map();
configMap.put("RGW/wan/connect_switch/proto",gWanConfigProto);
configMap.put("RGW/wan/connect_switch/dial_switch",$(this).attr("name"));
PostXml("cm","connection_switch",configMap);
GetWanConfig();
GetLinkContext();
});
$("#lt_dashbd_resetTrafficStatistic").click(function() {
var retXml = PostXml("statistics","stat_clear_common_data");
if("ERROR" == $(retXml).find("setting_response").text()) {
alert("stat_clear_common_data failed.");
}
GetTrafficStaticInfo();
});
}
GetSmsNewArrive();
GetSimStatus();
GetWifiStatus();
GetLinkContext();
GetRouterInfo();
GetWanConfig();
GetBatteryConfig();
GetConnectedDeviceInfo();
GetTrafficStaticInfo();
GetVersionInfo();
GetEngLteInfo();
}
function GetEngLteInfo() {
var retXml = PostXml("cm","get_wan_configs");
EngModeFlag = $(retXml).find("eng_mode").text();
if(EngModeFlag==1)
$("#engModeLTEInfo").show();
else
$("#engModeLTEInfo").hide();
if(EngModeFlag!=1)
return;
retXml = PostXml("cm","get_eng_info");
if("OK" == $(retXml).find("response_status").text()) {
$("#txtLTE_mcc").text($(retXml).find("mcc").text());
$("#txtLTE_mnc").text($(retXml).find("mnc").text());
$("#txtLTE_phy_cellid").text($(retXml).find("phy_cell_id").text());
$("#txtLTE_cellid").text($(retXml).find("cell_id").text());
$("#txtLTE_dl_euarfcn").text($(retXml).find("dl_euarfcn").text());
$("#txtLTE_ul_euarfcn").text($(retXml).find("ul_euarfcn").text());
$("#txtLTE_dl_bandwidth").text($(retXml).find("dl_bandwidth").text());
$("#txtLTE_transmission_mode").text($(retXml).find("transmission_mode").text());
$("#txtLTE_main_rsrp").text($(retXml).find("main_rsrp").text());
$("#txtLTE_diversity_rsrp").text($(retXml).find("diversity_rsrp").text());
$("#txtLTE_main_rsrq").text($(retXml).find("main_rsrq").text());
$("#txtLTE_diversity_rsrq").text($(retXml).find("diversity_rsrq").text());
$("#txtLTE_sinr").text($(retXml).find("sinr").text());
$("#txtLTE_rssi").text($(retXml).find("rssi").text());
$("#txtLTE_dl_bler").text($(retXml).find("dl_bler").text());
$("#txtLTE_ul_bler").text($(retXml).find("ul_bler").text());
$("#txtLTE_dl_througgout").text($(retXml).find("dl_throughput").text());
$("#txtLTE_ul_throughput").text($(retXml).find("ul_throughput").text());
$("#txtLTE_tx_power").text($(retXml).find("tx_power").text());
}
else
$("#engModeLTEInfo").hide();
}
function GetVersionInfo() {
var retXml = PostXml("version","get_version");
if("OK" == $(retXml).find("setting_response").text()) {
$("#txtRouterMAC").text($(retXml).find("mac_addr").text());
$("#txtSoftVersion").text($(retXml).find("sw_version").text());
$("#txtHardVersion").text($(retXml).find("hdware_ver").text());
}
}
function GetTrafficStaticInfo() {
var retXml = PostXml("statistics","stat_get_common_data");
if("ERROR" != $(retXml).find("setting_response").text()) {
$("#txtRecPackets").text($(retXml).find("total_rx_bytes").text());
$("#txtsentPackets").text($(retXml).find("total_tx_bytes").text());
}
}
function GetConnectedDeviceInfo() {
var retXml = PostXml("statistics","get_active_clients_num");
document.getElementById("lConnDeviceValue").innerHTML = $(retXml).find("active_clients_num").text();
}
function GetBatteryConfig() {
var retXml = PostXml("aoc","get_chg_info");
var err = $(retXml).find("error_cause").text();
var bIsChargernotrun = false;
if("3"==err) {
bIsChargernotrun = true;
}
if(bIsChargernotrun) {
$("#lDashChargeStatus").text(jQuery.i18n.prop("lNoBattery"));
$("#lDashBatteryQuantity").text(jQuery.i18n.prop("lNoBattery"));
return;
}
var Batterystatus = $(retXml).find("bat_status").text();
var Batterypercent = $(retXml).find("capacity").text();
var Battery_connect = $(retXml).find("present").text();
var Battery_technology = $(retXml).find("bat_technology").text();
if(Battery_technology==0){
$("#battery_status").hide();
}
if (Battery_connect == 0) {
$("#lDashChargeStatus").text(jQuery.i18n.prop("lNoBattery"));
$("#lDashBatteryQuantity").text(jQuery.i18n.prop("lNoBattery"));
} else if (Battery_connect == 1) {
if (Batterystatus == "0")
$("#lDashChargeStatus").text(jQuery.i18n.prop("lBatteryUnknownError"));
if (Batterystatus == "1")
$("#lDashChargeStatus").text(jQuery.i18n.prop("lCharging"));
if (Batterystatus == "2")
$("#lDashChargeStatus").text(jQuery.i18n.prop("lUncharged"));
if (Batterystatus == "3")
$("#lDashChargeStatus").text(jQuery.i18n.prop("lBatteryUnchargewithconnect"));
if (Batterystatus == "4")
$("#lDashChargeStatus").text(jQuery.i18n.prop("lFullycharged"));
var Battery_charge_percent = Batterypercent + '%';
$("#lDashBatteryQuantity").text(Battery_charge_percent);
}
}
function GetWanConfig() {
var retXml = PostXml("cm","get_wan_configs");
gWanConfigProto = $(retXml).find("proto").text();
if("cellular" == $(retXml).find("dial_switch").text()) {
$("#lCurConnStatus").text(jQuery.i18n.prop("lt_optEnableSwitch"));
$("#lChangeConnStatus").text(jQuery.i18n.prop("lt_optDisable"));
$("#lChangeConnStatus").attr("name","disabled");
//$("#globeImage").attr("src", "images/globe.png");
//$("#imgGlobalConnArrow").attr("src", "images/con-arrow.png");
} else {
$("#lCurConnStatus").text(jQuery.i18n.prop("lt_optDisabledSwitch"));
$("#lChangeConnStatus").text(jQuery.i18n.prop("lt_optEnable"));
$("#lChangeConnStatus").attr("name","cellular");
//$("#globeImage").attr("src", "images/globe_gr.png");
//$("#imgGlobalConnArrow").attr("src", "images/discon-arrow.png");
}
}
function GetRouterInfo() {
var retXml = PostXml("router","router_get_dhcp_settings");
if(1 == $(retXml).find("disable").text()) {
$("#imgDhcpServerSwitch").attr("src", "images/status-icon2.png");
$("#lDhcpServerSwitch").text(jQuery.i18n.prop("lt_optDisabledSwitch"));
} else {
$("#imgDhcpServerSwitch").attr("src", "images/status-icon3.png");
$("#lDhcpServerSwitch").text(jQuery.i18n.prop("lt_optEnableSwitch"));
}
retXml = PostXml("router","router_get_lan_ip");
$("#txtRouterLanIP").text($(retXml).find("lan_ip").text());
$("#txtRouterMask").text($(retXml).find("lan_netmask").text());
retXml = PostXml("router","get_router_runtime");
var days = $(retXml).find("run_days").text();
var hour = $(retXml).find("run_hours").text();
var min = $(retXml).find("run_min").text();
var sec = $(retXml).find("run_sec").text();
var strRunTime = "";
if(parseInt(days)>0) {
strRunTime = strRunTime + days + jQuery.i18n.prop("ldDay");
}
strRunTime = strRunTime + " " + hour + ":" + min + ":" + sec;
$("#txtDashRouterRunTime").text(strRunTime);
}
function SetPdpConnectIcon(){
$("#globeImage").attr("src", "images/globe.png");
$("#imgGlobalConnArrow").attr("src", "images/con-arrow.png");
}
function SetPdpDisconnectIcon(){
$("#globeImage").attr("src", "images/globe_gr.png");
$("#imgGlobalConnArrow").attr("src", "images/discon-arrow.png");
}
function GetLinkContext() {
var retXml = PostXml("cm","get_link_context");
/************************************************
***************** parse cellular basic info. *************
*************************************************/
$("#txtRouterIMEI").text($(retXml).find("IMEI").text());
if(1 == $(retXml).find("roaming").text()) {
$("#txtNetworkOperator").text($(retXml).find("roaming_network_name").text());
$("#divRoamingStatus").show();
} else {
$("#txtNetworkOperator").text($(retXml).find("network_name").text());
$("#divRoamingStatus").hide();
}
//<sys_mode/> <!-- 0: no service 1:2G3G 2:LTE 3: LTEP->
var cellularSysNetworkMode = $(retXml).find("sys_mode").text();
var cellularImsState = $(retXml).find("ims_state").text();
if(0 == cellularSysNetworkMode) {
$("#txtSystemNetworkMode").text(jQuery.i18n.prop("lt_dashbd_NoService"));
} else if(1 == cellularSysNetworkMode) {
$("#txtSystemNetworkMode").text("2G3G");
} else if(2 == cellularSysNetworkMode) {
$("#txtSystemNetworkMode").text("4G");
} else if (3 == cellularSysNetworkMode) {
$("#txtSystemNetworkMode").text("4G+");
} else if (4 == cellularSysNetworkMode) {
$("#txtSystemNetworkMode").text("5G");
}
if (1 == cellularImsState) {
$("#txtVolteState").text(jQuery.i18n.prop("volteState_registered"));
}
else {
$("#txtVolteState").text(jQuery.i18n.prop("volteState_unregistered"));
}
//<data_mode/> <!-- 1: GPRS 2: EDGE 9: HSPDA 10: HSUPA 11:HSPA 14: LTE -->
var cellularDataConnMode = $(retXml).find("data_mode").text();
if(1 == cellularDataConnMode) {
$("#txtDataConnMode").text("GPRS");
} else if(2 == cellularDataConnMode) {
$("#txtDataConnMode").text("EDGE");
} else if(9 == cellularDataConnMode) {
$("#txtDataConnMode").text("HSUPA");
} else if(10 == cellularDataConnMode) {
$("#txtDataConnMode").text("HSDPA");
} else if(11 == cellularDataConnMode) {
$("#txtDataConnMode").text("HSPA");
} else if(14 == cellularDataConnMode) {
$("#txtDataConnMode").text("LTE");
} else if(15 == cellularDataConnMode) {
$("#txtDataConnMode").text("HSPAP");
} else if (21 == cellularDataConnMode) {
$("#txtDataConnMode").text("EUTRAN_TO_5GCN");
} else if (22 == cellularDataConnMode) {
$("#txtDataConnMode").text("NR");
} else if (23 == cellularDataConnMode) {
$("#txtDataConnMode").text("NGRAN");
} else if (24 == cellularDataConnMode) {
$("#txtDataConnMode").text("EUTRAN/NR");
}
var rssi = $(retXml).find("rssi").text();
SetSignalStrength(rssi,cellularSysNetworkMode);
/************************************************
**************** parse PDP infor. ****************
*****************************************/
$("#txtPdpconnStatus,#txtPdpApn").text("");
$("#txtPdpIpv4Addr").text("");
$("#txtPdpIpv4Dns1").text("");
$("#txtPdpIpv4Dns2").text("");
$("#txtPdpIpv4GateWay").text("");
$("#txtPdpIpv4NetMask").text("");
$("#txtPdpIpv6Addr").text("");
$("#txtPdpIpv6Dns1").text("");
$("#txtPdpIpv6Dns2").text("");
$(retXml).find("contextlist").each(function() {
$(this).find("Item").each(function() {
/*0-disconnect;1-connected;2-connecting*/
var connetStatus = $(retXml).find("connection_status").text(); //
/*0- secondary pdp;1-primary pdp*/
var pdpType = $(retXml).find("pdp_type").text();
/*0-ipv4v6;1-ipv4;2-ipv6*/
var ipType = $(retXml).find("ip_type").text();
var auto_apn = $(retXml).find("auto_apn").text();
var authtype_23g = $(retXml).find("authtype_2g3g").text();
var authtype_4g = $(retXml).find("authtype_4g").text();
var connect_mode = $(retXml).find("connect_mode").text();
var data_on_roaming = $(retXml).find("data_on_roaming").text();
if(0 == connetStatus) {
$("#txtPdpconnStatus").text(jQuery.i18n.prop("pdpConnStatus_disconnected"));
SetPdpDisconnectIcon();
} else if(1 == connetStatus) {
$("#txtPdpconnStatus").text(jQuery.i18n.prop("pdpConnStatus_connected"));
SetPdpConnectIcon();
} else if(2 == connetStatus) {
$("#txtPdpconnStatus").text(jQuery.i18n.prop("pdpConnStatus_connecting"));
SetPdpDisconnectIcon();
}
if(2 == cellularSysNetworkMode) { /*LTE*/
var lteApn = $(retXml).find("lte_apn").text();
if("" == lteApn) {
$("#txtPdpApn").text($(retXml).find("apn").text());
} else {
$("#txtPdpApn").text($(retXml).find("lte_apn").text());
}
} else {
$("#txtPdpApn").text($(retXml).find("apn").text());
}
$("#txtPdpIpv4Addr").text($(retXml).find("ipv4_ip").text());
$("#txtPdpIpv4Dns1").text($(retXml).find("ipv4_dns1").text());
$("#txtPdpIpv4Dns2").text($(retXml).find("ipv4_dns2").text());
$("#txtPdpIpv4GateWay").text($(retXml).find("ipv4_gateway").text());
$("#txtPdpIpv4NetMask").text($(retXml).find("ipv4_submask").text());
$("#txtPdpIpv6Addr").text($(retXml).find("ipv6_ip").text());
$("#txtPdpIpv6Dns1").text($(retXml).find("ipv6_dns1").text());
$("#txtPdpIpv6Dns2").text($(retXml).find("ipv6_dns2").text());
if(0 == ipType) {
$("#pdpIpv4Info").show();
$("#pdpIpv6Info").show();
$("#txtPdpApn_iptype").text("IPV4V6");
} else if(1 == ipType) {
$("#pdpIpv4Info").show();
$("#pdpIpv6Info").hide();
$("#txtPdpApn_iptype").text("IPV4");
} else if(2 == ipType) {
$("#pdpIpv4Info").hide();
$("#pdpIpv6Info").show();
$("#txtPdpApn_iptype").text("IPV6");
}
if (1 == auto_apn) {
$("#txtPdpApn_mode").text(jQuery.i18n.prop("lAlways"));
$("#DivMMSInfo").show();
} else {
$("#DivMMSInfo").hide();
$("#txtPdpApn_mode").text(jQuery.i18n.prop("lManual"));
}
if (1 == connect_mode) {
/*auto*/
$("#txtPdpApn_conn_mode").text(jQuery.i18n.prop("lAlways"));
} else {
/*manual*/
$("#txtPdpApn_conn_mode").text(jQuery.i18n.prop("lManual"));
}
if (1 == data_on_roaming) {
$("#txtPdpApn_roaming").text(jQuery.i18n.prop("lEnabled"));
} else {
$("#txtPdpApn_roaming").text(jQuery.i18n.prop("lDisabled"));
}
$("#txtPdpApn_mtu").text($(retXml).find("mtu").text());
if ("PAP" == authtype_23g ||"CHAP" == authtype_23g ||"PAP" == authtype_4g ||"CHAP" == authtype_4g) {
$("#DivAuthInfo").show();
$("#txtPdpApn_Authtype_23g").text($(retXml).find("authtype_2g3g").text());
$("#txtPdpApn_user_23g").text($(retXml).find("usr_2g3g").text());
$("#txtPdpApn_pswd_23g").text($(retXml).find("pswd_2g3g").text());
$("#txtPdpApn_Authtype_4g").text($(retXml).find("authtype_4g").text());
$("#txtPdpApn_user_4g").text($(retXml).find("usr_4g").text());
$("#txtPdpApn_pswd_4g").text($(retXml).find("pswd_4g").text());
} else {
$("#DivAuthInfo").hide();
}
});
});
}
function GetSimStatus() {
$("#divSimCardAbsent").hide();
$("#divRequiredPinPuk").hide();
$("#divCellularConn").hide();
var retXml = PostXml("sim","get_sim_status");
if("OK" != $(retXml).find("setting_response").text()) {
//alert("Get Sim Status failed.");
//return;
}
//sim_status: <!--0: sim absent 1:sim present 2: sim error 3: unknown error-->
//pin_status: <!--0: unkown 1: detected 2: need pin 3: need puk 5: ready-->
var simStatus = $(retXml).find("sim_status").text();
var pinStatus = $(retXml).find("pin_status").text();
if(0 == simStatus) {
$("#divSimCardAbsent").show();
$("#txtSimStatus").text(jQuery.i18n.prop("lSimStatusAbsent"));
} else if(1 == simStatus) {
if(2 == pinStatus) {
$("#divRequiredPinPuk").show();
$("#txtPinPuk").text("PIN");
} else if(3 == pinStatus) {
$("#divRequiredPinPuk").show();
$("#txtPinPuk").text("PUK");
} else {
$("#divCellularConn").show();
}
} else if(2 == simStatus) {
$("#divSimCardAbsent").show();
$("#txtSimStatus").text(jQuery.i18n.prop("lSimStatusError"));
} else if(3 == simStatus) {
$("#divSimCardAbsent").show();
$("#txtSimStatus").text(jQuery.i18n.prop("lSimStatusUnknownError"));
}
}
function GetWifiStatus() {
var retXml = PostXml("wireless","wifi_get_detail");
var wifi24GStatus,wifi5GStatus;
var band24GSupport = 0;
var band5GSupport = 0;
var wifiDisabled = 0;
var wirelessAPNum = $(retXml).find("wireless_num").text();
if (wirelessAPNum == 0) {
$("#div_dashbd_wifi").hide();
$("#lNoWifi").show().text(jQuery.i18n.prop('lNoWiFiCardError'));
return;
}
$(retXml).find("wifi_if_24G").each(function() {
wifi24GStatus = $(this).find("switch").text();
});
$(retXml).find("wifi_if_5G").each(function() {
wifi5GStatus = $(this).find("switch").text();
});
if (null != wifi24GStatus)
band24GSupport = 1;
if (null != wifi5GStatus)
band5GSupport = 1;
if (band24GSupport && band5GSupport) {
if("off" == wifi24GStatus && "off" == wifi5GStatus) {
wifiDisabled = 1;
}
} else if (band24GSupport) {
if("off" == wifi24GStatus) {
wifiDisabled = 1;
}
} else if (band5GSupport) {
if ("off" == wifi5GStatus) {
wifiDisabled = 1;
}
}
if (wifiDisabled)
{
$("#lWLANStatus").text(jQuery.i18n.prop("lt_optDisabledSwitch"));
$("#imgWifiConnStatus").attr("src", "images/status-icon2.png");
$("#divWifiSet").hide();
$("#imgWifiConnArrow").attr("src", "images/discon-arrow.png");
$("#imgNetwork").attr("src", "images/network_gr.png");
return;
}
$("#imgWifiConnArrow").attr("src", "images/con-arrow.png");
$("#imgNetwork").attr("src", "images/network.png");
$("#lWLANStatus").text(jQuery.i18n.prop("lt_optEnableSwitch"));
$("#imgWifiConnStatus").attr("src", "images/status-icon3.png");
$("#divWifiSet").show();
var wifiModeTag;
if("on" == wifi24GStatus) {
wifiModeTag = "wifi_if_24G";
} else {
wifiModeTag = "wifi_if_5G";
}
$(retXml).find(wifiModeTag).each(function() {
$("#txtWifiSSID").text($(this).find("ssid").text());
$("#txtWifiChannel").text($(this).find("channel").text());
$("#txtWifiSecMode").text(GetAuthType($(this).find("encryption").text()));
});
}
function SetSignalStrength(rssi,cellularSysNetworkMode) {
if(0 == cellularSysNetworkMode) {
document.getElementById("imgSignalStrength").src = "images/signal0.png";
} else if(1 == cellularSysNetworkMode) { //GSM
if (rssi < 7)
document.getElementById("imgSignalStrength").src = "images/signal0.png";
else if (rssi >= 7 && rssi < 14)
document.getElementById("imgSignalStrength").src = "images/signal1.png";
else if (rssi >= 14 && rssi < 19)
document.getElementById("imgSignalStrength").src = "images/signal2.png";
else if (rssi >= 19 && rssi < 24)
document.getElementById("imgSignalStrength").src = "images/signal3.png";
else if (rssi >= 24 && rssi <= 63)
document.getElementById("imgSignalStrength").src = "images/signal4.png";
}/* else if (2 == cellularSysNetworkMode) { //3G
if (rssi < 17)
document.getElementById("imgSignalStrength").src = "images/signal0.png";
else if (rssi >= 17 && rssi < 22)
document.getElementById("imgSignalStrength").src = "images/signal1.png";
else if (rssi >= 22 && rssi < 27)
document.getElementById("imgSignalStrength").src = "images/signal2.png";
else if (rssi >= 27 && rssi < 31)
document.getElementById("imgSignalStrength").src = "images/signal3.png";
else if (rssi >= 31 && rssi <= 96)
document.getElementById("imgSignalStrength").src = "images/signal4.png";
}*/ else if (2 == cellularSysNetworkMode) { //LTE
if (rssi < 25)
document.getElementById("imgSignalStrength").src = "images/signal0.png";
else if (rssi >= 25 && rssi < 34)
document.getElementById("imgSignalStrength").src = "images/signal1.png";
else if (rssi >= 34 && rssi < 43)
document.getElementById("imgSignalStrength").src = "images/signal2.png";
else if (rssi >= 43 && rssi < 55)
document.getElementById("imgSignalStrength").src = "images/signal3.png";
else if (rssi >= 55 && rssi <= 97)
document.getElementById("imgSignalStrength").src = "images/signal4.png";
}
}
function GetAuthType(encryptInfo) {
var authType;
switch(encryptInfo) {
//WPA-PSK
case "psk+ccmp":
case "psk+aes":
case "psk":
case "psk+tkip":
case "psk+tkip+ccmp":
case "psk+tkip+aes":
authType = "WPA-PSK";
break;
//WPA2-PSK
case "psk2":
case "psk2+ccmp":
case "psk2+aes":
case "psk2+tkip+ccmp":
case "psk2+tkip+aes":
authType = "WPA2-PSK";
break;
//WPA/WPA2-MIXED
case "mixed-psk":
case "mixed-psk+tkip+aes":
case "mixed-psk+tkip+ccmp":
case "mixed-psk+aes":
case "mixed-psk+ccmp":
authType = "WPA/WPA2-MIXED";
break;
//MEP
case "wep":
case "wep+shared":
authType = "MEP";
break;
case "none":
authType = "NONE";
break;
//WPA3
case "sae":
authType = "WPA3-SAE";
break;
//WPA2-WPA3
case "sae-mixed":
authtype = "WPA2/WPA3-MIXED";
break;
default:
authType = "Unknow Error";
break;
}
return authType;
}
function GetSmsNewArrive() {
var retXml = PostXml("sms","sms.get_new_num");
var smsNewNum = $(retXml).find("new_num").text();
if (smsNewNum > 0) {
var smsNewNotifyMsg = "";
if (smsNewNum > 1)
smsNewNotifyMsg = smsNewNum + " " + jQuery.i18n.prop("lsmsMoreNewArrivedSMS");
else
smsNewNotifyMsg = smsNewNum + " " + jQuery.i18n.prop("lsmsOneNewArrivedSMS");
showMsgBox(jQuery.i18n.prop("lsmsNotification"), smsNewNotifyMsg);
}
}
return this.each(function() {
_dashboardIntervalID = setInterval("g_objContent.onLoad(false)", _dashboardInterval);
});
}
})(jQuery);