you.chen | 808f8ef | 2025-04-02 13:58:10 +0800 | [diff] [blame] | 1 |
|
| 2 | define("service","underscore jquery set CryptoJS".split(" "), function (_, $, config, CryptoJS) {
|
| 3 | function addTimerSomething(querys, cb) {
|
| 4 | if (_.isArray(querys)) {
|
| 5 | for (var i = 0; i < querys.length; i++) {
|
| 6 | addQueryString(querys[i]);
|
| 7 | }
|
| 8 | } else {
|
| 9 | addQueryString(querys);
|
| 10 | }
|
| 11 | addCallback(cb);
|
| 12 | }
|
| 13 | function removeTimerSomething(querys, cb) {
|
| 14 | if (_.isArray(querys)) {
|
| 15 | for (var i = 0; i < querys.length; i++) {
|
| 16 | removeQueryString(querys[i]);
|
| 17 | }
|
| 18 | } else {
|
| 19 | removeQueryString(querys);
|
| 20 | }
|
| 21 | removeCallback(cb);
|
| 22 | }
|
| 23 | function getCurretnMAC() {
|
| 24 | return getUserMacAddr({}).get_user_mac_addr;
|
| 25 | }
|
| 26 | function getDdnsParams(values, callback) {
|
| 27 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 28 | function prepare(values, isPost) {
|
| 29 | return {
|
| 30 | multi_data: 1,
|
| 31 | cmd: "DDNS_Enable,DDNS_Mode,DDNSProvider,DDNSAccount,DDNSPassword,DDNS,DDNS_Hash_Value"
|
| 32 | };
|
| 33 | }
|
| 34 | function deal(paramD) {
|
| 35 | if (paramD) {
|
| 36 | return {
|
| 37 | DDNS_Enable: paramD.DDNS_Enable,
|
| 38 | DDNS_Mode: paramD.DDNS_Mode,
|
| 39 | DDNSProvider: paramD.DDNSProvider,
|
| 40 | DDNSAccount: paramD.DDNSAccount,
|
| 41 | DDNSPassword: paramD.DDNSPassword,
|
| 42 | DDNS: paramD.DDNS,
|
| 43 | DDNS_Hash_Value: paramD.DDNS_Hash_Value
|
| 44 | }
|
| 45 | } else {
|
| 46 | return errUnknownObj;
|
| 47 | }
|
| 48 | }
|
| 49 | }
|
| 50 | function setDDNSForward() {
|
| 51 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 52 | function prepare(values, isPost) {
|
| 53 | var valueReq = $.extend({}, values);
|
| 54 | return valueReq;
|
| 55 | }
|
| 56 | function deal(paramD) {
|
| 57 | if (paramD) {
|
| 58 | return paramD;
|
| 59 | } else {
|
| 60 | return errUnknownObj;
|
| 61 | }
|
| 62 | }
|
| 63 | }
|
| 64 | function getLoginData() {
|
| 65 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 66 | function prepare(values, isPost) {
|
| 67 | var valueReq = {};
|
| 68 | valueReq.cmd = "modem_main_state,puknumber,pinnumber,blc_wan_mode,blc_wan_auto_mode,psw_fail_num_str,login_lock_time,psw_changed";
|
| 69 | valueReq.multi_data = 1;
|
| 70 | return valueReq;
|
| 71 | }
|
| 72 | function deal(paramD) {
|
| 73 | if (paramD) {
|
| 74 | if (paramD.blc_wan_mode == "AUTO") {
|
| 75 | paramD.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';
|
| 76 | } else {
|
| 77 | paramD.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';
|
| 78 | }
|
| 79 | paramD.psw_fail_num_str = paramD.psw_fail_num_str == '' ? config.MAX_LOGIN_COUNT : paramD.psw_fail_num_str;
|
| 80 | paramD.login_lock_time = paramD.login_lock_time == '' ? '300' : paramD.login_lock_time;
|
| 81 | return paramD;
|
| 82 | } else {
|
| 83 | return errUnknownObj;
|
| 84 | }
|
| 85 | }
|
| 86 | }
|
| 87 | function login() {
|
| 88 | return stuffMake(arguments, {}, prepare, deal, {
|
| 89 | errorType: 'badPassword'
|
| 90 | }, true);
|
| 91 | function prepare(values, isPost) {
|
| 92 | var obj = {
|
| 93 | goformId: "LOGIN",
|
w.deng | ccefa88 | 2025-04-10 20:17:16 -0700 | [diff] [blame^] | 94 | password: config.PASSWORD_ENCODE ? Base64.encode(values.password) : values.password,
|
| 95 | username: config.PASSWORD_ENCODE ? Base64.encode(values.username) : values.username
|
you.chen | 808f8ef | 2025-04-02 13:58:10 +0800 | [diff] [blame] | 96 | };
|
| 97 | return obj;
|
| 98 | }
|
| 99 | function deal(paramD) {
|
| 100 | if (paramD && (paramD.result == "0" || paramD.result == "4")) {
|
| 101 | informationAll.isLoggedIn = true;
|
| 102 | return {
|
| 103 | result: true
|
| 104 | };
|
| 105 | } else {
|
| 106 | var loginError = {};
|
| 107 | switch (paramD.result) {
|
| 108 | case "1":
|
| 109 | loginError = {
|
| 110 | errorType: "Login Fail"
|
| 111 | };
|
| 112 | break;
|
| 113 | case "2":
|
| 114 | loginError = {
|
| 115 | errorType: "duplicateUser"
|
| 116 | };
|
| 117 | break;
|
| 118 | case "3":
|
| 119 | loginError = {
|
| 120 | errorType: "badPassword"
|
| 121 | };
|
| 122 | break;
|
| 123 | default:
|
| 124 | loginError = {
|
| 125 | errorType: "Login Fail"
|
| 126 | };
|
| 127 | break;
|
| 128 | }
|
| 129 | informationAll.isLoggedIn = false;
|
| 130 | return $.extend(errUnknownObj, loginError);
|
| 131 | }
|
| 132 | }
|
| 133 | }
|
| 134 | function getLoginStatus() {
|
| 135 | if (informationAll.isLoggedIn != undefined) {
|
| 136 | return stuffMake(arguments, {
|
| 137 | status: informationAll.isLoggedIn ? 'loggedIn' : 'loggedOut'
|
| 138 | });
|
| 139 | } else {
|
| 140 | var resultObject = {};
|
| 141 | if (!config.HAS_LOGIN) {
|
| 142 | resultObject.status = 'loggedIn';
|
| 143 | resultObject.errorType = 'no_login';
|
| 144 | informationAll.isLoggedIn = true;
|
| 145 | }
|
| 146 | return stuffMake(arguments, resultObject, prepare, deal, null, false);
|
| 147 | }
|
| 148 | function prepare(values, isPost) {
|
| 149 | var valueReq = {};
|
| 150 | valueReq.cmd = "loginfo";
|
| 151 | valueReq.multi_data = 1;
|
| 152 | return valueReq;
|
| 153 | }
|
| 154 | function deal(paramD) {
|
| 155 | if (paramD && paramD.loginfo || paramD.loginfo == "") {
|
| 156 | var loginStatus = {};
|
| 157 | switch (paramD.loginfo) {
|
| 158 | case "ok":
|
| 159 | informationAll.isLoggedIn = true;
|
| 160 | loginStatus.status = "loggedIn";
|
| 161 | break;
|
| 162 | default:
|
| 163 | informationAll.isLoggedIn = false;
|
| 164 | loginStatus.status = "loggedOut";
|
| 165 | break;
|
| 166 | }
|
| 167 | return loginStatus;
|
| 168 | } else {
|
| 169 | informationAll.isLoggedIn = undefined;
|
| 170 | return $.extend(errUnknownObj, {
|
| 171 | errorType: "LoginStatusError"
|
| 172 | });
|
| 173 | }
|
| 174 | }
|
| 175 | }
|
| 176 | function enterPIN() {
|
| 177 | return stuffMake(arguments, {}, prepare, deal, {}, true);
|
| 178 | function prepare(values, isPost) {
|
| 179 | var obj = {};
|
| 180 | obj.goformId = "ENTER_PIN";
|
| 181 | obj.PinNumber = values.PinNumber;
|
| 182 | return obj;
|
| 183 | }
|
| 184 | function deal(paramD) {
|
| 185 | if (paramD && paramD.result === "success") {
|
| 186 | return {
|
| 187 | result: true
|
| 188 | };
|
| 189 | } else {
|
| 190 | return {
|
| 191 | result: false
|
| 192 | };
|
| 193 | }
|
| 194 | }
|
| 195 | }
|
| 196 | function enterPUK() {
|
| 197 | return stuffMake(arguments, {}, prepare, deal, {}, true);
|
| 198 | function prepare(values, isPost) {
|
| 199 | var obj = {};
|
| 200 | obj.goformId = "ENTER_PUK";
|
| 201 | obj.PUKNumber = values.PUKNumber;
|
| 202 | obj.PinNumber = values.PinNumber;
|
| 203 | return obj;
|
| 204 | }
|
| 205 | function deal(paramD) {
|
| 206 | if (paramD && paramD.result === "success") {
|
| 207 | return {
|
| 208 | result: true
|
| 209 | };
|
| 210 | } else {
|
| 211 | return {
|
| 212 | result: false
|
| 213 | };
|
| 214 | }
|
| 215 | }
|
| 216 | }
|
| 217 |
|
| 218 | function getStatusInfo() {
|
| 219 | if (informationAll.isLoggedIn === undefined) {
|
| 220 | var loginStatus = getLoginStatus();
|
| 221 | return {
|
| 222 | networkType: informationAll.networkType,
|
| 223 | signalImg: informationAll.signalImg,
|
| 224 | networkOperator: informationAll.networkOperator,
|
| 225 | spn_b1_flag: informationAll.spn_b1_flag,
|
| 226 | spn_name_data: informationAll.spn_name_data,
|
| 227 | spn_b2_flag: informationAll.spn_b2_flag,
|
| 228 | connectStatus: informationAll.connectStatus,
|
| 229 | rj45ConnectStatus: informationAll.rj45ConnectStatus,
|
| 230 | ssid1AttachedNum: informationAll.ssid1AttachedNum,
|
| 231 | ssid2AttachedNum: informationAll.ssid2AttachedNum,
|
| 232 | wirelessDeviceNum: informationAll.ssid1AttachedNum + informationAll.ssid2AttachedNum,
|
| 233 | roamingStatus: informationAll.roamingStatus,
|
| 234 | wifiStatus: informationAll.wifiStatus,
|
| 235 | simStatus: informationAll.simStatus,
|
| 236 | pinStatus: informationAll.pinStatus,
|
| 237 | batteryStatus: informationAll.batteryStatus,
|
| 238 | batteryLevel: informationAll.batteryLevel,
|
| 239 | batteryPers: informationAll.batteryPers,
|
| 240 | batteryTime: informationAll.batteryTime,
|
| 241 | ssid: informationAll.ssid,
|
| 242 | authMode: informationAll.authMode,
|
| 243 | data_counter: informationAll.data_counter,
|
| 244 | isLoggedIn: loginStatus.status == "loggedIn",
|
| 245 | newSmsReceived: informationAll.newSmsReceived,
|
| 246 | smsReportReceived: informationAll.smsReportReceived,
|
| 247 | smsUnreadCount: informationAll.smsUnreadCount,
|
| 248 | limitVolumeEnable: informationAll.limitVolumeEnable,
|
| 249 | limitVolumeType: informationAll.limitVolumeType,
|
| 250 | limitVolumePercent: informationAll.limitVolumePercent,
|
| 251 | limitVolumeSize: informationAll.limitVolumeSize,
|
| 252 | connectWifiProfile: informationAll.connectWifiProfile,
|
| 253 | connectWifiSSID: informationAll.connectWifiSSID,
|
| 254 | connectWifiStatus: informationAll.connectWifiStatus,
|
| 255 | multi_ssid_enable: informationAll.multi_ssid_enable,
|
| 256 | roamMode: informationAll.roamMode,
|
| 257 | blc_wan_mode: informationAll.blc_wan_mode,
|
| 258 | current_upgrade_state: informationAll.current_upgrade_state,
|
| 259 | is_mandatory: informationAll.is_mandatory,
|
| 260 | new_version_state: informationAll.new_version_state,
|
| 261 | allowRoamingUpdate: informationAll.allowRoamingUpdate,
|
| 262 | ap_station_enable: informationAll.ap_station_enable,
|
| 263 | ap_station_mode: informationAll.ap_station_mode,
|
| 264 | dialMode: informationAll.dialMode,
|
| 265 | fota_package_already_download: informationAll.fota_package_already_download,
|
| 266 | ethWanMode: informationAll.ethWanMode,
|
| 267 | fota_user_selector: informationAll.fota_user_selector,
|
| 268 | defaultWanName: informationAll.defaultWanName
|
| 269 | };
|
| 270 | }
|
| 271 | return {
|
| 272 | networkType: informationAll.networkType,
|
| 273 | signalImg: informationAll.signalImg,
|
| 274 | networkOperator: informationAll.networkOperator,
|
| 275 | spn_b1_flag: informationAll.spn_b1_flag,
|
| 276 | spn_name_data: informationAll.spn_name_data,
|
| 277 | spn_b2_flag: informationAll.spn_b2_flag,
|
| 278 | connectStatus: informationAll.connectStatus,
|
| 279 | rj45ConnectStatus: informationAll.rj45ConnectStatus,
|
| 280 | ssid1AttachedNum: informationAll.ssid1AttachedNum,
|
| 281 | ssid2AttachedNum: informationAll.ssid2AttachedNum,
|
| 282 | wirelessDeviceNum: informationAll.ssid1AttachedNum + informationAll.ssid2AttachedNum,
|
| 283 | roamingStatus: informationAll.roamingStatus,
|
| 284 | wifiStatus: informationAll.wifiStatus,
|
| 285 | simStatus: informationAll.simStatus,
|
| 286 | pinStatus: informationAll.pinStatus,
|
| 287 | batteryStatus: informationAll.batteryStatus,
|
| 288 | batteryLevel: informationAll.batteryLevel,
|
| 289 | batteryPers: informationAll.batteryPers,
|
| 290 | batteryTime: informationAll.batteryTime,
|
| 291 | ssid: informationAll.ssid,
|
| 292 | authMode: informationAll.authMode,
|
| 293 | data_counter: informationAll.data_counter,
|
| 294 | isLoggedIn: informationAll.isLoggedIn,
|
| 295 | newSmsReceived: informationAll.newSmsReceived,
|
| 296 | smsReportReceived: informationAll.smsReportReceived,
|
| 297 | smsUnreadCount: informationAll.smsUnreadCount,
|
| 298 | limitVolumeEnable: informationAll.limitVolumeEnable,
|
| 299 | limitVolumeType: informationAll.limitVolumeType,
|
| 300 | limitVolumePercent: informationAll.limitVolumePercent,
|
| 301 | limitVolumeSize: informationAll.limitVolumeSize,
|
| 302 | connectWifiProfile: informationAll.connectWifiProfile,
|
| 303 | connectWifiSSID: informationAll.connectWifiSSID,
|
| 304 | connectWifiStatus: informationAll.connectWifiStatus,
|
| 305 | multi_ssid_enable: informationAll.multi_ssid_enable,
|
| 306 | blc_wan_mode: informationAll.blc_wan_mode,
|
| 307 | roamMode: informationAll.roamMode,
|
| 308 | current_upgrade_state: informationAll.current_upgrade_state,
|
| 309 | is_mandatory: informationAll.is_mandatory,
|
| 310 | new_version_state: informationAll.new_version_state,
|
| 311 | allowRoamingUpdate: informationAll.allowRoamingUpdate,
|
| 312 | ap_station_enable: informationAll.ap_station_enable,
|
| 313 | ap_station_mode: informationAll.ap_station_mode,
|
| 314 | dialMode: informationAll.dialMode,
|
| 315 | fota_package_already_download: informationAll.fota_package_already_download,
|
| 316 | ethWanMode: informationAll.ethWanMode,
|
| 317 | fota_user_selector: informationAll.fota_user_selector,
|
| 318 | defaultWanName: informationAll.defaultWanName
|
| 319 | };
|
| 320 | }
|
| 321 | function getConnectionInfo() {
|
| 322 | var isData = informationAll.limitVolumeType == '1';
|
| 323 | var result = {
|
| 324 | data_counter: informationAll.data_counter,
|
| 325 | connectStatus: informationAll.connectStatus,
|
| 326 | rj45ConnectStatus: informationAll.rj45ConnectStatus,
|
| 327 | limitVolumeEnable: informationAll.limitVolumeEnable,
|
| 328 | limitVolumeType: informationAll.limitVolumeType,
|
| 329 | limitVolumePercent: informationAll.limitVolumePercent,
|
| 330 | networkType: informationAll.networkType
|
| 331 | };
|
| 332 | if (isData) {
|
| 333 | result.limitDataMonth = informationAll.limitVolumeSize;
|
| 334 | result.limitTimeMonth = 0;
|
| 335 | } else {
|
| 336 | result.limitTimeMonth = informationAll.limitVolumeSize;
|
| 337 | result.limitDataMonth = 0;
|
| 338 | }
|
| 339 | result.blc_wan_mode = informationAll.blc_wan_mode;
|
| 340 | return result;
|
| 341 | }
|
| 342 | function resetNewSmsReceivedVar() {
|
| 343 | informationAll.newSmsReceived = false;
|
| 344 | }
|
| 345 | function resetSmsReportReceivedVar() {
|
| 346 | informationAll.smsReportReceived = false;
|
| 347 | }
|
| 348 | function getSmsCapability() {
|
| 349 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 350 | function prepare(values, isPost) {
|
| 351 | var valueReq = {};
|
| 352 | valueReq.cmd = "sms_capacity_info";
|
| 353 | return valueReq;
|
| 354 | }
|
| 355 | function deal(paramD) {
|
| 356 | return {
|
| 357 | nvTotal: parseInt(paramD.sms_nv_total, 10),
|
| 358 | nvUsed: parseInt(paramD.sms_nv_rev_total, 10) + parseInt(paramD.sms_nv_send_total, 10) + parseInt(paramD.sms_nv_draftbox_total, 10),
|
| 359 | simTotal: parseInt(paramD.sms_sim_total, 10),
|
| 360 | simUsed: parseInt(paramD.sms_sim_rev_total, 10) + parseInt(paramD.sms_sim_send_total, 10) + parseInt(paramD.sms_sim_draftbox_total, 10),
|
| 361 | nvReceive: parseInt(paramD.sms_nv_rev_total, 10),
|
| 362 | nvSend: parseInt(paramD.sms_nv_send_total, 10),
|
| 363 | nvDraft: parseInt(paramD.sms_nv_draftbox_total, 10),
|
| 364 | simReceive: parseInt(paramD.sms_sim_rev_total, 10),
|
| 365 | simSend: parseInt(paramD.sms_sim_send_total, 10),
|
| 366 | simDraft: parseInt(paramD.sms_sim_draftbox_total, 10)
|
| 367 | };
|
| 368 | }
|
| 369 | }
|
| 370 | function connect() {
|
| 371 | var callback = arguments[1];
|
| 372 | var checkPoint = 0;
|
| 373 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 374 | function prepare(values, isPost) {
|
| 375 | var valueReq = {};
|
| 376 | valueReq.notCallback = true;
|
| 377 | valueReq.goformId = "CONNECT_NETWORK";
|
| 378 | return valueReq;
|
| 379 | }
|
| 380 | function deal(paramD) {
|
| 381 | if (paramD.result == "success") {
|
| 382 | checkPoint = new Date().getTime();
|
| 383 | addCallback(checkConnectStatus);
|
| 384 | } else {
|
| 385 | callback({
|
| 386 | result: false
|
| 387 | });
|
| 388 | }
|
| 389 | }
|
| 390 | function checkConnectStatus(paramD) {
|
| 391 | if (paramD.ppp_status == "ppp_connecting") {
|
| 392 | informationAll.connectStatus = "ppp_connecting";
|
| 393 | } else if (paramD.ppp_status == "ppp_connected") {
|
| 394 | removeCallback(checkConnectStatus);
|
| 395 | informationAll.connectStatus = "ppp_connected";
|
| 396 | callback({
|
| 397 | result: true,
|
| 398 | status: informationAll.connectStatus
|
| 399 | });
|
| 400 | } else if (new Date().getTime() - checkPoint < 1e4) {
|
| 401 | informationAll.connectStatus = "ppp_connecting";
|
| 402 | } else {
|
| 403 | removeCallback(checkConnectStatus);
|
| 404 | callback({
|
| 405 | result: false
|
| 406 | });
|
| 407 | }
|
| 408 | }
|
| 409 | }
|
| 410 | function disconnect() {
|
| 411 | var callback = arguments[1];
|
| 412 | var checkPoint = 0;
|
| 413 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 414 | function prepare(values, isPost) {
|
| 415 | var valueReq = {};
|
| 416 | valueReq.notCallback = true;
|
| 417 | valueReq.goformId = "DISCONNECT_NETWORK";
|
| 418 | return valueReq;
|
| 419 | }
|
| 420 | function deal(paramD) {
|
| 421 | if (paramD.result == "success") {
|
| 422 | checkPoint = new Date().getTime();
|
| 423 | addCallback(checkDisconnectStatus);
|
| 424 | } else {
|
| 425 | callback({
|
| 426 | result: false
|
| 427 | });
|
| 428 | }
|
| 429 | }
|
| 430 | function checkDisconnectStatus(paramD) {
|
| 431 | if (paramD.ppp_status == "ppp_disconnecting") {
|
| 432 | informationAll.connectStatus = "ppp_disconnecting";
|
| 433 | } else if (paramD.ppp_status == "ppp_disconnected") {
|
| 434 | removeCallback(checkDisconnectStatus);
|
| 435 | informationAll.connectStatus = "ppp_disconnected";
|
| 436 | callback({
|
| 437 | result: true,
|
| 438 | status: informationAll.connectStatus
|
| 439 | });
|
| 440 | } else if (new Date().getTime() - checkPoint < 1e4) {
|
| 441 | informationAll.connectStatus = "ppp_disconnecting";
|
| 442 | } else {
|
| 443 | removeCallback(checkDisconnectStatus);
|
| 444 | callback({
|
| 445 | result: false
|
| 446 | });
|
| 447 | }
|
| 448 | }
|
| 449 | }
|
| 450 | function getApnSettings() {
|
| 451 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 452 | function prepare(values, isPost) {
|
| 453 | var valueReq = {};
|
| 454 | valueReq.cmd = "APN_configtmp0,APN_configtmp1,APN_configtmp2,APN_configtmp3,APN_configtmp4,APN_configtmp5,APN_configtmp6,APN_configtmp7,APN_configtmp8,APN_configtmp9," + "APN_configtmp10,APN_configtmp11,APN_configtmp12,APN_configtmp13,APN_configtmp14,APN_configtmp15,APN_configtmp16,APN_configtmp17,APN_configtmp18,APN_configtmp19," + "ipv6_APN_configtmp0,ipv6_APN_configtmp1,ipv6_APN_configtmp2,ipv6_APN_configtmp3,ipv6_APN_configtmp4,ipv6_APN_configtmp5,ipv6_APN_configtmp6,ipv6_APN_configtmp7,ipv6_APN_configtmp8,ipv6_APN_configtmp9," + "ipv6_APN_configtmp10,ipv6_APN_configtmp11,ipv6_APN_configtmp12,ipv6_APN_configtmp13,ipv6_APN_configtmp14,ipv6_APN_configtmp15,ipv6_APN_configtmp16,ipv6_APN_configtmp17,ipv6_APN_configtmp18,ipv6_APN_configtmp19," + "m_profile_name,profile_name,wan_dial,pdp_type,pdp_select,index,Current_index,apn_auto_config,ipv6_apn_auto_config," + "apn_mode,wan_apn,ppp_auth_mode,ppp_username,ppp_passtmp," + "ipv6_wan_apn,ipv6_pdp_type,ipv6_ppp_auth_mode,ipv6_ppp_username,ipv6_ppp_passtmp,apn_num_preset";
|
| 455 | valueReq.multi_data = 1;
|
| 456 | return valueReq;
|
| 457 | }
|
| 458 | function deal(result) {
|
| 459 | if (result) {
|
| 460 | return {
|
| 461 | APNs: result.APN_configtmp0 + "||" + result.APN_configtmp1 + "||" + result.APN_configtmp2 + "||" + result.APN_configtmp3 + "||" + result.APN_configtmp4 + "||"
|
| 462 | +result.APN_configtmp5 + "||" + result.APN_configtmp6 + "||" + result.APN_configtmp7 + "||" + result.APN_configtmp8 + "||" + result.APN_configtmp9 + "||"
|
| 463 | +result.APN_configtmp10 + "||" + result.APN_configtmp11 + "||" + result.APN_configtmp12 + "||" + result.APN_configtmp13 + "||" + result.APN_configtmp14 + "||"
|
| 464 | +result.APN_configtmp15 + "||" + result.APN_configtmp16 + "||" + result.APN_configtmp17 + "||" + result.APN_configtmp18 + "||" + result.APN_configtmp19,
|
| 465 | ipv6APNs: result.ipv6_APN_configtmp0 + "||" + result.ipv6_APN_configtmp1 + "||" + result.ipv6_APN_configtmp2 + "||" + result.ipv6_APN_configtmp3 + "||" + result.ipv6_APN_configtmp4 + "||"
|
| 466 | +result.ipv6_APN_configtmp5 + "||" + result.ipv6_APN_configtmp6 + "||" + result.ipv6_APN_configtmp7 + "||" + result.ipv6_APN_configtmp8 + "||" + result.ipv6_APN_configtmp9 + "||"
|
| 467 | +result.ipv6_APN_configtmp10 + "||" + result.ipv6_APN_configtmp11 + "||" + result.ipv6_APN_configtmp12 + "||" + result.ipv6_APN_configtmp13 + "||" + result.ipv6_APN_configtmp14 + "||"
|
| 468 | +result.ipv6_APN_configtmp15 + "||" + result.ipv6_APN_configtmp16 + "||" + result.ipv6_APN_configtmp17 + "||" + result.ipv6_APN_configtmp18 + "||" + result.ipv6_APN_configtmp19,
|
| 469 | apnMode: result.apn_mode,
|
| 470 | profileName: result.m_profile_name || result.profile_name,
|
| 471 | wanDial: result.wan_dial,
|
| 472 | pdpType: result.pdp_type == 'IP' ? 'IP' : result.ipv6_pdp_type,
|
| 473 | pdpSelect: result.pdp_select,
|
| 474 | index: result.index,
|
| 475 | currIndex: result.Current_index,
|
| 476 | autoApns: result.apn_auto_config,
|
| 477 | autoApnsV6: result.ipv6_apn_auto_config,
|
| 478 | wanApn: result.wan_apn,
|
| 479 | authMode: result.ppp_auth_mode.toLowerCase(),
|
| 480 | username: result.ppp_username,
|
| 481 | password: result.ppp_passtmp,
|
| 482 | dnsMode: "",
|
| 483 | dns1: "",
|
| 484 | dns2: "",
|
| 485 | wanApnV6: result.ipv6_wan_apn,
|
| 486 | authModeV6: result.ipv6_ppp_auth_mode.toLowerCase(),
|
| 487 | usernameV6: result.ipv6_ppp_username,
|
| 488 | passwordV6: result.ipv6_ppp_passtmp,
|
| 489 | dnsModeV6: "",
|
| 490 | dns1V6: "",
|
| 491 | dns2V6: "",
|
| 492 | apnNumPreset: result.apn_num_preset
|
| 493 | };
|
| 494 | } else {
|
| 495 | return {
|
| 496 | result: false
|
| 497 | };
|
| 498 | }
|
| 499 | }
|
| 500 | }
|
| 501 | function getNetworkStatus() {
|
| 502 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 503 | function prepare(values, isPost) {
|
| 504 | var valueReq = {};
|
| 505 | valueReq.cmd = "NETWORK_INFO";
|
| 506 | return valueReq;
|
| 507 | }
|
| 508 | function deal(result) {
|
| 509 | return {
|
| 510 | sinr: result.lte_sinr,
|
| 511 | rsrp: result.lte_rsrp,
|
| 512 | rsrq: result.lte_rsrq,
|
| 513 | plmn: result.lte_plmn,
|
| 514 | pci: result.lte_pci,
|
| 515 | cellid: result.lte_cellid,
|
| 516 | band: result.lte_band
|
| 517 | };
|
| 518 | }
|
| 519 | }
|
| 520 | function deleteApn() {
|
| 521 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 522 | function prepare(values, isPost) {
|
| 523 | var valueReq = {
|
| 524 | apn_action: "delete",
|
| 525 | apn_mode: "manual",
|
| 526 | index: values.index
|
| 527 | };
|
| 528 | valueReq.goformId = "APN_PROC_EX";
|
| 529 | return valueReq;
|
| 530 | }
|
| 531 | function deal(paramD) {
|
| 532 | if (paramD.result == "success") {
|
| 533 | return {
|
| 534 | result: true
|
| 535 | };
|
| 536 | } else {
|
| 537 | return {
|
| 538 | result: false
|
| 539 | };
|
| 540 | }
|
| 541 | }
|
| 542 | }
|
| 543 | function setDefaultApn() {
|
| 544 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 545 | function prepare(values, isPost) {
|
| 546 | var requestParam = {
|
| 547 | goformId: "APN_PROC_EX",
|
| 548 | apn_mode: values.apnMode
|
| 549 | };
|
| 550 | if (values.apnMode == 'manual') {
|
| 551 | requestParam.apn_action = "set_default";
|
| 552 | requestParam.set_default_flag = "1";
|
| 553 | requestParam.pdp_type = values.pdpType;
|
| 554 | requestParam.index = values.index;
|
| 555 | }
|
| 556 | return requestParam;
|
| 557 | }
|
| 558 | function deal(paramD) {
|
| 559 | if (paramD.result == "success") {
|
| 560 | return {
|
| 561 | result: true
|
| 562 | };
|
| 563 | } else {
|
| 564 | return {
|
| 565 | result: false
|
| 566 | };
|
| 567 | }
|
| 568 | }
|
| 569 | }
|
| 570 | function addOrEditApn() {
|
| 571 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 572 | function prepare(values, isPost) {
|
| 573 | var valueReq = {
|
| 574 | goformId: "APN_PROC_EX",
|
| 575 | apn_action: "save",
|
| 576 | apn_mode: "manual",
|
| 577 | profile_name: values.profileName,
|
| 578 | wan_dial: '*99#',
|
| 579 | pdp_type: values.pdpType,
|
| 580 | pdp_select: 'auto',
|
| 581 | index: values.index
|
| 582 | };
|
| 583 | if (values.pdpType == "IP") {
|
| 584 | $.extend(valueReq, {
|
| 585 | wan_apn: values.wanApn,
|
| 586 | ppp_auth_mode: values.authMode,
|
| 587 | ppp_username: values.username,
|
| 588 | ppp_passtmp: values.password,
|
| 589 | });
|
| 590 | } else if (values.pdpType == "IPv6") {
|
| 591 | $.extend(valueReq, {
|
| 592 | ipv6_wan_apn: values.wanApnV6,
|
| 593 | ipv6_ppp_auth_mode: values.authModeV6,
|
| 594 | ipv6_ppp_username: values.usernameV6,
|
| 595 | ipv6_ppp_passtmp: values.passwordV6
|
| 596 | });
|
| 597 | } else {
|
| 598 | $.extend(valueReq, {
|
| 599 | wan_apn: values.wanApn,
|
| 600 | ppp_auth_mode: values.authMode,
|
| 601 | ppp_username: values.username,
|
| 602 | ppp_passtmp: values.password,
|
| 603 | dns_mode: values.dnsMode,
|
| 604 | prefer_dns_manual: values.dns1,
|
| 605 | standby_dns_manual: values.dns2,
|
| 606 | ipv6_wan_apn: values.wanApnV6,
|
| 607 | ipv6_ppp_auth_mode: values.authModeV6,
|
| 608 | ipv6_ppp_username: values.usernameV6,
|
| 609 | ipv6_ppp_passtmp: values.passwordV6
|
| 610 | });
|
| 611 | }
|
| 612 | return valueReq;
|
| 613 | }
|
| 614 | function deal(paramD) {
|
| 615 | if (paramD.result == "success") {
|
| 616 | return {
|
| 617 | result: true
|
| 618 | };
|
| 619 | } else {
|
| 620 | return {
|
| 621 | result: false
|
| 622 | };
|
| 623 | }
|
| 624 | }
|
| 625 | }
|
| 626 | var timerQueryString = ["modem_main_state", "pin_status", "blc_wan_mode", "blc_wan_auto_mode", "loginfo", "fota_new_version_state", "fota_current_upgrade_state", "fota_upgrade_selector", "network_provider", "is_mandatory", "sta_count", "m_sta_count"];
|
| 627 | var loginTimerQueryString = ["signalbar", "network_type", "sub_network_type", "ppp_status", "rj45_state", "EX_SSID1", "sta_ip_status", "EX_wifi_profile", "m_ssid_enable", "wifi_cur_state", "SSID1", "simcard_roam", "lan_ipaddr", "battery_charging", "battery_vol_percent", "battery_pers", "spn_name_data", "spn_b1_flag", "spn_b2_flag", "realtime_tx_bytes", "realtime_rx_bytes", "realtime_time", "realtime_tx_thrpt", "realtime_rx_thrpt", "monthly_rx_bytes", "monthly_tx_bytes", "traffic_alined_delta", "monthly_time", "date_month", "data_volume_limit_switch", "data_volume_limit_size", "data_volume_alert_percent", "data_volume_limit_unit", "roam_setting_option", "upg_roam_switch", "fota_package_already_download", 'ssid', 'dial_mode', 'ethwan_mode', 'default_wan_name'];
|
| 628 | if (config.HAS_SMS) {
|
| 629 | $.merge(loginTimerQueryString, ["sms_received_flag", "sts_received_flag", 'sms_unread_num']);
|
| 630 | }
|
| 631 | var timerCallbackStack = [];
|
| 632 | var timerCallbacks = [timerUpdateStatus];
|
| 633 | function timerUpdater() {
|
| 634 | if (!updateTimerFlag) {
|
| 635 | setTimeout(function () {
|
| 636 | timerUpdater();
|
| 637 | }, 1000);
|
| 638 | return;
|
| 639 | }
|
| 640 | var queryParams = checkTimerUpdaterParameters();
|
| 641 | reqAsync(queryParams, function (paramD) {
|
| 642 | for (var i = 0; i < timerCallbacks.length; i++) {
|
| 643 | if (typeof timerCallbacks[i] === "function") {
|
| 644 | timerCallbacks[i](paramD);
|
| 645 | }
|
| 646 | }
|
| 647 | $.merge(timerCallbacks, timerCallbackStack);
|
| 648 | timerCallbackStack = [];
|
| 649 | setTimeout(function () {
|
| 650 | timerUpdater();
|
| 651 | }, 1000);
|
| 652 | }, function () {
|
| 653 | timerUpdaterErrorCallback();
|
| 654 | setTimeout(function () {
|
| 655 | timerUpdater();
|
| 656 | }, 1000);
|
| 657 | }, false);
|
| 658 | }
|
| 659 | function checkTimerUpdaterParameters() {
|
| 660 | var queryParams = {
|
| 661 | multi_data: 1,
|
| 662 | };
|
| 663 | if (window.location.hash && window.location.hash != '#entry' && informationAll.isLoggedIn) {
|
| 664 | if (config.HAS_SMS) {
|
| 665 | queryParams.sms_received_flag_flag = 0;
|
| 666 | queryParams.sts_received_flag_flag = 0;
|
| 667 | }
|
| 668 | if (loginTimerQueryString.length > 0 && _.indexOf(timerQueryString, loginTimerQueryString[0]) == -1) {
|
| 669 | $.each(loginTimerQueryString, function (i, n) {
|
| 670 | timerQueryString.push(n);
|
| 671 | });
|
| 672 | }
|
| 673 | } else {
|
| 674 | if (loginTimerQueryString.length > 0 && _.indexOf(timerQueryString, loginTimerQueryString[0]) != -1) {
|
| 675 | timerQueryString = _.without(timerQueryString, loginTimerQueryString);
|
| 676 | }
|
| 677 | }
|
| 678 | queryParams.cmd = timerQueryString.join(",");
|
| 679 | return queryParams;
|
| 680 | }
|
| 681 | function addCallback(cb) {
|
| 682 | if (_.indexOf(timerCallbackStack, cb) == -1) {
|
| 683 | timerCallbackStack.push(cb);
|
| 684 | }
|
| 685 | }
|
| 686 | function removeCallback(cb) {
|
| 687 | timerCallbacks = _.without(timerCallbacks, cb);
|
| 688 | if (timerCallbacks.length == 0) {
|
| 689 | timerCallbacks.push(timerUpdateStatus);
|
| 690 | }
|
| 691 | return timerCallbackStack;
|
| 692 | }
|
| 693 | function addQueryString(query) {
|
| 694 | if (_.indexOf(timerQueryString, query) == -1) {
|
| 695 | timerQueryString.push(query);
|
| 696 | }
|
| 697 | }
|
| 698 | function removeQueryString(query) {
|
| 699 | timerQueryString = _.without(timerQueryString, query);
|
| 700 | return timerQueryString;
|
| 701 | }
|
| 702 | function timerUpdateStatus(paramD) {
|
| 703 | informationAll.defaultWanName = paramD.default_wan_name;
|
| 704 | informationAll.signalImg = typeof paramD.signalbar == 'undefined' ? '0' : paramD.signalbar;
|
| 705 | informationAll.networkType = paramD.sub_network_type ? paramD.sub_network_type : (paramD.network_type ? paramD.network_type : '');
|
| 706 | if (informationAll.networkType.toLowerCase().indexOf("limited_service") != -1 || informationAll.networkType.toLowerCase().indexOf("limited service") != -1) {
|
| 707 | informationAll.networkType = "limited_service";
|
| 708 | } else if (informationAll.networkType.toLowerCase().indexOf("no_service") != -1 || informationAll.networkType.toLowerCase().indexOf("no service") != -1) {
|
| 709 | informationAll.networkType = "no_service";
|
| 710 | }
|
| 711 | informationAll.networkOperator = paramD.network_provider ? paramD.network_provider : '';
|
| 712 | informationAll.spn_b1_flag = paramD.spn_b1_flag;
|
| 713 | informationAll.spn_b2_flag = paramD.spn_b2_flag;
|
| 714 | informationAll.spn_name_data = paramD.spn_name_data;
|
| 715 | informationAll.connectStatus = typeof paramD.ppp_status == 'undefined' ? 'ppp_disconnected' : paramD.ppp_status;
|
| 716 | informationAll.rj45ConnectStatus = (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state;
|
| 717 | informationAll.ethWanMode = paramD.ethwan_mode;
|
| 718 | informationAll.ssid1AttachedNum = paramD.sta_count == "" ? 0 : parseInt(paramD.sta_count, 10);
|
| 719 | informationAll.ssid2AttachedNum = paramD.m_sta_count == "" ? 0 : parseInt(paramD.m_sta_count, 10);
|
| 720 | informationAll.roamingStatus = getRoamStatus(informationAll.networkType, paramD.modem_main_state, paramD.simcard_roam);
|
| 721 | informationAll.wifiStatus = paramD.wifi_cur_state == "1";
|
| 722 | informationAll.simStatus = paramD.modem_main_state;
|
| 723 | informationAll.pinStatus = paramD.pin_status;
|
| 724 | var needMinutes = 3 * 60 * 60;
|
| 725 | var batteryLevel = (paramD.battery_vol_percent && paramD.battery_vol_percent.length > 0) ? paramD.battery_vol_percent : 100;
|
| 726 | informationAll.batteryPers = paramD.battery_pers;
|
| 727 | var remainMinutes = Math.round(needMinutes * (1 - batteryLevel / 100));
|
| 728 | informationAll.batteryStatus = (typeof paramD.battery_charging == 'undefined') ? '0' : paramD.battery_charging;
|
| 729 | informationAll.batteryLevel = batteryLevel;
|
| 730 | informationAll.batteryTime = remainMinutes.toString();
|
| 731 | informationAll.data_counter = {
|
| 732 | uploadRate: paramD.realtime_tx_thrpt == '' ? 0 : paramD.realtime_tx_thrpt,
|
| 733 | downloadRate: paramD.realtime_rx_thrpt == '' ? 0 : paramD.realtime_rx_thrpt,
|
| 734 | currentSent: paramD.realtime_tx_bytes == '' ? 0 : paramD.realtime_tx_bytes,
|
| 735 | currentReceived: paramD.realtime_rx_bytes == '' ? 0 : paramD.realtime_rx_bytes,
|
| 736 | currentConnectedTime: paramD.realtime_time == '' ? 0 : paramD.realtime_time,
|
| 737 | monthlySent: paramD.monthly_tx_bytes == '' ? 0 : paramD.monthly_tx_bytes,
|
| 738 | monthlyReceived: paramD.monthly_rx_bytes == '' ? 0 : paramD.monthly_rx_bytes,
|
| 739 | traffic_alined_delta: paramD.traffic_alined_delta == '' ? 0 : paramD.traffic_alined_delta,
|
| 740 | monthlyConnectedTime: paramD.monthly_time == '' ? 0 : paramD.monthly_time,
|
| 741 | month: paramD.date_month == '' ? 1 : paramD.date_month
|
| 742 | };
|
| 743 | informationAll.ssid = paramD.SSID1;
|
| 744 | informationAll.authMode = paramD.AuthMode;
|
| 745 | informationAll.isLoggedIn = config.HAS_LOGIN ? paramD.loginfo == "ok" : true;
|
| 746 | if (config.HAS_SMS) {
|
| 747 | if (!informationAll.newSmsReceived) {
|
| 748 | informationAll.newSmsReceived = paramD.sms_received_flag > 0;
|
| 749 | }
|
| 750 | if (!informationAll.smsReportReceived) {
|
| 751 | informationAll.smsReportReceived = paramD.sts_received_flag > 0;
|
| 752 | }
|
| 753 | if (typeof paramD.sms_dev_unread_num != "undefined") {
|
| 754 | informationAll.smsUnreadCount = config.SMS_UNREAD_NUM_INCLUDE_SIM ? parseInt(paramD.sms_dev_unread_num | 0, 10) + parseInt(paramD.sms_sim_unread_num | 0, 10) : parseInt(paramD.sms_dev_unread_num | 0, 10);
|
| 755 | } else {
|
| 756 | informationAll.smsUnreadCount = parseInt(paramD.sms_unread_num | 0, 10)
|
| 757 | }
|
| 758 | }
|
| 759 | if (paramD.data_volume_limit_switch == '1') {
|
| 760 | informationAll.limitVolumeEnable = true;
|
| 761 | informationAll.limitVolumeType = paramD.data_volume_limit_unit == 'data' ? '1' : '0';
|
| 762 | informationAll.limitVolumePercent = paramD.data_volume_alert_percent;
|
| 763 | if (paramD.data_volume_limit_unit == 'data') {
|
| 764 | var limitMonth = paramD.data_volume_limit_size.split("_");
|
| 765 | informationAll.limitVolumeSize = limitMonth[0] * limitMonth[1] * 1024 * 1024;
|
| 766 | } else {
|
| 767 | informationAll.limitVolumeSize = paramD.data_volume_limit_size * 60 * 60;
|
| 768 | }
|
| 769 | } else {
|
| 770 | informationAll.limitVolumeEnable = false;
|
| 771 | informationAll.limitVolumeType = '1';
|
| 772 | informationAll.limitVolumePercent = '100';
|
| 773 | informationAll.limitVolumeSize = '0';
|
| 774 | }
|
| 775 | informationAll.connectWifiProfile = paramD.EX_wifi_profile;
|
| 776 | informationAll.connectWifiSSID = paramD.EX_SSID1;
|
| 777 | informationAll.connectWifiStatus = paramD.sta_ip_status;
|
| 778 | informationAll.multi_ssid_enable = paramD.m_ssid_enable;
|
| 779 | informationAll.roamMode = paramD.roam_setting_option;
|
| 780 | if (paramD.blc_wan_mode == "AUTO") {
|
| 781 | informationAll.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';
|
| 782 | } else {
|
| 783 | informationAll.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';
|
| 784 | }
|
| 785 | informationAll.new_version_state = paramD.fota_new_version_state == "has_critical" || paramD.fota_new_version_state == "has_optional" || paramD.fota_new_version_state == "already_has_pkg";
|
| 786 | informationAll.current_upgrade_state = paramD.fota_current_upgrade_state;
|
| 787 | if (informationAll.current_upgrade_state == "verify_failed") {
|
| 788 | informationAll.current_upgrade_state = "upgrade_pack_error";
|
| 789 | }
|
| 790 | informationAll.fota_user_selector = paramD.fota_upgrade_selector;
|
| 791 | informationAll.is_mandatory = paramD.is_mandatory == "1" || paramD.fota_new_version_state == "has_critical";
|
| 792 | informationAll.allowRoamingUpdate = paramD.upg_roam_switch;
|
| 793 | informationAll.dialMode = paramD.dial_mode;
|
| 794 | informationAll.fota_package_already_download = paramD.fota_package_already_download;
|
| 795 | }
|
| 796 | function timerUpdaterErrorCallback() {
|
| 797 | informationAll.batteryStatus = '0';
|
| 798 | }
|
| 799 | function getRoamStatus(networkType, modemState, simcardRoam) {
|
| 800 | if (("" == $.trim(networkType)) || "no_service" == networkType.toLowerCase() || "limited_service" == networkType.toLowerCase() || "modem_sim_undetected" == modemState || "modem_waitpin" == modemState || "modem_waitpuk" == modemState) {
|
| 801 | return false;
|
| 802 | }
|
| 803 | if ("Internal" == simcardRoam || "International" == simcardRoam) {
|
| 804 | return true;
|
| 805 | } else {
|
| 806 | return false;
|
| 807 | }
|
| 808 | }
|
| 809 | $(document).ready(function () {
|
| 810 | setTimeout(function () {
|
| 811 | timerUpdater();
|
| 812 | }, 0);
|
| 813 | });
|
| 814 | function setNetwork(strNetworkNumber, nRat, nSubAct, callback) {
|
| 815 | if ((typeof(strNetworkNumber) !== "string") || (strNetworkNumber === "") || (typeof(nRat) !== "number") || (isNaN(nRat))) {
|
| 816 | if (typeof(callback) === "function") {
|
| 817 | callback(false);
|
| 818 | return;
|
| 819 | }
|
| 820 | }
|
| 821 | var nRat1 = -1;
|
| 822 | if (nRat === 0) {
|
| 823 | nRat1 = 0;
|
| 824 | } else if (nRat === 2) {
|
| 825 | nRat1 = 2;
|
| 826 | } else if (nRat == 7) {
|
| 827 | nRat1 = 7;
|
| 828 | } else {
|
| 829 | nRat1 = -1;
|
| 830 | }
|
| 831 | if (-1 === nRat1) {
|
| 832 | if (typeof(callback) === "function") {
|
| 833 | callback(false);
|
| 834 | return;
|
| 835 | }
|
| 836 | }
|
| 837 | var SubAct;
|
| 838 | if (nSubAct.toString() == "NaN") {
|
| 839 | SubAct = "";
|
| 840 | } else {
|
| 841 | SubAct = nSubAct;
|
| 842 | }
|
| 843 | reqAsync({
|
| 844 | goformId: "SET_NETWORK",
|
| 845 | NetworkNumber: strNetworkNumber,
|
| 846 | Rat: nRat,
|
| 847 | nSubrat: SubAct
|
| 848 | }, function (paramD) {
|
| 849 | if (paramD && paramD.result == "success") {
|
| 850 | var flag;
|
| 851 | var counter = 0;
|
| 852 | var timer = setInterval(function () {
|
| 853 | var obj = reqSync({
|
| 854 | cmd: 'm_netselect_result',
|
| 855 | }, false);
|
| 856 | if (!obj) {
|
| 857 | callback(false);
|
| 858 | return;
|
| 859 | }
|
| 860 | if (obj.m_netselect_result == "manual_success") {
|
| 861 | flag = "1";
|
| 862 | window.clearInterval(timer);
|
| 863 | callback(true);
|
| 864 | } else if (obj.m_netselect_result == "manual_fail") {
|
| 865 | flag = "0";
|
| 866 | window.clearInterval(timer);
|
| 867 | callback(false);
|
| 868 | } else if (counter < 120) {
|
| 869 | counter++;
|
| 870 | } else {
|
| 871 | window.clearInterval(timer);
|
| 872 | callback(false);
|
| 873 | }
|
| 874 | }, 1000);
|
| 875 | } else {
|
| 876 | callback(false);
|
| 877 | }
|
| 878 | }, function (paramD) {
|
| 879 | callback(false);
|
| 880 | }, true);
|
| 881 | }
|
| 882 | function savePhoneBook() {
|
| 883 | var callback = arguments[1];
|
| 884 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 885 | function prepare(values, isPost) {
|
| 886 | var valueReq = {};
|
| 887 | valueReq.notCallback = true;
|
| 888 | valueReq.goformId = "PBM_CONTACT_ADD";
|
| 889 | valueReq.location = values.location;
|
| 890 | valueReq.name = encodeMessage(values.name);
|
| 891 | valueReq.mobilephone_num = values.mobile_phone_number;
|
| 892 | if (valueReq.location == 1) {
|
| 893 | valueReq.add_index_pc = values.index;
|
| 894 | valueReq.homephone_num = values.home_phone_number;
|
| 895 | valueReq.officephone_num = values.office_phone_number;
|
| 896 | valueReq.email = encodeMessage(values.mail);
|
| 897 | valueReq.groupchoose = values.group;
|
| 898 | if (!valueReq.groupchoose) {
|
| 899 | valueReq.groupchoose = "common";
|
| 900 | }
|
| 901 | } else {
|
| 902 | valueReq.edit_index = values.index;
|
| 903 | }
|
| 904 | if (values.delId != undefined) {
|
| 905 | valueReq.delId = values.delId;
|
| 906 | }
|
| 907 | return valueReq;
|
| 908 | }
|
| 909 | function deal(paramD) {
|
| 910 | if (paramD && paramD.result == "success") {
|
| 911 | addTimerSomething("pbm_write_flag", checkSavePhoneBook);
|
| 912 | } else {
|
| 913 | callback(paramD);
|
| 914 | }
|
| 915 | }
|
| 916 | function checkSavePhoneBook(paramD) {
|
| 917 | checkPbmWriteFlag(paramD, callback, checkSavePhoneBook);
|
| 918 | }
|
| 919 | }
|
| 920 | function checkPbmWriteFlag(paramD, callback, fn) {
|
| 921 | if (paramD.pbm_write_flag == "0") {
|
| 922 | removeTimerSomething("pbm_write_flag", fn);
|
| 923 | callback({
|
| 924 | result: "success"
|
| 925 | });
|
| 926 | } else if (paramD.pbm_write_flag == "6" || paramD.pbm_write_flag == "7" || paramD.pbm_write_flag == "8" || paramD.pbm_write_flag == "9" || paramD.pbm_write_flag == "10" || paramD.pbm_write_flag == "11" || paramD.pbm_write_flag == "14") {
|
| 927 | removeTimerSomething("pbm_write_flag", fn);
|
| 928 | callback({
|
| 929 | result: "fail"
|
| 930 | });
|
| 931 | } else {}
|
| 932 | }
|
| 933 | function deletePhoneBooks() {
|
| 934 | var callback = arguments[1];
|
| 935 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 936 | function prepare(values, isPost) {
|
| 937 | var valueReq = {};
|
| 938 | valueReq.notCallback = true;
|
| 939 | valueReq.goformId = "PBM_CONTACT_DEL";
|
| 940 | valueReq.del_option = "delete_num";
|
| 941 | valueReq.delete_id = values.indexs.join(",");
|
| 942 | return valueReq;
|
| 943 | }
|
| 944 | function deal(paramD) {
|
| 945 | if (paramD && paramD.result == "success") {
|
| 946 | addTimerSomething("pbm_write_flag", checkDeletePhoneBooks);
|
| 947 | } else {
|
| 948 | callback(paramD);
|
| 949 | }
|
| 950 | }
|
| 951 | function checkDeletePhoneBooks(paramD) {
|
| 952 | checkPbmWriteFlag(paramD, callback, checkDeletePhoneBooks);
|
| 953 | }
|
| 954 | }
|
| 955 | function deleteAllPhoneBooks() {
|
| 956 | var callback = arguments[1];
|
| 957 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 958 | function prepare(values, isPost) {
|
| 959 | var valueReq = {};
|
| 960 | valueReq.notCallback = true;
|
| 961 | valueReq.goformId = "PBM_CONTACT_DEL";
|
| 962 | valueReq.del_option = "delete_all";
|
| 963 | valueReq.del_all_location = values.location;
|
| 964 | return valueReq;
|
| 965 | }
|
| 966 | function deal(paramD) {
|
| 967 | if (paramD && paramD.result == "success") {
|
| 968 | addTimerSomething("pbm_write_flag", checkDeleteAllPhoneBooks);
|
| 969 | } else {
|
| 970 | callback(paramD);
|
| 971 | }
|
| 972 | }
|
| 973 | function checkDeleteAllPhoneBooks(paramD) {
|
| 974 | checkPbmWriteFlag(paramD, callback, checkDeleteAllPhoneBooks);
|
| 975 | }
|
| 976 | }
|
| 977 | function deleteAllPhoneBooksByGroup() {
|
| 978 | var callback = arguments[1];
|
| 979 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 980 | function prepare(values, isPost) {
|
| 981 | var valueReq = {};
|
| 982 | valueReq.notCallback = true;
|
| 983 | valueReq.goformId = "PBM_CONTACT_DEL";
|
| 984 | valueReq.del_option = "delete_all_by_group";
|
| 985 | valueReq.del_all_location = 3;
|
| 986 | valueReq.del_group = values.group;
|
| 987 | return valueReq;
|
| 988 | }
|
| 989 | function deal(paramD) {
|
| 990 | if (paramD && paramD.result == "success") {
|
| 991 | addTimerSomething("pbm_write_flag", checkDeleteAllPhoneBooksByGroup);
|
| 992 | } else {
|
| 993 | callback(paramD);
|
| 994 | }
|
| 995 | }
|
| 996 | function checkDeleteAllPhoneBooksByGroup(paramD) {
|
| 997 | checkPbmWriteFlag(paramD, callback, checkDeleteAllPhoneBooksByGroup);
|
| 998 | }
|
| 999 | }
|
| 1000 | function setConnectionMode() {
|
| 1001 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1002 | function prepare(values, isPost) {
|
| 1003 | var valueReq = {};
|
| 1004 | valueReq.goformId = "SET_CONNECTION_MODE";
|
| 1005 | valueReq.ConnectionMode = values.connectionMode;
|
| 1006 | valueReq.roam_setting_option = values.isAllowedRoaming;
|
| 1007 | return valueReq;
|
| 1008 | }
|
| 1009 | function deal(paramD) {
|
| 1010 | if (paramD) {
|
| 1011 | return paramD;
|
| 1012 | } else {
|
| 1013 | callback(paramD);
|
| 1014 | }
|
| 1015 | }
|
| 1016 | }
|
| 1017 | function getConnectionMode() {
|
| 1018 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1019 | function prepare(values, isPost) {
|
| 1020 | var valueReq = {};
|
| 1021 | valueReq.cmd = "ConnectionMode";
|
| 1022 | return valueReq;
|
| 1023 | }
|
| 1024 | function deal(paramD) {
|
| 1025 | if (paramD) {
|
| 1026 | var result = {};
|
| 1027 | result.connectionMode = paramD.connectionMode;
|
| 1028 | result.isAllowedRoaming = paramD.autoConnectWhenRoaming;
|
| 1029 | return result;
|
| 1030 | } else {
|
| 1031 | return errUnknownObj;
|
| 1032 | }
|
| 1033 | }
|
| 1034 | }
|
| 1035 | function _getPhoneBooks(array, location) {
|
| 1036 | if (array[0].data_per_page == 0) {
|
| 1037 | return {
|
| 1038 | "pbm_data": []
|
| 1039 | };
|
| 1040 | }
|
| 1041 | return stuffMake(array, {}, prepare, deal, null, false);
|
| 1042 | function prepare(values, isPost) {
|
| 1043 | var valueReq = {};
|
| 1044 | valueReq.mem_store = location;
|
| 1045 | if (location == 2) {
|
| 1046 | valueReq.cmd = "pbm_data_total";
|
| 1047 | } else {
|
| 1048 | valueReq.cmd = "pbm_data_info";
|
| 1049 | }
|
| 1050 | valueReq.page = values.page;
|
| 1051 | valueReq.data_per_page = values.data_per_page;
|
| 1052 | valueReq.orderBy = values.orderBy;
|
| 1053 | valueReq.isAsc = values.isAsc;
|
| 1054 | return valueReq;
|
| 1055 | }
|
| 1056 | function deal(paramD) {
|
| 1057 | if (paramD && paramD.pbm_data) {
|
| 1058 | var books = [];
|
| 1059 | $.each(paramD.pbm_data, function (i) {
|
| 1060 | books.push({
|
| 1061 | pbm_id: paramD.pbm_data[i].pbm_id,
|
| 1062 | pbm_location: paramD.pbm_data[i].pbm_location,
|
| 1063 | pbm_number: paramD.pbm_data[i].pbm_number,
|
| 1064 | pbm_anr: paramD.pbm_data[i].pbm_anr,
|
| 1065 | pbm_anr1: paramD.pbm_data[i].pbm_anr1,
|
| 1066 | pbm_group: paramD.pbm_data[i].pbm_group,
|
| 1067 | pbm_name: decodeMessage(paramD.pbm_data[i].pbm_name),
|
| 1068 | pbm_email: decodeMessage(paramD.pbm_data[i].pbm_email)
|
| 1069 | });
|
| 1070 | });
|
| 1071 | return {
|
| 1072 | pbm_data: books
|
| 1073 | };
|
| 1074 | } else {
|
| 1075 | return errUnknownObj;
|
| 1076 | }
|
| 1077 | }
|
| 1078 | }
|
| 1079 | function getPhoneBooksByGroup() {
|
| 1080 | if (arguments[0].data_per_page == 0) {
|
| 1081 | return {
|
| 1082 | "pbm_data": []
|
| 1083 | };
|
| 1084 | }
|
| 1085 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1086 | function prepare(values, isPost) {
|
| 1087 | var valueReq = {};
|
| 1088 | valueReq.cmd = "pbm_data_total";
|
| 1089 | valueReq.mem_store = 3;
|
| 1090 | valueReq.pbm_group = values.group;
|
| 1091 | valueReq.page = values.page;
|
| 1092 | valueReq.data_per_page = values.data_per_page;
|
| 1093 | valueReq.orderBy = values.orderBy;
|
| 1094 | valueReq.isAsc = values.isAsc;
|
| 1095 | return valueReq;
|
| 1096 | }
|
| 1097 | function deal(paramD) {
|
| 1098 | if (paramD && paramD.pbm_data) {
|
| 1099 | var books = [];
|
| 1100 | $.each(paramD.pbm_data, function (i) {
|
| 1101 | books.push({
|
| 1102 | pbm_id: paramD.pbm_data[i].pbm_id,
|
| 1103 | pbm_location: paramD.pbm_data[i].pbm_location,
|
| 1104 | pbm_number: paramD.pbm_data[i].pbm_number,
|
| 1105 | pbm_anr: paramD.pbm_data[i].pbm_anr,
|
| 1106 | pbm_anr1: paramD.pbm_data[i].pbm_anr1,
|
| 1107 | pbm_group: paramD.pbm_data[i].pbm_group,
|
| 1108 | pbm_name: decodeMessage(paramD.pbm_data[i].pbm_name),
|
| 1109 | pbm_email: decodeMessage(paramD.pbm_data[i].pbm_email)
|
| 1110 | });
|
| 1111 | });
|
| 1112 | return {
|
| 1113 | pbm_data: books
|
| 1114 | };
|
| 1115 | } else {
|
| 1116 | return errUnknownObj;
|
| 1117 | }
|
| 1118 | }
|
| 1119 | }
|
| 1120 | function getDevicePhoneBooks() {
|
| 1121 | return _getPhoneBooks(arguments, 1);
|
| 1122 | }
|
| 1123 | function getSIMPhoneBooks() {
|
| 1124 | return _getPhoneBooks(arguments, 0);
|
| 1125 | }
|
| 1126 | function getPhoneBooks() {
|
| 1127 | return _getPhoneBooks(arguments, 2);
|
| 1128 | }
|
| 1129 | function getPhoneBookReady() {
|
| 1130 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1131 | function prepare(values, isPost) {
|
| 1132 | var valueReq = {};
|
| 1133 | valueReq.cmd = "pbm_init_flag";
|
| 1134 | return valueReq;
|
| 1135 | }
|
| 1136 | function deal(paramD) {
|
| 1137 | if (paramD) {
|
| 1138 | return paramD;
|
| 1139 | } else {
|
| 1140 | return errUnknownObj;
|
| 1141 | }
|
| 1142 | }
|
| 1143 | }
|
| 1144 | function getPhoneBookCapacity(array, isSIM) {
|
| 1145 | return stuffMake(array, {}, prepare, deal, null, false);
|
| 1146 | function prepare(values, isPost) {
|
| 1147 | var valueReq = {};
|
| 1148 | valueReq.cmd = "pbm_capacity_info";
|
| 1149 | if (isSIM) {
|
| 1150 | valueReq.pbm_location = "pbm_sim";
|
| 1151 | } else {
|
| 1152 | valueReq.pbm_location = "pbm_native";
|
| 1153 | }
|
| 1154 | return valueReq;
|
| 1155 | }
|
| 1156 | function deal(paramD) {
|
| 1157 | if (paramD) {
|
| 1158 | return paramD;
|
| 1159 | } else {
|
| 1160 | return errUnknownObj;
|
| 1161 | }
|
| 1162 | }
|
| 1163 | }
|
| 1164 | function getSIMPhoneBookCapacity() {
|
| 1165 | var paramD = getPhoneBookCapacity(arguments, true);
|
| 1166 | return {
|
| 1167 | simPbmTotalCapacity: parseInt(paramD.pbm_sim_max_record_num),
|
| 1168 | simPbmUsedCapacity: parseInt(paramD.pbm_sim_used_record_num),
|
| 1169 | simType: paramD.pbm_sim_type,
|
| 1170 | maxNameLen: parseInt(paramD.pbm_sim_max_name_len),
|
| 1171 | maxNumberLen: parseInt(paramD.pbm_sim_max_number_len) > 40 ? 40 : parseInt(paramD.pbm_sim_max_number_len)
|
| 1172 | };
|
| 1173 | }
|
| 1174 | function getDevicePhoneBookCapacity() {
|
| 1175 | var paramD = getPhoneBookCapacity(arguments, false);
|
| 1176 | return {
|
| 1177 | pcPbmTotalCapacity: parseInt(paramD.pbm_dev_max_record_num),
|
| 1178 | pcPbmUsedCapacity: parseInt(paramD.pbm_dev_used_record_num)
|
| 1179 | };
|
| 1180 | }
|
| 1181 | function getAttachedCableDevices() {
|
| 1182 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1183 | function prepare(values, isPost) {
|
| 1184 | var obj = {
|
| 1185 | cmd: "lan_station_list"
|
| 1186 | };
|
| 1187 | return obj;
|
| 1188 | }
|
| 1189 | function deal(paramD) {
|
| 1190 | var deviceArr = [];
|
| 1191 | var attachedDevices = paramD.lan_station_list || paramD.station_list;
|
| 1192 | for (var i = 0; attachedDevices && i < attachedDevices.length; i++) {
|
| 1193 | var obj = {};
|
| 1194 | obj.macAddress = attachedDevices[i].mac_addr;
|
| 1195 | var hostname = attachedDevices[i].hostname;
|
| 1196 | obj.hostName = hostname == "" ? $.i18n.prop("unknown") : hostname;
|
| 1197 | obj.ipAddress = attachedDevices[i].ip_addr;
|
| 1198 | deviceArr.push(obj);
|
| 1199 | }
|
| 1200 | return {
|
| 1201 | attachedDevices: deviceArr
|
| 1202 | };
|
| 1203 | }
|
| 1204 | }
|
| 1205 | function getCurrentlyAttachedDevicesInfo() {
|
| 1206 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1207 | function prepare(values, isPost) {
|
| 1208 | var obj = {
|
| 1209 | cmd: "station_list"
|
| 1210 | };
|
| 1211 | return obj;
|
| 1212 | }
|
| 1213 | function deal(paramD) {
|
| 1214 | var deviceArr = [];
|
| 1215 | var attachedDevices = paramD.station_list;
|
| 1216 | for (var i = 0; attachedDevices && i < attachedDevices.length; i++) {
|
| 1217 | var obj = {};
|
| 1218 | obj.macAddress = attachedDevices[i].mac_addr;
|
| 1219 | var hostname = attachedDevices[i].hostname;
|
| 1220 | obj.hostName = hostname == "" ? $.i18n.prop("unknown") : hostname;
|
| 1221 | obj.ipAddress = attachedDevices[i].ip_addr;
|
| 1222 | deviceArr.push(obj);
|
| 1223 | }
|
| 1224 | return {
|
| 1225 | attachedDevices: deviceArr
|
| 1226 | };
|
| 1227 | }
|
| 1228 | }
|
| 1229 |
|
| 1230 | function setLanguage() {
|
| 1231 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1232 | function prepare(values, isPost) {
|
| 1233 | var valueReq = {};
|
| 1234 | valueReq.goformId = "SET_WEB_LANGUAGE";
|
| 1235 | valueReq.Language = values.Language;
|
| 1236 | return valueReq;
|
| 1237 | }
|
| 1238 | function deal(paramD) {
|
| 1239 | if (paramD) {
|
| 1240 | return paramD;
|
| 1241 | } else {
|
| 1242 | return errUnknownObj;
|
| 1243 | }
|
| 1244 | }
|
| 1245 | }
|
| 1246 | function getLanguage() {
|
| 1247 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1248 | function prepare(values, isPost) {
|
| 1249 | var valueReq = {};
|
| 1250 | valueReq.cmd = "Language";
|
| 1251 | valueReq.multi_data = 1;
|
| 1252 | return valueReq;
|
| 1253 | }
|
| 1254 | function deal(paramD) {
|
| 1255 | if (paramD) {
|
| 1256 | var result = {};
|
| 1257 | result.Language = (paramD && paramD.Language) ? paramD.Language : "en";
|
| 1258 | return result;
|
| 1259 | } else {
|
| 1260 | return errUnknownObj;
|
| 1261 | }
|
| 1262 | }
|
| 1263 | }
|
| 1264 |
|
| 1265 | function setBearerPreference() {
|
| 1266 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1267 | function prepare(values, isPost) {
|
| 1268 | var valueReq = {};
|
| 1269 | valueReq.goformId = "SET_BEARER_PREFERENCE";
|
| 1270 | valueReq.BearerPreference = values.strBearerPreference;
|
| 1271 | return valueReq;
|
| 1272 | }
|
| 1273 | function deal(paramD) {
|
| 1274 | if (paramD) {
|
| 1275 | return paramD;
|
| 1276 | } else {
|
| 1277 | return errUnknownObj;
|
| 1278 | }
|
| 1279 | }
|
| 1280 | }
|
| 1281 | function scanForNetwork(callback) {
|
| 1282 | $.post("/reqproc/proc_post", {
|
| 1283 | goformId: "SCAN_NETWORK"
|
| 1284 | }, function (paramD) {
|
| 1285 | if (paramD.result == "success") {
|
| 1286 | checkScanStatus();
|
| 1287 | } else {
|
| 1288 | callback(false, []);
|
| 1289 | }
|
| 1290 | }, "json").error(function () {
|
| 1291 | callback(false, []);
|
| 1292 | });
|
| 1293 | function checkScanStatus() {
|
| 1294 | $.getJSON("/reqproc/proc_get", {
|
| 1295 | cmd: "m_netselect_status",
|
| 1296 | "_": new Date().getTime()
|
| 1297 | }, function (paramD) {
|
| 1298 | if (paramD.m_netselect_status == "manual_selecting") {
|
| 1299 | setTimeout(checkScanStatus, 1000);
|
| 1300 | } else {
|
| 1301 | $.getJSON("/reqproc/proc_get", {
|
| 1302 | cmd: "m_netselect_contents",
|
| 1303 | "_": new Date().getTime()
|
| 1304 | }, function (paramD2) {
|
| 1305 | if (trim(paramD2.m_netselect_contents) != "") {
|
| 1306 | parseScanResult(paramD2.m_netselect_contents);
|
| 1307 | } else {
|
| 1308 | callback(false, []);
|
| 1309 | }
|
| 1310 | }).error(function () {
|
| 1311 | callback(false, []);
|
| 1312 | });
|
| 1313 | }
|
| 1314 | }).error(function () {
|
| 1315 | callback(false, []);
|
| 1316 | });
|
| 1317 | }
|
| 1318 | function parseScanResult(result) {
|
| 1319 | var pattern = /([^,;]*),([^,]*),([^,]*),([^,]*),([^,;]*)/g;
|
| 1320 | var listNetwork = [];
|
| 1321 | var mts;
|
| 1322 | var unit = result.split(";");
|
| 1323 | var unitString = "";
|
| 1324 | for (i = 0; i < unit.length; i++) {
|
| 1325 | var unitLength = unit[i].split(",").length;
|
| 1326 | if (unitLength == 4) {
|
| 1327 | unitString += unit[i] + ",NON;";
|
| 1328 | } else {
|
| 1329 | unitString += unit[i] + ";";
|
| 1330 | }
|
| 1331 | }
|
| 1332 | while (mts = pattern.exec(unitString)) {
|
| 1333 | if (mts != null) {
|
| 1334 | listNetwork.push({
|
| 1335 | strShortName: mts[2].replace(/\"/g, ''),
|
| 1336 | strNumeric: mts[3].replace(/\D/g, ''),
|
| 1337 | nRat: parseInt(mts[4], 10),
|
| 1338 | nState: parseInt(mts[1], 10),
|
| 1339 | SubAct: parseInt(mts[5], 10)
|
| 1340 | });
|
| 1341 | }
|
| 1342 | }
|
| 1343 | callback(true, listNetwork);
|
| 1344 | }
|
| 1345 | }
|
| 1346 | function getNetSelectInfo() {
|
| 1347 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1348 | function prepare(values, isPost) {
|
| 1349 | var valueReq = {};
|
| 1350 | valueReq.cmd = "current_network_mode,m_netselect_save,net_select_mode,m_netselect_contents,net_select,ppp_status,modem_main_state";
|
| 1351 | valueReq.multi_data = 1;
|
| 1352 | return valueReq;
|
| 1353 | }
|
| 1354 | function deal(paramD) {
|
| 1355 | if (paramD) {
|
| 1356 | var result = {};
|
| 1357 | result.current_network_mode = paramD.current_network_mode;
|
| 1358 | result.net_select_mode = paramD.net_select_mode;
|
| 1359 | result.m_netselect_save = paramD.m_netselect_save;
|
| 1360 | result.m_netselect_contents = paramD.m_netselect_contents;
|
| 1361 | result.net_select = paramD.net_select;
|
| 1362 | result.ppp_status = paramD.ppp_status;
|
| 1363 | result.modem_main_state = paramD.modem_main_state;
|
| 1364 | return result;
|
| 1365 | } else {
|
| 1366 | return errUnknownObj;
|
| 1367 | }
|
| 1368 | }
|
| 1369 | }
|
| 1370 |
|
| 1371 | function getSMSMessages() {
|
| 1372 | return stuffMake(arguments, {}, prepare, deal, {}, false);
|
| 1373 | function prepare(values, isPost) {
|
| 1374 | var obj = {
|
| 1375 | cmd: "sms_data_total",
|
| 1376 | page: values.page,
|
| 1377 | data_per_page: config.SMS_DATABASE_SORT_SUPPORT ? values.smsCount : 500,
|
| 1378 | mem_store: values.nMessageStoreType,
|
| 1379 | tags: values.tags,
|
| 1380 | order_by: values.orderBy
|
| 1381 | };
|
| 1382 | return obj;
|
| 1383 | }
|
| 1384 | function deal(paramD) {
|
| 1385 | if (paramD && paramD.messages && paramD.messages.length > 0) {
|
| 1386 | return {
|
| 1387 | messages: parseMessages(paramD.messages)
|
| 1388 | };
|
| 1389 | } else {
|
| 1390 | return {
|
| 1391 | messages: []
|
| 1392 | };
|
| 1393 | }
|
| 1394 | }
|
| 1395 | }
|
| 1396 | function parseMessages(messages, isReport) {
|
| 1397 | var result = [];
|
| 1398 | for (var i = 0; i < messages.length; i++) {
|
| 1399 | if (!config.SHOW_UN_COMPLETE_CONCAT_SMS && typeof messages[i].received_all_concat_sms != "undefined" && messages[i].received_all_concat_sms == '0') {
|
| 1400 | continue;
|
| 1401 | }
|
| 1402 | var oneMessage = {};
|
| 1403 | oneMessage.id = messages[i].id;
|
| 1404 | oneMessage.number = messages[i].number;
|
| 1405 | oneMessage.content = isReport ? messages[i].content : decodeMessageContent(messages[i].content);
|
| 1406 | oneMessage.time = transTime('20' + messages[i].date);
|
| 1407 | oneMessage.isNew = messages[i].tag == "1";
|
| 1408 | oneMessage.groupId = messages[i].draft_group_id;
|
| 1409 | oneMessage.tag = messages[i].tag;
|
| 1410 | oneMessage.receivedAll = messages[i].received_all_concat_sms == '1';
|
| 1411 | result.push(oneMessage);
|
| 1412 | }
|
| 1413 | if (!config.SMS_DATABASE_SORT_SUPPORT) {
|
| 1414 | var ids = [];
|
| 1415 | var tmpResult = [];
|
| 1416 | for (var i = result.length; i--; ) {
|
| 1417 | var n = result[i];
|
| 1418 | var idx = $.inArray(n.id, ids);
|
| 1419 | if (idx == -1) {
|
| 1420 | ids.push(n.id);
|
| 1421 | tmpResult.push(n);
|
| 1422 | } else {
|
| 1423 | if (n.content.length > tmpResult[idx].content.length) {
|
| 1424 | tmpResult[idx] = n;
|
| 1425 | }
|
| 1426 | }
|
| 1427 | }
|
| 1428 | return _.sortBy(tmpResult, function (n) {
|
| 1429 | return 0 - n.id;
|
| 1430 | });
|
| 1431 | } else {
|
| 1432 | return result;
|
| 1433 | }
|
| 1434 | }
|
| 1435 | function decodeMessageContent(msgContent) {
|
| 1436 | return decodeMessage(escapeMessage(msgContent));
|
| 1437 | }
|
| 1438 | function sendSMS() {
|
| 1439 | var callback = arguments[1];
|
| 1440 | var errorCabllback = arguments[2] ? arguments[2] : callback;
|
| 1441 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1442 | function prepare(values, isPost) {
|
| 1443 | var obj = {
|
| 1444 | goformId: "SEND_SMS",
|
| 1445 | notCallback: true,
|
| 1446 | Number: values.number,
|
| 1447 | sms_time: getCurrentTimeString(),
|
| 1448 | MessageBody: escapeMessage(encodeMessage(values.message)),
|
| 1449 | ID: values.id,
|
| 1450 | encode_type: getEncodeType(values.message).encodeType
|
| 1451 | };
|
| 1452 | return obj;
|
| 1453 | }
|
| 1454 | function deal(paramD) {
|
| 1455 | if (!paramD) {
|
| 1456 | errorCabllback($.extend(errUnknownObj, {
|
| 1457 | errorType: "sendFail",
|
| 1458 | errorText: "send_fail_try_again"
|
| 1459 | }));
|
| 1460 | return;
|
| 1461 | }
|
| 1462 | if (paramD.result == "success") {
|
| 1463 | setTimeout(function () {
|
| 1464 | getSmsStatusInfo({
|
| 1465 | smsCmd: 4,
|
| 1466 | errorType: "sendFail",
|
| 1467 | errorText: "send_fail_try_again"
|
| 1468 | }, callback, errorCabllback);
|
| 1469 | }, 1000);
|
| 1470 | } else {
|
| 1471 | errorCabllback($.extend(errUnknownObj, {
|
| 1472 | errorType: "sendFail",
|
| 1473 | errorText: "send_fail_try_again"
|
| 1474 | }));
|
| 1475 | }
|
| 1476 | }
|
| 1477 | }
|
| 1478 | function saveSMS() {
|
| 1479 | var callback = arguments[1];
|
| 1480 | var errorCabllback = arguments[2] ? arguments[2] : callback;
|
| 1481 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1482 | function prepare(values, isPost) {
|
| 1483 | var obj = {
|
| 1484 | notCallback: true,
|
| 1485 | goformId: "SAVE_SMS",
|
| 1486 | SMSMessage: escapeMessage(encodeMessage(values.message)),
|
| 1487 | SMSNumber: values.numbers.join(";") + ";",
|
| 1488 | Index: values.index,
|
| 1489 | encode_type: getEncodeType(values.message).encodeType,
|
| 1490 | sms_time: values.currentTimeString,
|
| 1491 | draft_group_id: values.groupId
|
| 1492 | };
|
| 1493 | return obj;
|
| 1494 | }
|
| 1495 | function deal(paramD) {
|
| 1496 | if (!paramD) {
|
| 1497 | errorCabllback($.extend(errUnknownObj, {
|
| 1498 | errorType: "saveFail",
|
| 1499 | errorText: "save_fail"
|
| 1500 | }));
|
| 1501 | return;
|
| 1502 | }
|
| 1503 | if (paramD.result == "success") {
|
| 1504 | getSmsStatusInfo({
|
| 1505 | smsCmd: 5,
|
| 1506 | errorType: "saveFail",
|
| 1507 | errorText: "save_fail"
|
| 1508 | }, callback, errorCabllback);
|
| 1509 | } else {
|
| 1510 | errorCabllback($.extend(errUnknownObj, {
|
| 1511 | errorType: "saveFail",
|
| 1512 | errorText: "save_fail"
|
| 1513 | }));
|
| 1514 | }
|
| 1515 | }
|
| 1516 | }
|
| 1517 | function deleteAllMessages() {
|
| 1518 | var callback = arguments[1];
|
| 1519 | var errorCabllback = arguments[2] ? arguments[2] : callback;
|
| 1520 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1521 | function prepare(values, isPost) {
|
| 1522 | var obj = {
|
| 1523 | goformId: "ALL_DELETE_SMS",
|
| 1524 | notCallback: true,
|
| 1525 | which_cgi: values.location
|
| 1526 | };
|
| 1527 | return obj;
|
| 1528 | }
|
| 1529 | function deal(paramD) {
|
| 1530 | if (!paramD) {
|
| 1531 | errorCabllback($.extend(errUnknownObj, {
|
| 1532 | errorType: "deleteFail",
|
| 1533 | errorText: "delete_fail_try_again"
|
| 1534 | }));
|
| 1535 | return;
|
| 1536 | }
|
| 1537 | if (paramD.result == "success") {
|
| 1538 | addTimerSomething("sms_cmd_status_info", checkDeleteStatus);
|
| 1539 | } else {
|
| 1540 | errorCabllback($.extend(errUnknownObj, {
|
| 1541 | errorType: "deleteFail",
|
| 1542 | errorText: "delete_fail_try_again"
|
| 1543 | }));
|
| 1544 | }
|
| 1545 | }
|
| 1546 | function checkDeleteStatus(paramD) {
|
| 1547 | var status = paramD.sms_cmd_status_info;
|
| 1548 | if (status == "2") {
|
| 1549 | removeTimerSomething("sms_cmd_status_info", checkDeleteStatus);
|
| 1550 | errorCabllback($.extend(errUnknownObj, {
|
| 1551 | errorType: "deleteFail",
|
| 1552 | errorText: "delete_fail_try_again"
|
| 1553 | }));
|
| 1554 | } else if (status == "3") {
|
| 1555 | removeTimerSomething("sms_cmd_status_info", checkDeleteStatus);
|
| 1556 | callback({
|
| 1557 | result: true
|
| 1558 | });
|
| 1559 | }
|
| 1560 | }
|
| 1561 | }
|
| 1562 | function deleteMessage() {
|
| 1563 | var callback = arguments[1];
|
| 1564 | var errorCabllback = arguments[2] ? arguments[2] : callback;
|
| 1565 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1566 | function prepare(values, isPost) {
|
| 1567 | var msgIds = values.ids.join(";") + ";";
|
| 1568 | var obj = {
|
| 1569 | goformId: "DELETE_SMS",
|
| 1570 | msg_id: msgIds,
|
| 1571 | notCallback: true
|
| 1572 | };
|
| 1573 | return obj;
|
| 1574 | }
|
| 1575 | function deal(paramD) {
|
| 1576 | if (!paramD) {
|
| 1577 | errorCabllback($.extend(errUnknownObj, {
|
| 1578 | errorType: "deleteFail",
|
| 1579 | errorText: "delete_fail_try_again"
|
| 1580 | }));
|
| 1581 | return;
|
| 1582 | }
|
| 1583 | if (paramD.result == "success") {
|
| 1584 | getSmsStatusInfo({
|
| 1585 | smsCmd: 6,
|
| 1586 | errorType: "deleteFail",
|
| 1587 | errorText: "delete_fail_try_again"
|
| 1588 | }, callback, errorCabllback);
|
| 1589 | } else {
|
| 1590 | errorCabllback($.extend(errUnknownObj, {
|
| 1591 | errorType: "deleteFail",
|
| 1592 | errorText: "delete_fail_try_again"
|
| 1593 | }));
|
| 1594 | }
|
| 1595 | }
|
| 1596 | }
|
| 1597 | function getSmsStatusInfo(obj, callback, errorCabllback) {
|
| 1598 | reqAsync({
|
| 1599 | cmd: "sms_cmd_status_info",
|
| 1600 | sms_cmd: obj.smsCmd,
|
| 1601 | }, function (paramD) {
|
| 1602 | if (paramD) {
|
| 1603 | var status = paramD.sms_cmd_status_result;
|
| 1604 | if (status == "2") {
|
| 1605 | errorCabllback($.extend(errUnknownObj, {
|
| 1606 | errorType: obj.errorType,
|
| 1607 | errorText: obj.errorText
|
| 1608 | }));
|
| 1609 | } else if (status == "3") {
|
| 1610 | callback({
|
| 1611 | result: "success"
|
| 1612 | });
|
| 1613 | } else {
|
| 1614 | window.setTimeout(function () {
|
| 1615 | getSmsStatusInfo(obj, callback, errorCabllback);
|
| 1616 | }, 1000);
|
| 1617 | }
|
| 1618 | } else {
|
| 1619 | errorCabllback($.extend(errUnknownObj, {
|
| 1620 | errorType: obj.errorType,
|
| 1621 | errorText: obj.errorText
|
| 1622 | }));
|
| 1623 | }
|
| 1624 | }, function (paramD) {
|
| 1625 | errorCabllback($.extend(errUnknownObj, {
|
| 1626 | errorType: obj.errorType,
|
| 1627 | errorText: obj.errorText
|
| 1628 | }));
|
| 1629 | }, false);
|
| 1630 | }
|
| 1631 | function getSMSReady() {
|
| 1632 | if (config.smsIsReady) {
|
| 1633 | var callback = arguments[1];
|
| 1634 | if (callback) {
|
| 1635 | return callback({
|
| 1636 | "sms_cmd": "1",
|
| 1637 | "sms_cmd_status_result": "3"
|
| 1638 | });
|
| 1639 | } else {
|
| 1640 | return {
|
| 1641 | "sms_cmd": "1",
|
| 1642 | "sms_cmd_status_result": "3"
|
| 1643 | };
|
| 1644 | }
|
| 1645 | } else {
|
| 1646 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1647 | }
|
| 1648 | function prepare(values, isPost) {
|
| 1649 | var valueReq = {};
|
| 1650 | valueReq.cmd = "sms_cmd_status_info";
|
| 1651 | valueReq.sms_cmd = 1;
|
| 1652 | return valueReq;
|
| 1653 | }
|
| 1654 | function deal(paramD) {
|
| 1655 | if (paramD) {
|
| 1656 | if (paramD.sms_cmd_status_result == "3") {
|
| 1657 | config.smsIsReady = true;
|
| 1658 | }
|
| 1659 | return paramD;
|
| 1660 | } else {
|
| 1661 | return errUnknownObj;
|
| 1662 | }
|
| 1663 | }
|
| 1664 | }
|
| 1665 | function setSmsRead() {
|
| 1666 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1667 | function prepare(values, isPost) {
|
| 1668 | var msgIds = values.ids.join(";");
|
| 1669 | if (values.ids.length > 0) {
|
| 1670 | msgIds += ";";
|
| 1671 | }
|
| 1672 | var obj = {
|
| 1673 | goformId: "SET_MSG_READ",
|
| 1674 | msg_id: msgIds,
|
| 1675 | tag: 0
|
| 1676 | };
|
| 1677 | return obj;
|
| 1678 | }
|
| 1679 | function deal(paramD) {
|
| 1680 | if (paramD.result == "success") {
|
| 1681 | return {
|
| 1682 | result: true
|
| 1683 | };
|
| 1684 | } else {
|
| 1685 | return {
|
| 1686 | result: false
|
| 1687 | };
|
| 1688 | }
|
| 1689 | }
|
| 1690 | }
|
| 1691 | function getSMSDeliveryReport() {
|
| 1692 | return stuffMake(arguments, {}, prepare, deal, {}, false);
|
| 1693 | function prepare(values, isPost) {
|
| 1694 | var obj = {
|
| 1695 | cmd: "sms_status_rpt_data",
|
| 1696 | page: values.page,
|
| 1697 | data_per_page: values.smsCount
|
| 1698 | };
|
| 1699 | return obj;
|
| 1700 | }
|
| 1701 | function deal(paramD) {
|
| 1702 | if (paramD) {
|
| 1703 | return {
|
| 1704 | messages: parseMessages(paramD.messages, true)
|
| 1705 | };
|
| 1706 | } else {
|
| 1707 | return errUnknownObj;
|
| 1708 | }
|
| 1709 | }
|
| 1710 | }
|
| 1711 | function logout() {
|
| 1712 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1713 | function prepare(values, isPost) {
|
| 1714 | var obj = $.extend({}, values);
|
| 1715 | obj.goformId = "LOGOUT";
|
| 1716 | return obj;
|
| 1717 | }
|
| 1718 | function deal(paramD) {
|
| 1719 | if (paramD && paramD.result == "success") {
|
| 1720 | informationAll.isLoggedIn = false;
|
| 1721 | return {
|
| 1722 | result: true
|
| 1723 | };
|
| 1724 | } else {
|
| 1725 | return $.extend(errUnknownObj, {
|
| 1726 | errorType: "loggedOutError"
|
| 1727 | });
|
| 1728 | }
|
| 1729 | }
|
| 1730 | }
|
| 1731 | function changeManageInfo() {
|
| 1732 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1733 | function prepare(values, isPost) {
|
| 1734 | var obj = {};
|
| 1735 | obj.newPassword = config.PASSWORD_ENCODE ? Base64.encode(values.newValue) : values.newValue;
|
| 1736 | obj.oldPassword = config.PASSWORD_ENCODE ? Base64.encode(values.oldValue) : values.oldValue;
|
| 1737 | obj.goformId = "CHANGE_PASSWORD";
|
| 1738 | return obj;
|
| 1739 | }
|
| 1740 | function deal(paramD) {
|
| 1741 | if (paramD && paramD.result === "success") {
|
| 1742 | return {
|
| 1743 | result: true
|
| 1744 | };
|
| 1745 | } else {
|
| 1746 | return $.extend(errUnknownObj, {
|
| 1747 | errorType: "badPassword"
|
| 1748 | });
|
| 1749 | }
|
| 1750 | }
|
| 1751 | }
|
| 1752 | function getPinData() {
|
| 1753 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1754 | function prepare(values, isPost) {
|
| 1755 | var valueReq = {};
|
| 1756 | valueReq.cmd = "pinnumber,pin_status,puknumber";
|
| 1757 | valueReq.multi_data = 1;
|
| 1758 | return valueReq;
|
| 1759 | }
|
| 1760 | function deal(paramD) {
|
| 1761 | if (paramD) {
|
| 1762 | return paramD;
|
| 1763 | } else {
|
| 1764 | return errUnknownObj;
|
| 1765 | }
|
| 1766 | }
|
| 1767 | }
|
| 1768 | function enablePin() {
|
| 1769 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1770 | function prepare(values, isPost) {
|
| 1771 | var obj = {};
|
| 1772 | obj.goformId = "ENABLE_PIN";
|
| 1773 | obj.OldPinNumber = values.oldPin;
|
| 1774 | return obj;
|
| 1775 | }
|
| 1776 | function deal(paramD) {
|
| 1777 | if (paramD && paramD.result === "success") {
|
| 1778 | return {
|
| 1779 | result: true
|
| 1780 | };
|
| 1781 | } else {
|
| 1782 | return {
|
| 1783 | result: false
|
| 1784 | };
|
| 1785 | }
|
| 1786 | }
|
| 1787 | }
|
| 1788 | function disablePin() {
|
| 1789 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1790 | function prepare(values, isPost) {
|
| 1791 | var obj = {};
|
| 1792 | obj.goformId = "DISABLE_PIN";
|
| 1793 | obj.OldPinNumber = values.oldPin;
|
| 1794 | return obj;
|
| 1795 | }
|
| 1796 | function deal(paramD) {
|
| 1797 | if (paramD && paramD.result === "success") {
|
| 1798 | return {
|
| 1799 | result: true
|
| 1800 | };
|
| 1801 | } else {
|
| 1802 | return {
|
| 1803 | result: false
|
| 1804 | };
|
| 1805 | }
|
| 1806 | }
|
| 1807 | }
|
| 1808 | function changePin() {
|
| 1809 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1810 | function prepare(values, isPost) {
|
| 1811 | var obj = {};
|
| 1812 | obj.goformId = "ENABLE_PIN";
|
| 1813 | obj.OldPinNumber = values.oldPin;
|
| 1814 | obj.NewPinNumber = values.newPin;
|
| 1815 | return obj;
|
| 1816 | }
|
| 1817 | function deal(paramD) {
|
| 1818 | if (paramD && paramD.result === "success") {
|
| 1819 | return {
|
| 1820 | result: true
|
| 1821 | };
|
| 1822 | } else {
|
| 1823 | return {
|
| 1824 | result: false
|
| 1825 | };
|
| 1826 | }
|
| 1827 | }
|
| 1828 | }
|
| 1829 | function getLanInfo() {
|
| 1830 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1831 | function prepare(values, isPost) {
|
| 1832 | var valueReq = {};
|
| 1833 | valueReq.cmd = "lan_ipaddr,lan_netmask,mac_address,dhcpEnabled,dhcpStart,dhcpEnd,dhcpLease_hour";
|
| 1834 | valueReq.multi_data = 1;
|
| 1835 | return valueReq;
|
| 1836 | }
|
| 1837 | function deal(paramD) {
|
| 1838 | if (paramD) {
|
| 1839 | var result = {};
|
| 1840 | result.ipAddress = paramD.lan_ipaddr;
|
| 1841 | result.subnetMask = paramD.lan_netmask;
|
| 1842 | result.macAddress = paramD.mac_address;
|
| 1843 | result.dhcpServer = paramD.dhcpEnabled;
|
| 1844 | result.dhcpStart = paramD.dhcpStart;
|
| 1845 | result.dhcpEnd = paramD.dhcpEnd;
|
| 1846 | result.dhcpLease = parseInt(paramD.dhcpLease_hour, 10);
|
| 1847 | return result;
|
| 1848 | } else {
|
| 1849 | return errUnknownObj;
|
| 1850 | }
|
| 1851 | }
|
| 1852 | }
|
| 1853 | function setLanInfo() {
|
| 1854 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1855 | function prepare(values, isPost) {
|
| 1856 | var valueReq = {};
|
| 1857 | valueReq.goformId = "DHCP_SETTING";
|
| 1858 | valueReq.lanIp = values.ipAddress;
|
| 1859 | valueReq.lanNetmask = values.subnetMask;
|
| 1860 | valueReq.lanDhcpType = values.dhcpServer == "1" ? "SERVER" : "DISABLE";
|
| 1861 | if (valueReq.lanDhcpType == "SERVER") {
|
| 1862 | valueReq.dhcpStart = values.dhcpStart;
|
| 1863 | valueReq.dhcpEnd = values.dhcpEnd;
|
| 1864 | valueReq.dhcpLease = values.dhcpLease;
|
| 1865 | }
|
| 1866 | valueReq.dhcp_reboot_flag = 1;
|
| 1867 | return valueReq;
|
| 1868 | }
|
| 1869 | function deal(paramD) {
|
| 1870 | if (paramD) {
|
| 1871 | return paramD;
|
| 1872 | } else {
|
| 1873 | return errUnknownObj;
|
| 1874 | }
|
| 1875 | }
|
| 1876 | }
|
| 1877 | function getSmsSetting() {
|
| 1878 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1879 | function prepare(values, isPost) {
|
| 1880 | var valueReq = {};
|
| 1881 | valueReq.cmd = "sms_parameter_info";
|
| 1882 | return valueReq;
|
| 1883 | }
|
| 1884 | function deal(paramD) {
|
| 1885 | if (paramD) {
|
| 1886 | var result = {};
|
| 1887 | result.centerNumber = paramD.sms_para_sca;
|
| 1888 | result.memStroe = paramD.sms_para_mem_store;
|
| 1889 | result.deliveryReport = paramD.sms_para_status_report;
|
| 1890 | switch (parseInt(paramD.sms_para_validity_period, 10)) {
|
| 1891 | case 143:
|
| 1892 | result.validity = "twelve_hours";
|
| 1893 | break;
|
| 1894 | case 167:
|
| 1895 | result.validity = "one_day";
|
| 1896 | break;
|
| 1897 | case 173:
|
| 1898 | result.validity = "one_week";
|
| 1899 | break;
|
| 1900 | case 244:
|
| 1901 | result.validity = "largest";
|
| 1902 | break;
|
| 1903 | case 255:
|
| 1904 | result.validity = "largest";
|
| 1905 | break;
|
| 1906 | default:
|
| 1907 | result.validity = "twelve_hours";
|
| 1908 | break;
|
| 1909 | }
|
| 1910 | return result;
|
| 1911 | } else {
|
| 1912 | return errUnknownObj;
|
| 1913 | }
|
| 1914 | }
|
| 1915 | }
|
| 1916 | function setSmsSetting() {
|
| 1917 | var callback = arguments[1];
|
| 1918 | var errorCabllback = arguments[2] ? arguments[2] : callback;
|
| 1919 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 1920 | function prepare(values, isPost) {
|
| 1921 | var valueReq = {};
|
| 1922 | valueReq.goformId = "SET_MESSAGE_CENTER";
|
| 1923 | valueReq.save_time = values.validity;
|
| 1924 | valueReq.MessageCenter = values.centerNumber;
|
| 1925 | valueReq.status_save = values.deliveryReport;
|
| 1926 | valueReq.save_location = 'native';
|
| 1927 | valueReq.notCallback = true;
|
| 1928 | return valueReq;
|
| 1929 | }
|
| 1930 | function deal(paramD) {
|
| 1931 | if (!paramD) {
|
| 1932 | errorCabllback($.extend(errUnknownObj, {
|
| 1933 | errorType: "smsSettingFail",
|
| 1934 | errorText: "error_info"
|
| 1935 | }));
|
| 1936 | return;
|
| 1937 | }
|
| 1938 | if (paramD.result == "success") {
|
| 1939 | getSmsStatusInfo({
|
| 1940 | smsCmd: 3,
|
| 1941 | errorType: "smsSettingFail",
|
| 1942 | errorText: "error_info"
|
| 1943 | }, callback, errorCabllback);
|
| 1944 | } else {
|
| 1945 | errorCabllback($.extend(errUnknownObj, {
|
| 1946 | errorType: "deleteFail",
|
| 1947 | errorText: "delete_fail_try_again"
|
| 1948 | }));
|
| 1949 | }
|
| 1950 | }
|
| 1951 | }
|
| 1952 | function restoreFactorySettings() {
|
| 1953 | var preErrorObj = {};
|
| 1954 | if (config.HAS_PARENTAL_CONTROL && config.currentUserInChildGroup != false) {
|
| 1955 | preErrorObj = {
|
| 1956 | errorType: 'no_auth'
|
| 1957 | };
|
| 1958 | }
|
| 1959 | return stuffMake(arguments, preErrorObj, prepare, deal, null, true);
|
| 1960 | function prepare(values, isPost) {
|
| 1961 | var valueReq = {};
|
| 1962 | valueReq.goformId = "RESTORE_FACTORY_SETTINGS";
|
| 1963 | return valueReq;
|
| 1964 | }
|
| 1965 | function deal(paramD) {
|
| 1966 | if (paramD) {
|
| 1967 | return paramD;
|
| 1968 | } else {
|
| 1969 | return errUnknownObj;
|
| 1970 | }
|
| 1971 | }
|
| 1972 | }
|
| 1973 | function checkRestoreStatus(successCallback) {
|
| 1974 | var valueReq = {};
|
| 1975 | valueReq.cmd = "restore_flag";
|
| 1976 | valueReq.multi_data = 1;
|
| 1977 | reqAsync(valueReq, function (paramD) {
|
| 1978 | if (paramD && paramD.restore_flag === "1") {
|
| 1979 | successCallback();
|
| 1980 | } else {
|
| 1981 | setTimeout(function () {
|
| 1982 | checkRestoreStatus(successCallback);
|
| 1983 | }, 5000);
|
| 1984 | }
|
| 1985 | }, function () {
|
| 1986 | setTimeout(function () {
|
| 1987 | checkRestoreStatus(successCallback);
|
| 1988 | }, 5000);
|
| 1989 | }, false);
|
| 1990 | }
|
| 1991 | function getWpsInfo() {
|
| 1992 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 1993 | function prepare(values, isPost) {
|
| 1994 | var valueReq = {};
|
| 1995 | valueReq.cmd = "wifi_wps_index,WscModeOption,AuthMode,wifi_cur_state,EncrypType,wps_mode,WPS_SSID,m_ssid_enable,SSID1,m_SSID,m_EncrypType,m_AuthMode,wifi_sta_connection";
|
| 1996 | valueReq.multi_data = 1;
|
| 1997 | return valueReq;
|
| 1998 | }
|
| 1999 | function deal(paramD) {
|
| 2000 | if (paramD) {
|
| 2001 | var result = {};
|
| 2002 | result.wpsFlag = paramD.WscModeOption;
|
| 2003 | result.authMode = paramD.AuthMode;
|
| 2004 | result.wpsType = paramD.wps_mode;
|
| 2005 | result.radioFlag = paramD.wifi_cur_state == "1" ? "1" : "0";
|
| 2006 | result.encrypType = paramD.EncrypType;
|
| 2007 | result.wpsSSID = paramD.WPS_SSID;
|
| 2008 | result.ssidEnable = paramD.m_ssid_enable;
|
| 2009 | result.ssid = paramD.SSID1;
|
| 2010 | result.multiSSID = paramD.m_SSID;
|
| 2011 | result.m_encrypType = paramD.m_EncrypType;
|
| 2012 | result.wifi_wps_index = paramD.wifi_wps_index;
|
| 2013 | result.AuthMode = paramD.AuthMode;
|
| 2014 | result.m_AuthMode = paramD.m_AuthMode;
|
| 2015 | result.ap_station_enable = paramD.wifi_sta_connection;
|
| 2016 | return result;
|
| 2017 | } else {
|
| 2018 | return errUnknownObj;
|
| 2019 | }
|
| 2020 | }
|
| 2021 | }
|
| 2022 | function openWps() {
|
| 2023 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2024 | function prepare(values, isPost) {
|
| 2025 | var valueReq = {};
|
| 2026 | valueReq.goformId = "WIFI_WPS_SET";
|
| 2027 | valueReq.WPS_SSID = values.wpsSSID;
|
| 2028 | valueReq.wps_mode = values.wpsType;
|
| 2029 | valueReq.wifi_wps_index = values.wpsIndex;
|
| 2030 | if (valueReq.wps_mode == 'PIN') {
|
| 2031 | valueReq.wps_pin = values.wpsPin;
|
| 2032 | }
|
| 2033 | return valueReq;
|
| 2034 | }
|
| 2035 | function deal(paramD) {
|
| 2036 | if (paramD) {
|
| 2037 | return paramD;
|
| 2038 | } else {
|
| 2039 | return errUnknownObj;
|
| 2040 | }
|
| 2041 | }
|
| 2042 | }
|
| 2043 | function openWps_5g() {
|
| 2044 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2045 | function prepare(values, isPost) {
|
| 2046 | var valueReq = {};
|
| 2047 | valueReq.goformId = "WIFI_M_WPS_SET";
|
| 2048 | valueReq.m_WPS_SSID = values.wpsSSID;
|
| 2049 | valueReq.m_wps_mode = values.wpsType;
|
| 2050 | valueReq.m_wifi_wps_index = values.wpsIndex;
|
| 2051 | if (valueReq.m_wps_mode == 'PIN') {
|
| 2052 | valueReq.m_wps_pin = values.wpsPin;
|
| 2053 | }
|
| 2054 | return valueReq;
|
| 2055 | }
|
| 2056 | function deal(paramD) {
|
| 2057 | if (paramD) {
|
| 2058 | return paramD;
|
| 2059 | } else {
|
| 2060 | return errUnknownObj;
|
| 2061 | }
|
| 2062 | }
|
| 2063 | }
|
| 2064 | function getSleepMode() {
|
| 2065 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2066 | function prepare(values, isPost) {
|
| 2067 | var valueReq = {};
|
| 2068 | valueReq.cmd = "wifi_sleep_mode,Sleep_interval";
|
| 2069 | valueReq.multi_data = 1;
|
| 2070 | return valueReq;
|
| 2071 | }
|
| 2072 | function deal(paramD) {
|
| 2073 | if (paramD) {
|
| 2074 | var result = {};
|
| 2075 | result.wifiSleepMode = paramD.wifi_sleep_mode;
|
| 2076 | result.sleepMode = paramD.Sleep_interval;
|
| 2077 | return result;
|
| 2078 | } else {
|
| 2079 | return errUnknownObj;
|
| 2080 | }
|
| 2081 | }
|
| 2082 | }
|
| 2083 | function setSleepMode() {
|
| 2084 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2085 | function prepare(values, isPost) {
|
| 2086 | var valueReq = {};
|
| 2087 | valueReq.goformId = "SET_WIFI_SLEEP_INFO";
|
| 2088 | valueReq.sysWifiSleepMode = values.wifiSleepMode;
|
| 2089 | valueReq.sysIdleTimeToSleep = values.sleepMode;
|
| 2090 | return valueReq;
|
| 2091 | }
|
| 2092 | function deal(paramD) {
|
| 2093 | if (paramD) {
|
| 2094 | return paramD;
|
| 2095 | } else {
|
| 2096 | return errUnknownObj;
|
| 2097 | }
|
| 2098 | }
|
| 2099 | }
|
| 2100 | function getSysSecurity() {
|
| 2101 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2102 | function prepare(values, isPost) {
|
| 2103 | var valueReq = {};
|
| 2104 | valueReq.cmd = "RemoteManagement,WANPingFilter";
|
| 2105 | valueReq.multi_data = 1;
|
| 2106 | return valueReq;
|
| 2107 | }
|
| 2108 | function deal(paramD) {
|
| 2109 | if (paramD) {
|
| 2110 | var result = {};
|
| 2111 | result.remoteFlag = paramD.RemoteManagement == "1" ? "1" : "0";
|
| 2112 | result.pingFlag = paramD.WANPingFilter == "1" ? "1" : "0";
|
| 2113 | return result;
|
| 2114 | } else {
|
| 2115 | return errUnknownObj;
|
| 2116 | }
|
| 2117 | }
|
| 2118 | }
|
| 2119 | function setSysSecurity() {
|
| 2120 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2121 | function prepare(values, isPost) {
|
| 2122 | var valueReq = {};
|
| 2123 | valueReq.goformId = "FW_SYS";
|
| 2124 | valueReq.remoteManagementEnabled = values.remoteFlag;
|
| 2125 | valueReq.pingFrmWANFilterEnabled = values.pingFlag;
|
| 2126 | return valueReq;
|
| 2127 | }
|
| 2128 | function deal(paramD) {
|
| 2129 | if (paramD) {
|
| 2130 | return paramD;
|
| 2131 | } else {
|
| 2132 | return errUnknownObj;
|
| 2133 | }
|
| 2134 | }
|
| 2135 | }
|
| 2136 | function getPortForward() {
|
| 2137 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2138 | function prepare(values, isPost) {
|
| 2139 | var valueReq = {};
|
| 2140 | valueReq.cmd = "PortForwardEnable,PortForwardRules_0,PortForwardRules_1,PortForwardRules_2,PortForwardRules_3,PortForwardRules_4,PortForwardRules_5,PortForwardRules_6,PortForwardRules_7,PortForwardRules_8,PortForwardRules_9";
|
| 2141 | valueReq.multi_data = 1;
|
| 2142 | return valueReq;
|
| 2143 | }
|
| 2144 | function deal(paramD) {
|
| 2145 | if (paramD) {
|
| 2146 | var result = {};
|
| 2147 | result.portForwardEnable = paramD.PortForwardEnable;
|
| 2148 | var rules = [];
|
| 2149 | if (paramD.PortForwardRules_0 != "") {
|
| 2150 | rules.push([0, paramD.PortForwardRules_0]);
|
| 2151 | }
|
| 2152 | if (paramD.PortForwardRules_1 != "") {
|
| 2153 | rules.push([1, paramD.PortForwardRules_1]);
|
| 2154 | }
|
| 2155 | if (paramD.PortForwardRules_2 != "") {
|
| 2156 | rules.push([2, paramD.PortForwardRules_2]);
|
| 2157 | }
|
| 2158 | if (paramD.PortForwardRules_3 != "") {
|
| 2159 | rules.push([3, paramD.PortForwardRules_3]);
|
| 2160 | }
|
| 2161 | if (paramD.PortForwardRules_4 != "") {
|
| 2162 | rules.push([4, paramD.PortForwardRules_4]);
|
| 2163 | }
|
| 2164 | if (paramD.PortForwardRules_5 != "") {
|
| 2165 | rules.push([5, paramD.PortForwardRules_5]);
|
| 2166 | }
|
| 2167 | if (paramD.PortForwardRules_6 != "") {
|
| 2168 | rules.push([6, paramD.PortForwardRules_6]);
|
| 2169 | }
|
| 2170 | if (paramD.PortForwardRules_7 != "") {
|
| 2171 | rules.push([7, paramD.PortForwardRules_7]);
|
| 2172 | }
|
| 2173 | if (paramD.PortForwardRules_8 != "") {
|
| 2174 | rules.push([8, paramD.PortForwardRules_8]);
|
| 2175 | }
|
| 2176 | if (paramD.PortForwardRules_9 != "") {
|
| 2177 | rules.push([9, paramD.PortForwardRules_9]);
|
| 2178 | }
|
| 2179 | result.portForwardRules = parsePortForwardRules(rules);
|
| 2180 | return result;
|
| 2181 | } else {
|
| 2182 | return errUnknownObj;
|
| 2183 | }
|
| 2184 | }
|
| 2185 | function parsePortForwardRules(paramD) {
|
| 2186 | var rules = [];
|
| 2187 | if (paramD && paramD.length > 0) {
|
| 2188 | for (var i = 0; i < paramD.length; i++) {
|
| 2189 | var aRule = {};
|
| 2190 | var elements = paramD[i][1].split(",");
|
| 2191 | aRule.index = paramD[i][0];
|
| 2192 | aRule.ipAddress = elements[0];
|
| 2193 | aRule.portRange = elements[1] + ' - ' + elements[2];
|
| 2194 | aRule.protocol = transProtocol(elements[3]);
|
| 2195 | aRule.comment = elements[4];
|
| 2196 | rules.push(aRule);
|
| 2197 | }
|
| 2198 | }
|
| 2199 | return rules;
|
| 2200 | }
|
| 2201 | }
|
| 2202 | function setPortForward() {
|
| 2203 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2204 | function prepare(values, isPost) {
|
| 2205 | var valueReq = {};
|
| 2206 | valueReq.goformId = "FW_FORWARD_ADD";
|
| 2207 | valueReq.ipAddress = values.ipAddress;
|
| 2208 | valueReq.portStart = values.portStart;
|
| 2209 | valueReq.portEnd = values.portEnd;
|
| 2210 | valueReq.protocol = values.protocol;
|
| 2211 | valueReq.comment = values.comment;
|
| 2212 | return valueReq;
|
| 2213 | }
|
| 2214 | function deal(paramD) {
|
| 2215 | if (paramD) {
|
| 2216 | return paramD;
|
| 2217 | } else {
|
| 2218 | return errUnknownObj;
|
| 2219 | }
|
| 2220 | }
|
| 2221 | }
|
| 2222 | function deleteForwardRules() {
|
| 2223 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2224 | function prepare(values, isPost) {
|
| 2225 | var valueReq = {};
|
| 2226 | valueReq.goformId = "FW_FORWARD_DEL";
|
| 2227 | valueReq.delete_id = values.indexs.join(';') + ";";
|
| 2228 | return valueReq;
|
| 2229 | }
|
| 2230 | function deal(paramD) {
|
| 2231 | if (paramD) {
|
| 2232 | return paramD;
|
| 2233 | } else {
|
| 2234 | return errUnknownObj;
|
| 2235 | }
|
| 2236 | }
|
| 2237 | }
|
| 2238 | function enableVirtualServer() {
|
| 2239 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2240 | function prepare(values, isPost) {
|
| 2241 | var valueReq = {};
|
| 2242 | valueReq.goformId = "VIRTUAL_SERVER";
|
| 2243 | valueReq.PortForwardEnable = values.portForwardEnable;
|
| 2244 | return valueReq;
|
| 2245 | }
|
| 2246 | function deal(paramD) {
|
| 2247 | if (paramD) {
|
| 2248 | return paramD;
|
| 2249 | } else {
|
| 2250 | return errUnknownObj;
|
| 2251 | }
|
| 2252 | }
|
| 2253 | }
|
| 2254 | function wifiDecode(fact1,fact2,encode_aes) {//wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes,paramD.m_WPAPSK1_enaes);
|
| 2255 | var kstr = fact1 + fact2 + "FFFFFFFFFFFFFFFFFFFFFFFF";
|
| 2256 | var kstr_final;
|
| 2257 | var kiv_final;
|
| 2258 |
|
| 2259 | kstr_final = kstr.substring(0, 24);
|
| 2260 | kiv_final = kstr.substring(0, 16);
|
| 2261 |
|
| 2262 | var tkey = CryptoJS.enc.Latin1.parse(kstr_final);
|
| 2263 | var tiv = CryptoJS.enc.Latin1.parse(kiv_final);
|
| 2264 | var decdata = CryptoJS.AES.decrypt(encode_aes, tkey, {
|
| 2265 | iv: tiv,
|
| 2266 | mode: CryptoJS.mode.CBC,
|
| 2267 | padding: CryptoJS.pad.ZeroPadding
|
| 2268 | }).toString(CryptoJS.enc.Utf8);
|
| 2269 |
|
| 2270 | return decdata;
|
| 2271 | }
|
| 2272 | function getQuickSettingInfo() {
|
| 2273 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2274 | function prepare(values, isPost) {
|
| 2275 | var valueReq = {};
|
| 2276 | var wpask = config.PASSWORD_ENCODE ? ",WPAPSK1_encode" : ",imei,rnum_js,WPAPSK1_enaes";
|
| 2277 | valueReq.cmd = "pdp_type,ipv6_pdp_type,wifi_cur_state,SSID1,HideSSID,AuthMode,WscModeOption,ppp_status,apn_index,ipv6_apn_index,ipv6_APN_index,m_profile_name,apn_mode,EncrypType,DefaultKeyID,Key1Str1,Key2Str1,Key3Str1,Key4Str1" + wpask + ",APN_configtmp0,APN_configtmp1,APN_configtmp2,APN_configtmp3,APN_configtmp4,APN_configtmp5,APN_configtmp6,APN_configtmp7,APN_configtmp8,APN_configtmp9,APN_configtmp10,APN_configtmp11,APN_configtmp12,APN_configtmp13,APN_configtmp14,APN_configtmp15,APN_configtmp16,APN_configtmp17,APN_configtmp18,APN_configtmp19" + ",ipv6_APN_configtmp0,ipv6_APN_configtmp1,ipv6_APN_configtmp2,ipv6_APN_configtmp3,ipv6_APN_configtmp4,ipv6_APN_configtmp5,ipv6_APN_configtmp6,ipv6_APN_configtmp7,ipv6_APN_configtmp8,ipv6_APN_configtmp9,ipv6_APN_configtmp10,ipv6_APN_configtmp11,ipv6_APN_configtmp12,ipv6_APN_configtmp13,ipv6_APN_configtmp14,ipv6_APN_configtmp15,ipv6_APN_configtmp16,ipv6_APN_configtmp17,ipv6_APN_configtmp18,ipv6_APN_configtmp19";
|
| 2278 | valueReq.multi_data = 1;
|
| 2279 | return valueReq;
|
| 2280 | }
|
| 2281 | function deal(paramD) {
|
| 2282 | if (paramD) {
|
| 2283 | if (config.PASSWORD_ENCODE) {
|
| 2284 | paramD.WPAPSK1 = Base64.decode(paramD.WPAPSK1_encode);
|
| 2285 | } else {
|
| 2286 | paramD.WPAPSK1 = wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes);
|
| 2287 | }
|
| 2288 | return paramD;
|
| 2289 | } else {
|
| 2290 | return errUnknownObj;
|
| 2291 | }
|
| 2292 | }
|
| 2293 | }
|
| 2294 | function setQuickSetting4IPv6() {
|
| 2295 | stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
|
| 2296 | function prepare(values) {
|
| 2297 | var valueReq = {
|
| 2298 | goformId: "QUICK_SETUP_EX",
|
| 2299 | index: values.apn_index,
|
| 2300 | pdp_type: values.pdp_type,
|
| 2301 | apn_mode: values.apnMode,
|
| 2302 | profile_name: values.profile_name,
|
| 2303 | wan_apn: values.wan_apn,
|
| 2304 | ppp_auth_mode: values.ppp_auth_mode,
|
| 2305 | ppp_username: values.ppp_username,
|
| 2306 | ppp_passtmp: values.ppp_passtmp,
|
| 2307 | ipv6_wan_apn: values.ipv6_wan_apn,
|
| 2308 | ipv6_ppp_auth_mode: values.ipv6_ppp_auth_mode,
|
| 2309 | ipv6_ppp_username: values.ipv6_ppp_username,
|
| 2310 | ipv6_ppp_passtmp: values.ipv6_ppp_passtmp,
|
| 2311 | SSID_name: values.SSID_name,
|
| 2312 | SSID_Broadcast: values.SSID_Broadcast,
|
| 2313 | Encryption_Mode_hid: values.Encryption_Mode_hid,
|
| 2314 | security_shared_mode: values.security_shared_mode,
|
| 2315 | WPA_PreShared_Key: config.PASSWORD_ENCODE ? Base64.encode(values.WPA_PreShared_Key) : values.WPA_PreShared_Key,
|
| 2316 | wep_default_key: values.wep_default_key,
|
| 2317 | WPA_ENCRYPTION_hid: values.WPA_ENCRYPTION_hid
|
| 2318 | }
|
| 2319 | valueReq.wep_key_1 = values.wep_key_1;
|
| 2320 | valueReq.wep_key_2 = values.wep_key_2;
|
| 2321 | valueReq.wep_key_3 = values.wep_key_3;
|
| 2322 | valueReq.wep_key_4 = values.wep_key_4;
|
| 2323 | if (values.wep_default_key == '1') {
|
| 2324 | valueReq.WEP2Select = values.WEP2Select;
|
| 2325 | } else if (values.wep_default_key == '2') {
|
| 2326 | valueReq.WEP3Select = values.WEP3Select;
|
| 2327 | } else if (values.wep_default_key == '3') {
|
| 2328 | valueReq.WEP4Select = values.WEP4Select;
|
| 2329 | } else {
|
| 2330 | valueReq.WEP1Select = values.WEP1Select;
|
| 2331 | }
|
| 2332 | return valueReq;
|
| 2333 | }
|
| 2334 | function deal(paramD) {
|
| 2335 | if (paramD) {
|
| 2336 | return paramD;
|
| 2337 | } else {
|
| 2338 | return $.extend(errUnknownObj, {
|
| 2339 | errorType: "SetSetUpError"
|
| 2340 | });
|
| 2341 | }
|
| 2342 | }
|
| 2343 | }
|
| 2344 | function stuffMakeAndCheckServerIsOnline(arg, prepare, deal) {
|
| 2345 | var isServerOnline = false;
|
| 2346 | var isCallbackExecuted = false;
|
| 2347 | var values = prepare(arg[0]);
|
| 2348 | var callback = arg[1];
|
| 2349 | var successCallback = function (paramD) {
|
| 2350 | isServerOnline = true;
|
| 2351 | if (!isCallbackExecuted && callback) {
|
| 2352 | callback(deal(paramD));
|
| 2353 | }
|
| 2354 | isCallbackExecuted = true;
|
| 2355 | };
|
| 2356 | var errorMethod = arg[2];
|
| 2357 | var errorCallback = function () {
|
| 2358 | isServerOnline = true;
|
| 2359 | if (errorMethod) {
|
| 2360 | errorMethod();
|
| 2361 | }
|
| 2362 | };
|
| 2363 | reqAsync(values, successCallback, errorCallback, true);
|
| 2364 | addTimeout(function () {
|
| 2365 | if (isServerOnline == false) {
|
| 2366 | var timer = addInterval(function () {
|
| 2367 | if (isServerOnline == false) {
|
| 2368 | getLanguage({}, function (paramD) {
|
| 2369 | window.clearInterval(timer);
|
| 2370 | successCallback({
|
| 2371 | result: "success"
|
| 2372 | });
|
| 2373 | });
|
| 2374 | }
|
| 2375 | }, 1000);
|
| 2376 | }
|
| 2377 | }, 5000);
|
| 2378 | }
|
| 2379 | function getSDConfiguration() {
|
| 2380 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2381 | function prepare(values, isPost) {
|
| 2382 | var valueReq = {
|
| 2383 | cmd: "sdcard_mode_option,sd_card_state,HTTP_SHARE_STATUS,HTTP_SHARE_WR_AUTH,HTTP_SHARE_FILE",
|
| 2384 | multi_data: 1
|
| 2385 | };
|
| 2386 | return valueReq;
|
| 2387 | }
|
| 2388 | function deal(paramD) {
|
| 2389 | if (paramD) {
|
| 2390 | var fileToShare;
|
| 2391 | if ("mmc2" == paramD.HTTP_SHARE_FILE || "/mmc2" == paramD.HTTP_SHARE_FILE || "/mmc2/" == paramD.HTTP_SHARE_FILE) {
|
| 2392 | fileToShare = "1";
|
| 2393 | } else {
|
| 2394 | fileToShare = "0";
|
| 2395 | }
|
| 2396 | var result = {
|
| 2397 | sd_mode: paramD.sdcard_mode_option == "1" ? "0" : "1",
|
| 2398 | sd_status: paramD.sd_card_state,
|
| 2399 | share_status: paramD.HTTP_SHARE_STATUS == "Enabled" ? "1" : "0",
|
| 2400 | share_auth: paramD.HTTP_SHARE_WR_AUTH == "readOnly" ? "0" : "1",
|
| 2401 | file_to_share: fileToShare,
|
| 2402 | share_file: paramD.HTTP_SHARE_FILE
|
| 2403 | };
|
| 2404 | return result;
|
| 2405 | } else {
|
| 2406 | return errUnknownObj;
|
| 2407 | }
|
| 2408 | }
|
| 2409 | }
|
| 2410 | function setSdCardMode() {
|
| 2411 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2412 | function prepare(values, isPost) {
|
| 2413 | var valueReq = {
|
| 2414 | goformId: "HTTPSHARE_MODE_SET",
|
| 2415 | mode_set: values.mode == "0" ? "http_share_mode" : "usb_mode"
|
| 2416 | };
|
| 2417 | return valueReq;
|
| 2418 | }
|
| 2419 | function deal(paramD) {
|
| 2420 | if (paramD && paramD.result == 'success') {
|
| 2421 | return {
|
| 2422 | result: 'success'
|
| 2423 | };
|
| 2424 | } else if (paramD && paramD.result == 'processing') {
|
| 2425 | return {
|
| 2426 | result: 'processing'
|
| 2427 | };
|
| 2428 | } else {
|
| 2429 | return {
|
| 2430 | result: false
|
| 2431 | };
|
| 2432 | }
|
| 2433 | }
|
| 2434 | }
|
| 2435 | function checkFileExists() {
|
| 2436 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2437 | function prepare(values, isPost) {
|
| 2438 | var valueReq = {
|
| 2439 | goformId: "GOFORM_HTTPSHARE_CHECK_FILE",
|
| 2440 | path_SD_CARD: values.path
|
| 2441 | };
|
| 2442 | return valueReq;
|
| 2443 | }
|
| 2444 | function deal(paramD) {
|
| 2445 | if (paramD) {
|
| 2446 | if (paramD.result == "no_sdcard") {
|
| 2447 | return {
|
| 2448 | status: "no_sdcard"
|
| 2449 | };
|
| 2450 | } else if (paramD.result == "noexist") {
|
| 2451 | return {
|
| 2452 | status: "noexist"
|
| 2453 | };
|
| 2454 | } else if (paramD.result == "processing") {
|
| 2455 | return {
|
| 2456 | status: "processing"
|
| 2457 | };
|
| 2458 | } else {
|
| 2459 | return {
|
| 2460 | status: "exist"
|
| 2461 | };
|
| 2462 | }
|
| 2463 | } else {
|
| 2464 | return errUnknownObj;
|
| 2465 | }
|
| 2466 | }
|
| 2467 | }
|
| 2468 | function getFileList() {
|
| 2469 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2470 | function prepare(values, isPost) {
|
| 2471 | var valueReq = {
|
| 2472 | goformId: "HTTPSHARE_ENTERFOLD",
|
| 2473 | path_SD_CARD: values.path,
|
| 2474 | indexPage: values.index
|
| 2475 | };
|
| 2476 | return valueReq;
|
| 2477 | }
|
| 2478 | function deal(paramD) {
|
| 2479 | if (paramD) {
|
| 2480 | if (paramD.result == 'failure') {
|
| 2481 | return $.extend(errUnknownObj, {
|
| 2482 | errorType: "get_file_list_failure"
|
| 2483 | });
|
| 2484 | } else if (paramD.result == "no_sdcard") {
|
| 2485 | return $.extend(errUnknownObj, {
|
| 2486 | errorType: "no_sdcard"
|
| 2487 | });
|
| 2488 | } else {
|
| 2489 | return parseSdCardFile(paramD.result);
|
| 2490 | }
|
| 2491 | } else {
|
| 2492 | return errUnknownObj;
|
| 2493 | }
|
| 2494 | }
|
| 2495 | function parseSdCardFile(result) {
|
| 2496 | var fileInfo = {};
|
| 2497 | fileInfo.totalRecord = result.totalRecord;
|
| 2498 | var fileArr = [];
|
| 2499 | var details = result.fileInfo;
|
| 2500 | for (var i = 0; details && i < details.length; i++) {
|
| 2501 | if (details[i].fileName == "") {
|
| 2502 | continue;
|
| 2503 | }
|
| 2504 | var obj = {};
|
| 2505 | obj.fileName = details[i].fileName;
|
| 2506 | obj.attribute = details[i].attribute;
|
| 2507 | obj.size = details[i].size;
|
| 2508 | obj.lastUpdateTime = details[i].lastUpdateTime;
|
| 2509 | fileArr.push(obj);
|
| 2510 | }
|
| 2511 | fileInfo.details = fileArr;
|
| 2512 | return fileInfo;
|
| 2513 | }
|
| 2514 | }
|
| 2515 | function fileRename() {
|
| 2516 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2517 | function prepare(values, isPost) {
|
| 2518 | var d = new Date();
|
| 2519 | var currentTime = d.getTime();
|
| 2520 | var zoneOffsetSeconds = d.getTimezoneOffset() * 60;
|
| 2521 | return {
|
| 2522 | goformId: "HTTPSHARE_FILE_RENAME",
|
| 2523 | path_SD_CARD: values.path,
|
| 2524 | OLD_NAME_SD_CARD: values.oldPath,
|
| 2525 | NEW_NAME_SD_CARD: values.newPath,
|
| 2526 | path_SD_CARD_time: transUnixTime(currentTime),
|
| 2527 | path_SD_CARD_time_unix: Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3)
|
| 2528 | };
|
| 2529 | }
|
| 2530 | function deal(paramD) {
|
| 2531 | if (paramD) {
|
| 2532 | if (paramD.result == "success") {
|
| 2533 | return {
|
| 2534 | result: true
|
| 2535 | };
|
| 2536 | } else if (paramD.result == "no_sdcard") {
|
| 2537 | return $.extend(errUnknownObj, {
|
| 2538 | errorType: "no_sdcard"
|
| 2539 | });
|
| 2540 | } else if (paramD.result == "noexist") {
|
| 2541 | return $.extend(errUnknownObj, {
|
| 2542 | errorType: "no_exist"
|
| 2543 | });
|
| 2544 | } else if (paramD.result == "processing") {
|
| 2545 | return $.extend(errUnknownObj, {
|
| 2546 | errorType: "sd_file_processing_cant_rename"
|
| 2547 | });
|
| 2548 | } else {
|
| 2549 | return {
|
| 2550 | result: false
|
| 2551 | };
|
| 2552 | }
|
| 2553 | } else {
|
| 2554 | return errUnknownObj;
|
| 2555 | }
|
| 2556 | }
|
| 2557 | }
|
| 2558 | function getSdMemorySizes() {
|
| 2559 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2560 | function prepare(values, isPost) {
|
| 2561 | var valueReq = {
|
| 2562 | cmd: "HTTPSHARE_GETCARD_VALUE"
|
| 2563 | };
|
| 2564 | return valueReq;
|
| 2565 | }
|
| 2566 | function deal(paramD) {
|
| 2567 | if (!paramD || (paramD.result && paramD.result == "no_sdcard")) {
|
| 2568 | return $.extend(errUnknownObj, {
|
| 2569 | errorType: "no_sdcard"
|
| 2570 | });
|
| 2571 | } else {
|
| 2572 | return {
|
| 2573 | totalMemorySize: paramD.sd_card_total_size == "" ? 0 : paramD.sd_card_total_size * 32 * 1024,
|
| 2574 | availableMemorySize: paramD.sd_card_avi_space == "" ? 0 : paramD.sd_card_avi_space * 32 * 1024
|
| 2575 | };
|
| 2576 | }
|
| 2577 | }
|
| 2578 | }
|
| 2579 | function deleteFilesAndFolders() {
|
| 2580 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2581 | function prepare(values, isPost) {
|
| 2582 | var currentTime = new Date().getTime();
|
| 2583 | var valueReq = {
|
| 2584 | goformId: "HTTPSHARE_DEL",
|
| 2585 | path_SD_CARD: values.path,
|
| 2586 | name_SD_CARD: values.names,
|
| 2587 | path_SD_CARD_time: transUnixTime(currentTime),
|
| 2588 | path_SD_CARD_time_unix: Math.round(currentTime / 1e3)
|
| 2589 | };
|
| 2590 | return valueReq;
|
| 2591 | }
|
| 2592 | function deal(paramD) {
|
| 2593 | if (paramD.result && paramD.result == "failure") {
|
| 2594 | return {
|
| 2595 | status: "failure"
|
| 2596 | };
|
| 2597 | } else if (paramD.result && paramD.result == "no_sdcard") {
|
| 2598 | return {
|
| 2599 | status: "no_sdcard"
|
| 2600 | };
|
| 2601 | } else if (paramD.result && paramD.result == "processing") {
|
| 2602 | return {
|
| 2603 | status: "processing"
|
| 2604 | };
|
| 2605 | } else if (paramD.result && paramD.result == "success") {
|
| 2606 | return {
|
| 2607 | status: "success"
|
| 2608 | };
|
| 2609 | } else {
|
| 2610 | return errUnknownObj;
|
| 2611 | }
|
| 2612 | }
|
| 2613 | }
|
| 2614 | function createFolder() {
|
| 2615 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2616 | function prepare(values, isPost) {
|
| 2617 | var d = new Date();
|
| 2618 | var currentTime = d.getTime();
|
| 2619 | var zoneOffsetSeconds = d.getTimezoneOffset() * 60;
|
| 2620 | return {
|
| 2621 | goformId: "HTTPSHARE_NEW",
|
| 2622 | path_SD_CARD: values.path,
|
| 2623 | path_SD_CARD_time: transUnixTime(currentTime),
|
| 2624 | path_SD_CARD_time_unix: Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3)
|
| 2625 | };
|
| 2626 | }
|
| 2627 | function deal(paramD) {
|
| 2628 | if (paramD.result && paramD.result == "failure") {
|
| 2629 | return $.extend(errUnknownObj, {
|
| 2630 | errorType: "create_folder_failure"
|
| 2631 | });
|
| 2632 | } else if (paramD.result && paramD.result == "no_sdcard") {
|
| 2633 | return $.extend(errUnknownObj, {
|
| 2634 | errorType: "no_sdcard"
|
| 2635 | });
|
| 2636 | } else if (paramD.result && paramD.result == "success") {
|
| 2637 | return {
|
| 2638 | result: true
|
| 2639 | };
|
| 2640 | } else {
|
| 2641 | return errUnknownObj;
|
| 2642 | }
|
| 2643 | }
|
| 2644 | }
|
| 2645 | function setSdCardSharing() {
|
| 2646 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2647 | function prepare(values, isPost) {
|
| 2648 | var valueReq = {
|
| 2649 | goformId: "HTTPSHARE_AUTH_SET",
|
| 2650 | HTTP_SHARE_STATUS: values.share_status == "1" ? "Enabled" : "Disabled",
|
| 2651 | HTTP_SHARE_WR_AUTH: values.share_auth == "1" ? "readWrite" : "readOnly",
|
| 2652 | HTTP_SHARE_FILE: values.share_file
|
| 2653 | };
|
| 2654 | return valueReq;
|
| 2655 | }
|
| 2656 | function deal(paramD) {
|
| 2657 | if (paramD) {
|
| 2658 | if (paramD.result == "no_sdcard") {
|
| 2659 | return $.extend(errUnknownObj, {
|
| 2660 | errorType: "no_sdcard"
|
| 2661 | });
|
| 2662 | } else {
|
| 2663 | return {
|
| 2664 | result: true
|
| 2665 | };
|
| 2666 | }
|
| 2667 | } else {
|
| 2668 | return errUnknownObj;
|
| 2669 | }
|
| 2670 | }
|
| 2671 | }
|
| 2672 | function getPortFilter() {
|
| 2673 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2674 | function prepare(values, isPost) {
|
| 2675 | var valueReq = {};
|
| 2676 | valueReq.cmd = "IPPortFilterEnable,DefaultFirewallPolicy,IPPortFilterRules_0,IPPortFilterRules_1,IPPortFilterRules_2,IPPortFilterRules_3,IPPortFilterRules_4,IPPortFilterRules_5,IPPortFilterRules_6,IPPortFilterRules_7,IPPortFilterRules_8,IPPortFilterRules_9";
|
| 2677 | valueReq.cmd += ",IPPortFilterRulesv6_0,IPPortFilterRulesv6_1,IPPortFilterRulesv6_2,IPPortFilterRulesv6_3,IPPortFilterRulesv6_4,IPPortFilterRulesv6_5,IPPortFilterRulesv6_6,IPPortFilterRulesv6_7,IPPortFilterRulesv6_8,IPPortFilterRulesv6_9";
|
| 2678 | valueReq.multi_data = 1;
|
| 2679 | return valueReq;
|
| 2680 | }
|
| 2681 | function deal(paramD) {
|
| 2682 | if (paramD) {
|
| 2683 | var result = {};
|
| 2684 | result.portFilterEnable = paramD.IPPortFilterEnable;
|
| 2685 | result.defaultPolicy = paramD.DefaultFirewallPolicy;
|
| 2686 | var rules = [];
|
| 2687 | if (paramD.IPPortFilterRules_0 != "") {
|
| 2688 | rules.push([0, paramD.IPPortFilterRules_0]);
|
| 2689 | }
|
| 2690 | if (paramD.IPPortFilterRules_1 != "") {
|
| 2691 | rules.push([1, paramD.IPPortFilterRules_1]);
|
| 2692 | }
|
| 2693 | if (paramD.IPPortFilterRules_2 != "") {
|
| 2694 | rules.push([2, paramD.IPPortFilterRules_2]);
|
| 2695 | }
|
| 2696 | if (paramD.IPPortFilterRules_3 != "") {
|
| 2697 | rules.push([3, paramD.IPPortFilterRules_3]);
|
| 2698 | }
|
| 2699 | if (paramD.IPPortFilterRules_4 != "") {
|
| 2700 | rules.push([4, paramD.IPPortFilterRules_4]);
|
| 2701 | }
|
| 2702 | if (paramD.IPPortFilterRules_5 != "") {
|
| 2703 | rules.push([5, paramD.IPPortFilterRules_5]);
|
| 2704 | }
|
| 2705 | if (paramD.IPPortFilterRules_6 != "") {
|
| 2706 | rules.push([6, paramD.IPPortFilterRules_6]);
|
| 2707 | }
|
| 2708 | if (paramD.IPPortFilterRules_7 != "") {
|
| 2709 | rules.push([7, paramD.IPPortFilterRules_7]);
|
| 2710 | }
|
| 2711 | if (paramD.IPPortFilterRules_8 != "") {
|
| 2712 | rules.push([8, paramD.IPPortFilterRules_8]);
|
| 2713 | }
|
| 2714 | if (paramD.IPPortFilterRules_9 != "") {
|
| 2715 | rules.push([9, paramD.IPPortFilterRules_9]);
|
| 2716 | }
|
| 2717 | result.portFilterRules = parsePortFilterRules(rules, "IPv4");
|
| 2718 | var v6Rules = [];
|
| 2719 | if (paramD.IPPortFilterRulesv6_0 != "") {
|
| 2720 | v6Rules.push([10, paramD.IPPortFilterRulesv6_0]);
|
| 2721 | }
|
| 2722 | if (paramD.IPPortFilterRulesv6_1 != "") {
|
| 2723 | v6Rules.push([11, paramD.IPPortFilterRulesv6_1]);
|
| 2724 | }
|
| 2725 | if (paramD.IPPortFilterRulesv6_2 != "") {
|
| 2726 | v6Rules.push([12, paramD.IPPortFilterRulesv6_2]);
|
| 2727 | }
|
| 2728 | if (paramD.IPPortFilterRulesv6_3 != "") {
|
| 2729 | v6Rules.push([13, paramD.IPPortFilterRulesv6_3]);
|
| 2730 | }
|
| 2731 | if (paramD.IPPortFilterRulesv6_4 != "") {
|
| 2732 | v6Rules.push([14, paramD.IPPortFilterRulesv6_4]);
|
| 2733 | }
|
| 2734 | if (paramD.IPPortFilterRulesv6_5 != "") {
|
| 2735 | v6Rules.push([15, paramD.IPPortFilterRulesv6_5]);
|
| 2736 | }
|
| 2737 | if (paramD.IPPortFilterRulesv6_6 != "") {
|
| 2738 | v6Rules.push([16, paramD.IPPortFilterRulesv6_6]);
|
| 2739 | }
|
| 2740 | if (paramD.IPPortFilterRulesv6_7 != "") {
|
| 2741 | v6Rules.push([17, paramD.IPPortFilterRulesv6_7]);
|
| 2742 | }
|
| 2743 | if (paramD.IPPortFilterRulesv6_8 != "") {
|
| 2744 | v6Rules.push([18, paramD.IPPortFilterRulesv6_8]);
|
| 2745 | }
|
| 2746 | if (paramD.IPPortFilterRulesv6_9 != "") {
|
| 2747 | v6Rules.push([19, paramD.IPPortFilterRulesv6_9]);
|
| 2748 | }
|
| 2749 | result.portFilterRules = _.union(result.portFilterRules, parsePortFilterRules(v6Rules, "IPv6"));
|
| 2750 | return result;
|
| 2751 | } else {
|
| 2752 | return errUnknownObj;
|
| 2753 | }
|
| 2754 | }
|
| 2755 | function parsePortFilterRules(paramD, ipTypeTmp) {
|
| 2756 | var rules = [];
|
| 2757 | if (paramD && paramD.length > 0) {
|
| 2758 | for (var i = 0; i < paramD.length; i++) {
|
| 2759 | var aRule = {};
|
| 2760 | var elements = paramD[i][1].split(",");
|
| 2761 | aRule.index = paramD[i][0];
|
| 2762 | aRule.macAddress = elements[11];
|
| 2763 | aRule.destIpAddress = elements[4] == "any/0" ? "" : elements[4];
|
| 2764 | aRule.sourceIpAddress = elements[0] == "any/0" ? "" : elements[0];
|
| 2765 | aRule.destPortRange = elements[6] == '0' ? '' : elements[6] + " - " + elements[7];
|
| 2766 | aRule.sourcePortRange = elements[2] == '0' ? '' : elements[2] + " - " + elements[3];
|
| 2767 | aRule.action = elements[9] == 1 ? "filter_accept" : "filter_drop";
|
| 2768 | aRule.protocol = transProtocol(elements[8]);
|
| 2769 | aRule.comment = elements[10];
|
| 2770 | aRule.ipType = ipTypeTmp;
|
| 2771 | rules.push(aRule);
|
| 2772 | }
|
| 2773 | }
|
| 2774 | return rules;
|
| 2775 | }
|
| 2776 | }
|
| 2777 | function setPortFilterBasic() {
|
| 2778 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2779 | function prepare(values, isPost) {
|
| 2780 | var valueReq = {};
|
| 2781 | valueReq.goformId = "BASIC_SETTING";
|
| 2782 | valueReq.portFilterEnabled = values.portFilterEnable;
|
| 2783 | valueReq.defaultFirewallPolicy = values.defaultPolicy;
|
| 2784 | return valueReq;
|
| 2785 | }
|
| 2786 | function deal(paramD) {
|
| 2787 | if (paramD) {
|
| 2788 | return paramD;
|
| 2789 | } else {
|
| 2790 | return errUnknownObj;
|
| 2791 | }
|
| 2792 | }
|
| 2793 | }
|
| 2794 | function setPortFilter() {
|
| 2795 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2796 | function prepare(values, isPost) {
|
| 2797 | var valueReq = {};
|
| 2798 | valueReq.goformId = "ADD_IP_PORT_FILETER_V4V6";
|
| 2799 | valueReq.ip_version = values.ipType;
|
| 2800 | valueReq.mac_address = values.macAddress;
|
| 2801 | valueReq.dip_address = values.destIpAddress;
|
| 2802 | valueReq.sip_address = values.sourceIpAddress;
|
| 2803 | valueReq.dFromPort = values.destPortStart;
|
| 2804 | valueReq.dToPort = values.destPortEnd;
|
| 2805 | valueReq.sFromPort = values.sourcePortStart;
|
| 2806 | valueReq.sToPort = values.sourcePortEnd;
|
| 2807 | valueReq.action = values.action;
|
| 2808 | valueReq.protocol = values.protocol;
|
| 2809 | valueReq.comment = values.comment;
|
| 2810 | return valueReq;
|
| 2811 | }
|
| 2812 | function deal(paramD) {
|
| 2813 | if (paramD) {
|
| 2814 | return paramD;
|
| 2815 | } else {
|
| 2816 | return errUnknownObj;
|
| 2817 | }
|
| 2818 | }
|
| 2819 | }
|
| 2820 | function deleteFilterRules() {
|
| 2821 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 2822 | function prepare(values, isPost) {
|
| 2823 | var valueReq = {};
|
| 2824 | var deleteIds = _.filter(values.indexs, function (item) {
|
| 2825 | return item.length == 1;
|
| 2826 | });
|
| 2827 | valueReq.goformId = "DEL_IP_PORT_FILETER_V4V6";
|
| 2828 | var deletev6Ids = [];
|
| 2829 | _.each(values.indexs, function (item) {
|
| 2830 | if (item.length == 2) {
|
| 2831 | deletev6Ids.push(item.substring(1));
|
| 2832 | }
|
| 2833 | });
|
| 2834 | valueReq.delete_id_v6 = deletev6Ids.length > 0 ? deletev6Ids.join(';') + ";" : "";
|
| 2835 | valueReq.delete_id = deleteIds.length > 0 ? deleteIds.join(';') + ";" : "";
|
| 2836 | return valueReq;
|
| 2837 | }
|
| 2838 | function deal(paramD) {
|
| 2839 | if (paramD) {
|
| 2840 | return paramD;
|
| 2841 | } else {
|
| 2842 | return errUnknownObj;
|
| 2843 | }
|
| 2844 | }
|
| 2845 | }
|
| 2846 | function getWifiAdvance() {
|
| 2847 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2848 | function prepare(values, isPost) {
|
| 2849 | var valueReq = {};
|
| 2850 | valueReq.cmd = "WirelessMode,CountryCode,Channel,HT_MCS,wifi_band,wifi_11n_cap,MAX_Access_num,m_MAX_Access_num,MAX_Station_num,wifi_sta_connection";
|
| 2851 | valueReq.multi_data = 1;
|
| 2852 | return valueReq;
|
| 2853 | }
|
| 2854 | function deal(paramD) {
|
| 2855 | if (paramD) {
|
| 2856 | var result = {
|
| 2857 | mode: paramD.WirelessMode,
|
| 2858 | countryCode: paramD.CountryCode,
|
| 2859 | channel: paramD.Channel,
|
| 2860 | rate: paramD.HT_MCS,
|
| 2861 | wifiBand: paramD.wifi_band == 'a' ? 'a' : 'b',
|
| 2862 | bandwidth: paramD.wifi_11n_cap,
|
| 2863 | MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,
|
| 2864 | MAX_Access_num: paramD.MAX_Access_num,
|
| 2865 | m_MAX_Access_num: paramD.m_MAX_Access_num,
|
| 2866 | ap_station_enable: paramD.wifi_sta_connection
|
| 2867 | };
|
| 2868 | return result;
|
| 2869 | } else {
|
| 2870 | return errUnknownObj;
|
| 2871 | }
|
| 2872 | }
|
| 2873 | }
|
| 2874 | function setWifiAdvance() {
|
| 2875 | stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
|
| 2876 | function prepare(values) {
|
| 2877 | var valueReq = {
|
| 2878 | goformId: "SET_WIFI_INFO",
|
| 2879 | wifiMode: values.mode,
|
| 2880 | countryCode: values.countryCode,
|
| 2881 | MAX_Access_num: values.station,
|
| 2882 | m_MAX_Access_num: values.m_station
|
| 2883 | };
|
| 2884 | if (config.WIFI_BAND_SUPPORT) {
|
| 2885 | valueReq.wifi_band = values.wifiBand;
|
| 2886 | }
|
| 2887 | if (config.WIFI_BAND_SUPPORT && values.wifiBand == 'a') {
|
| 2888 | valueReq.selectedChannel = 'auto';
|
| 2889 | } else {
|
| 2890 | valueReq.selectedChannel = values.channel;
|
| 2891 | valueReq.abg_rate = values.rate;
|
| 2892 | }
|
| 2893 | if (config.WIFI_BANDWIDTH_SUPPORT) {
|
| 2894 | valueReq.wifi_11n_cap = values.bandwidth;
|
| 2895 | }
|
| 2896 | return valueReq;
|
| 2897 | }
|
| 2898 | function deal(paramD) {
|
| 2899 | if (paramD) {
|
| 2900 | return paramD;
|
| 2901 | } else {
|
| 2902 | return errUnknownObj;
|
| 2903 | }
|
| 2904 | }
|
| 2905 | }
|
| 2906 | function getDeviceInfo() {
|
| 2907 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2908 | function prepare(values, isPost) {
|
| 2909 | var wpask = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";
|
| 2910 | var valueReq = {
|
| 2911 | cmd: "wifi_coverage,m_ssid_enable,imei,ziccid,cell_id,network_type,sub_network_type,rssi,rscp,lte_rsrp,imsi,sim_imsi,cr_version,hw_version,MAX_Access_num," + wpask + "SSID1,AuthMode,m_SSID,m_AuthMode,m_HideSSID,m_MAX_Access_num,lan_ipaddr," + "mac_address,msisdn,LocalDomain,wan_ipaddr,static_wan_ipaddr,ipv6_wan_ipaddr,ipv6_pdp_type,pdp_type,ppp_status,sta_ip_status,rj45_state,ethwan_mode",
|
| 2912 | multi_data: 1
|
| 2913 | };
|
| 2914 | return valueReq;
|
| 2915 | }
|
| 2916 | function deal(paramD) {
|
| 2917 | if (paramD) {
|
| 2918 | return {
|
| 2919 | ssid: paramD.SSID1,
|
| 2920 | authMode: paramD.AuthMode,
|
| 2921 | passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),
|
| 2922 | m_ssid: paramD.m_SSID,
|
| 2923 | m_AuthMode: paramD.m_AuthMode,
|
| 2924 | m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),
|
| 2925 | m_max_access_num: paramD.m_MAX_Access_num,
|
| 2926 | multi_ssid_enable: paramD.m_ssid_enable,
|
| 2927 | ipAddress: paramD.lan_ipaddr,
|
| 2928 | wanIpAddress: paramD.wan_ipaddr,
|
| 2929 | staticWanIpAddress: paramD.static_wan_ipaddr,
|
| 2930 | ipv6WanIpAddress: paramD.ipv6_wan_ipaddr,
|
| 2931 | ipv6PdpType: paramD.ipv6_pdp_type,
|
| 2932 | macAddress: paramD.mac_address,
|
| 2933 | simSerialNumber: paramD.msisdn,
|
| 2934 | lanDomain: paramD.LocalDomain,
|
| 2935 | imei: paramD.imei,
|
| 2936 | signal: convertSignal(paramD),
|
| 2937 | imsi: paramD.imsi || paramD.sim_imsi,
|
| 2938 | iccid: paramD.ziccid,
|
| 2939 | cellid: paramD.cell_id,
|
| 2940 | sw_version: paramD.cr_version,
|
| 2941 | hw_version: paramD.hw_version,
|
| 2942 | max_access_num: paramD.MAX_Access_num,
|
| 2943 | wifiRange: paramD.wifi_coverage,
|
| 2944 | pdpType: paramD.pdp_type,
|
| 2945 | rj45ConnectStatus: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state,
|
| 2946 | blc_wan_mode: informationAll.blc_wan_mode,
|
| 2947 | connectStatus: paramD.ppp_status,
|
| 2948 | wifiConStatus: paramD.sta_ip_status,
|
| 2949 | ethwan_mode: paramD.ethwan_mode.toUpperCase()
|
| 2950 | };
|
| 2951 | } else {
|
| 2952 | return errUnknownObj;
|
| 2953 | }
|
| 2954 | }
|
| 2955 | }
|
| 2956 | function getDeviceInfoLow() {
|
| 2957 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2958 | function prepare(values, isPost) {
|
| 2959 | var valueReq = {
|
| 2960 | cmd: "imei,rnum_js",
|
| 2961 | multi_data: 1
|
| 2962 | };
|
| 2963 | return valueReq;
|
| 2964 | }
|
| 2965 | function deal(paramD) {
|
| 2966 | if (paramD) {
|
| 2967 | var kstr = paramD.rnum_js + paramD.imei + "FFFFFFFFFFFFFFFFFFFFFFFF";
|
| 2968 | var kstr_final;
|
| 2969 | var kiv_final;
|
| 2970 |
|
| 2971 | kstr_final = kstr.substring(0, 24);
|
| 2972 | kiv_final = kstr.substring(0, 16);
|
| 2973 |
|
| 2974 | return {
|
| 2975 | skey: kstr_final,
|
| 2976 | siv: kiv_final
|
| 2977 | };
|
| 2978 | } else {
|
| 2979 |
|
| 2980 | return {
|
| 2981 | skey: "FFFFFFFFFFFFFFFFFFFFFFFF",
|
| 2982 | siv: "FFFFFFFFFFFFFFFF"
|
| 2983 | };
|
| 2984 | }
|
| 2985 | }
|
| 2986 | }
|
| 2987 | function getWifiRange() {
|
| 2988 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 2989 | function prepare(values, isPost) {
|
| 2990 | var valueReq = {};
|
| 2991 | valueReq.cmd = "wifi_coverage";
|
| 2992 | return valueReq;
|
| 2993 | }
|
| 2994 | function deal(paramD) {
|
| 2995 | if (paramD) {
|
| 2996 | var result = {};
|
| 2997 | result.wifiRangeMode = paramD.wifi_coverage;
|
| 2998 | return result;
|
| 2999 | } else {
|
| 3000 | return errUnknownObj;
|
| 3001 | }
|
| 3002 | }
|
| 3003 | }
|
| 3004 | function setWifiRange() {
|
| 3005 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3006 | function prepare(values, isPost) {
|
| 3007 | var valueReq = {};
|
| 3008 | valueReq.goformId = "SET_WIFI_COVERAGE";
|
| 3009 | valueReq.wifi_coverage = values.wifiRangeMode;
|
| 3010 | return valueReq;
|
| 3011 | }
|
| 3012 | function deal(paramD) {
|
| 3013 | if (paramD) {
|
| 3014 | return paramD;
|
| 3015 | } else {
|
| 3016 | return errUnknownObj;
|
| 3017 | }
|
| 3018 | }
|
| 3019 | }
|
| 3020 | function getUpnpSetting() {
|
| 3021 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3022 | function prepare(values, isPost) {
|
| 3023 | var valueReq = {};
|
| 3024 | valueReq.cmd = "upnpEnabled";
|
| 3025 | valueReq.multi_data = 1;
|
| 3026 | return valueReq;
|
| 3027 | }
|
| 3028 | function deal(paramD) {
|
| 3029 | if (paramD) {
|
| 3030 | var result = {};
|
| 3031 | result.upnpSetting = paramD.upnpEnabled == "1" ? "1" : "0";
|
| 3032 | return result;
|
| 3033 | } else {
|
| 3034 | return errUnknownObj;
|
| 3035 | }
|
| 3036 | }
|
| 3037 | }
|
| 3038 | function setUpnpSetting() {
|
| 3039 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3040 | function prepare(values, isPost) {
|
| 3041 | var valueReq = {};
|
| 3042 | valueReq.goformId = "UPNP_SETTING";
|
| 3043 | valueReq.upnp_setting_option = values.upnpSetting;
|
| 3044 | return valueReq;
|
| 3045 | }
|
| 3046 | function deal(paramD) {
|
| 3047 | if (paramD) {
|
| 3048 | return paramD;
|
| 3049 | } else {
|
| 3050 | return errUnknownObj;
|
| 3051 | }
|
| 3052 | }
|
| 3053 | }
|
| 3054 | function getDmzSetting() {
|
| 3055 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3056 | function prepare(values, isPost) {
|
| 3057 | var valueReq = {};
|
| 3058 | valueReq.cmd = "DMZEnable,DMZIPAddress";
|
| 3059 | valueReq.multi_data = 1;
|
| 3060 | return valueReq;
|
| 3061 | }
|
| 3062 | function deal(paramD) {
|
| 3063 | if (paramD) {
|
| 3064 | var result = {};
|
| 3065 | result.dmzSetting = paramD.DMZEnable == "1" ? "1" : "0";
|
| 3066 | result.ipAddress = paramD.DMZIPAddress;
|
| 3067 | return result;
|
| 3068 | } else {
|
| 3069 | return errUnknownObj;
|
| 3070 | }
|
| 3071 | }
|
| 3072 | }
|
| 3073 | function setDmzSetting() {
|
| 3074 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3075 | function prepare(values, isPost) {
|
| 3076 | var valueReq = {};
|
| 3077 | valueReq.goformId = "DMZ_SETTING";
|
| 3078 | valueReq.DMZEnabled = values.dmzSetting;
|
| 3079 | if (valueReq.DMZEnabled == '1') {
|
| 3080 | valueReq.DMZIPAddress = values.ipAddress;
|
| 3081 | }
|
| 3082 | return valueReq;
|
| 3083 | }
|
| 3084 | function deal(paramD) {
|
| 3085 | if (paramD) {
|
| 3086 | return paramD;
|
| 3087 | } else {
|
| 3088 | return errUnknownObj;
|
| 3089 | }
|
| 3090 | }
|
| 3091 | }
|
| 3092 | function getPortMap() {
|
| 3093 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3094 | function prepare(values, isPost) {
|
| 3095 | var valueReq = {};
|
| 3096 | valueReq.cmd = "PortMapEnable,PortMapRules_0,PortMapRules_1,PortMapRules_2,PortMapRules_3,PortMapRules_4,PortMapRules_5,PortMapRules_6,PortMapRules_7,PortMapRules_8,PortMapRules_9",
|
| 3097 | valueReq.multi_data = 1;
|
| 3098 | return valueReq;
|
| 3099 | }
|
| 3100 | function deal(paramD) {
|
| 3101 | if (paramD) {
|
| 3102 | var result = {};
|
| 3103 | result.portMapEnable = paramD.PortMapEnable;
|
| 3104 | var rules = [];
|
| 3105 | if (paramD.PortMapRules_0 != "") {
|
| 3106 | rules.push([0, paramD.PortMapRules_0]);
|
| 3107 | }
|
| 3108 | if (paramD.PortMapRules_1 != "") {
|
| 3109 | rules.push([1, paramD.PortMapRules_1]);
|
| 3110 | }
|
| 3111 | if (paramD.PortMapRules_2 != "") {
|
| 3112 | rules.push([2, paramD.PortMapRules_2]);
|
| 3113 | }
|
| 3114 | if (paramD.PortMapRules_3 != "") {
|
| 3115 | rules.push([3, paramD.PortMapRules_3]);
|
| 3116 | }
|
| 3117 | if (paramD.PortMapRules_4 != "") {
|
| 3118 | rules.push([4, paramD.PortMapRules_4]);
|
| 3119 | }
|
| 3120 | if (paramD.PortMapRules_5 != "") {
|
| 3121 | rules.push([5, paramD.PortMapRules_5]);
|
| 3122 | }
|
| 3123 | if (paramD.PortMapRules_6 != "") {
|
| 3124 | rules.push([6, paramD.PortMapRules_6]);
|
| 3125 | }
|
| 3126 | if (paramD.PortMapRules_7 != "") {
|
| 3127 | rules.push([7, paramD.PortMapRules_7]);
|
| 3128 | }
|
| 3129 | if (paramD.PortMapRules_8 != "") {
|
| 3130 | rules.push([8, paramD.PortMapRules_8]);
|
| 3131 | }
|
| 3132 | if (paramD.PortMapRules_9 != "") {
|
| 3133 | rules.push([9, paramD.PortMapRules_9]);
|
| 3134 | }
|
| 3135 | result.portMapRules = parsePortMapRules(rules);
|
| 3136 | return result;
|
| 3137 | } else {
|
| 3138 | return errUnknownObj;
|
| 3139 | }
|
| 3140 | }
|
| 3141 | function parsePortMapRules(paramD) {
|
| 3142 | var rules = [];
|
| 3143 | if (paramD && paramD.length > 0) {
|
| 3144 | for (var i = 0; i < paramD.length; i++) {
|
| 3145 | var aRule = {};
|
| 3146 | var elements = paramD[i][1].split(",");
|
| 3147 | aRule.index = paramD[i][0];
|
| 3148 | aRule.sourcePort = elements[1];
|
| 3149 | aRule.destIpAddress = elements[0];
|
| 3150 | aRule.destPort = elements[2];
|
| 3151 | aRule.protocol = transProtocol(elements[3]);
|
| 3152 | aRule.comment = elements[4];
|
| 3153 | rules.push(aRule);
|
| 3154 | }
|
| 3155 | }
|
| 3156 | return rules;
|
| 3157 | }
|
| 3158 | }
|
| 3159 | function setPortMap() {
|
| 3160 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3161 | function prepare(values, isPost) {
|
| 3162 | var valueReq = {};
|
| 3163 | valueReq.goformId = "ADD_PORT_MAP";
|
| 3164 | valueReq.portMapEnabled = values.portMapEnable;
|
| 3165 | valueReq.fromPort = values.sourcePort;
|
| 3166 | valueReq.ip_address = values.destIpAddress;
|
| 3167 | valueReq.toPort = values.destPort;
|
| 3168 | valueReq.protocol = values.protocol;
|
| 3169 | valueReq.comment = values.comment;
|
| 3170 | return valueReq;
|
| 3171 | }
|
| 3172 | function deal(paramD) {
|
| 3173 | if (paramD) {
|
| 3174 | return paramD;
|
| 3175 | } else {
|
| 3176 | return errUnknownObj;
|
| 3177 | }
|
| 3178 | }
|
| 3179 | }
|
| 3180 | function enablePortMap() {
|
| 3181 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3182 | function prepare(values, isPost) {
|
| 3183 | var valueReq = {};
|
| 3184 | valueReq.goformId = "ADD_PORT_MAP";
|
| 3185 | valueReq.portMapEnabled = values.portMapEnable;
|
| 3186 | return valueReq;
|
| 3187 | }
|
| 3188 | function deal(paramD) {
|
| 3189 | if (paramD) {
|
| 3190 | return paramD;
|
| 3191 | } else {
|
| 3192 | return errUnknownObj;
|
| 3193 | }
|
| 3194 | }
|
| 3195 | }
|
| 3196 | function deleteMapRules() {
|
| 3197 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3198 | function prepare(values, isPost) {
|
| 3199 | var valueReq = {};
|
| 3200 | valueReq.goformId = "DEL_PORT_MAP";
|
| 3201 | valueReq.delete_id = values.indexs.join(';') + ";";
|
| 3202 | return valueReq;
|
| 3203 | }
|
| 3204 | function deal(paramD) {
|
| 3205 | if (paramD) {
|
| 3206 | return paramD;
|
| 3207 | } else {
|
| 3208 | return errUnknownObj;
|
| 3209 | }
|
| 3210 | }
|
| 3211 | }
|
| 3212 | function getTrafficAlertInfo() {
|
| 3213 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3214 | function prepare(values, isPost) {
|
| 3215 | return {
|
| 3216 | cmd: "data_volume_limit_switch,data_volume_limit_unit,data_volume_limit_size,data_volume_alert_percent,monthly_tx_bytes,monthly_rx_bytes,monthly_time,traffic_alined_delta",
|
| 3217 | multi_data: 1
|
| 3218 | };
|
| 3219 | }
|
| 3220 | function deal(paramD) {
|
| 3221 | if (paramD) {
|
| 3222 | var isData = paramD.data_volume_limit_unit == 'data';
|
| 3223 | var result = {
|
| 3224 | dataLimitChecked: paramD.data_volume_limit_switch,
|
| 3225 | dataLimitTypeChecked: isData ? '1' : '0',
|
| 3226 | limitDataMonth: isData ? paramD.data_volume_limit_size : '0',
|
| 3227 | alertDataReach: isData ? paramD.data_volume_alert_percent : '0',
|
| 3228 | limitTimeMonth: isData ? '0' : paramD.data_volume_limit_size,
|
| 3229 | alertTimeReach: isData ? '0' : paramD.data_volume_alert_percent,
|
| 3230 | monthlySent: paramD.monthly_tx_bytes == '' ? 0 : paramD.monthly_tx_bytes,
|
| 3231 | monthlyReceived: paramD.monthly_rx_bytes == '' ? 0 : paramD.monthly_rx_bytes,
|
| 3232 | monthlyConnectedTime: paramD.monthly_time == '' ? 0 : paramD.monthly_time,
|
| 3233 | traffic_alined_delta: paramD.traffic_alined_delta == '' ? 0 : paramD.traffic_alined_delta
|
| 3234 | };
|
| 3235 | return result;
|
| 3236 | } else {
|
| 3237 | return errUnknownObj;
|
| 3238 | }
|
| 3239 | }
|
| 3240 | }
|
| 3241 | function setTrafficAlertInfo() {
|
| 3242 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3243 | function prepare(values, isPost) {
|
| 3244 | var isData = values.dataLimitTypeChecked == '1';
|
| 3245 | var valueReq = {
|
| 3246 | goformId: "DATA_LIMIT_SETTING",
|
| 3247 | data_volume_limit_switch: values.dataLimitChecked
|
| 3248 | };
|
| 3249 | if (values.dataLimitChecked == '1') {
|
| 3250 | valueReq.data_volume_limit_unit = isData ? 'data' : 'time';
|
| 3251 | valueReq.data_volume_limit_size = isData ? values.limitDataMonth : values.limitTimeMonth;
|
| 3252 | valueReq.data_volume_alert_percent = isData ? values.alertDataReach : values.alertTimeReach;
|
| 3253 | }
|
| 3254 | return valueReq;
|
| 3255 | }
|
| 3256 | function deal(paramD) {
|
| 3257 | if (paramD) {
|
| 3258 | return paramD;
|
| 3259 | } else {
|
| 3260 | return errUnknownObj;
|
| 3261 | }
|
| 3262 | }
|
| 3263 | }
|
| 3264 | function getUSSDResponse() {
|
| 3265 | var callback = arguments[1];
|
| 3266 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3267 | function prepare(values, isPost) {
|
| 3268 | if (values.sendOrReply == "send") {
|
| 3269 | return {
|
| 3270 | goformId: "USSD_PROCESS",
|
| 3271 | USSD_operator: values.operator,
|
| 3272 | USSD_send_number: values.strUSSDCommand,
|
| 3273 | notCallback: true
|
| 3274 | };
|
| 3275 | } else if (values.sendOrReply == "reply") {
|
| 3276 | return {
|
| 3277 | goformId: "USSD_PROCESS",
|
| 3278 | USSD_operator: values.operator,
|
| 3279 | USSD_reply_number: values.strUSSDCommand,
|
| 3280 | notCallback: true
|
| 3281 | };
|
| 3282 | }
|
| 3283 | }
|
| 3284 | function deal(paramD) {
|
| 3285 | if (!paramD) {
|
| 3286 | callback(false, "ussd_fail");
|
| 3287 | return;
|
| 3288 | }
|
| 3289 | if (paramD.result == "success") {
|
| 3290 | callbackTemp = callback;
|
| 3291 | getResponse();
|
| 3292 | } else {
|
| 3293 | callback(false, "ussd_fail");
|
| 3294 | }
|
| 3295 | }
|
| 3296 | }
|
| 3297 | function getResponse() {
|
| 3298 | $.ajax({
|
| 3299 | url: "/reqproc/proc_get",
|
| 3300 | data: {
|
| 3301 | cmd: "ussd_write_flag"
|
| 3302 | },
|
| 3303 | cache: false,
|
| 3304 | async: true,
|
| 3305 | dataType: "json",
|
| 3306 | success: function (result) {
|
| 3307 | if (result.ussd_write_flag == "1") {
|
| 3308 | callbackTemp(false, "ussd_no_service");
|
| 3309 | } else if (result.ussd_write_flag == "4" || result.ussd_write_flag == "unknown" || result.ussd_write_flag == "3") {
|
| 3310 | callbackTemp(false, "ussd_timeout");
|
| 3311 | } else if (result.ussd_write_flag == "15") {
|
| 3312 | setTimeout(getResponse, 1000);
|
| 3313 | } else if (result.ussd_write_flag == "10") {
|
| 3314 | callbackTemp(false, "ussd_retry");
|
| 3315 | } else if (result.ussd_write_flag == "99") {
|
| 3316 | callbackTemp(false, "ussd_unsupport");
|
| 3317 | } else if (result.ussd_write_flag == "41") {
|
| 3318 | callbackTemp(false, "operation_not_supported");
|
| 3319 | } else if (result.ussd_write_flag == "2") {
|
| 3320 | callbackTemp(false, "network_terminated");
|
| 3321 | } else if (result.ussd_write_flag == "16") {
|
| 3322 | $.ajax({
|
| 3323 | url: "/reqproc/proc_get",
|
| 3324 | data: {
|
| 3325 | cmd: "ussd_data_info"
|
| 3326 | },
|
| 3327 | dataType: "json",
|
| 3328 | async: true,
|
| 3329 | cache: false,
|
| 3330 | success: function (paramD) {
|
| 3331 | var content = {};
|
| 3332 | content.data = paramD.ussd_data;
|
| 3333 | content.ussd_action = paramD.ussd_action;
|
| 3334 | content.ussd_dcs = paramD.ussd_dcs;
|
| 3335 | callbackTemp(true, content);
|
| 3336 | },
|
| 3337 | error: function () {
|
| 3338 | callbackTemp(false, "ussd_info_error");
|
| 3339 | }
|
| 3340 | });
|
| 3341 | } else {
|
| 3342 | callbackTemp(false, "ussd_fail");
|
| 3343 | }
|
| 3344 | },
|
| 3345 | error: function () {
|
| 3346 | callbackTemp(false, "ussd_fail");
|
| 3347 | }
|
| 3348 | });
|
| 3349 | }
|
| 3350 | function USSDReplyCancel(callback) {
|
| 3351 | $.ajax({
|
| 3352 | url: "/reqproc/proc_post",
|
| 3353 | data: {
|
| 3354 | goformId: "USSD_PROCESS",
|
| 3355 | USSD_operator: "ussd_cancel"
|
| 3356 | },
|
| 3357 | cache: false,
|
| 3358 | dataType: "json",
|
| 3359 | success: function (paramD) {
|
| 3360 | if (paramD.result == "success") {
|
| 3361 | getCancelResponse();
|
| 3362 | } else {
|
| 3363 | callback(false);
|
| 3364 | }
|
| 3365 | }
|
| 3366 | });
|
| 3367 | function getCancelResponse() {
|
| 3368 | $.ajax({
|
| 3369 | url: "/reqproc/proc_get",
|
| 3370 | data: {
|
| 3371 | cmd: "ussd_write_flag"
|
| 3372 | },
|
| 3373 | cache: false,
|
| 3374 | async: true,
|
| 3375 | dataType: "json",
|
| 3376 | success: function (result) {
|
| 3377 | if (result.ussd_write_flag == "15") {
|
| 3378 | setTimeout(getCancelResponse, 1000);
|
| 3379 | } else if (result.ussd_write_flag == "13") {
|
| 3380 | callback(true);
|
| 3381 | } else {
|
| 3382 | callback(false);
|
| 3383 | }
|
| 3384 | },
|
| 3385 | error: function () {
|
| 3386 | callback(false);
|
| 3387 | }
|
| 3388 | });
|
| 3389 | }
|
| 3390 | }
|
| 3391 | function unlockNetwork() {
|
| 3392 | var callback = arguments[1];
|
| 3393 | var checkPoint = 0;
|
| 3394 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3395 | function prepare(values) {
|
| 3396 | return {
|
| 3397 | goformId: "UNLOCK_NETWORK",
|
| 3398 | notCallback: true,
|
| 3399 | unlock_network_code: values.unlock_network_code
|
| 3400 | };
|
| 3401 | }
|
| 3402 | function deal(paramD) {
|
| 3403 | if (paramD && paramD.result == "success") {
|
| 3404 | addCallback(checkUnlockNetworkStatus);
|
| 3405 | } else {
|
| 3406 | callback({
|
| 3407 | result: 'fail'
|
| 3408 | });
|
| 3409 | }
|
| 3410 | }
|
| 3411 | function checkUnlockNetworkStatus() {
|
| 3412 | if (checkPoint > 5) {
|
| 3413 | removeCallback(checkUnlockNetworkStatus);
|
| 3414 | callback({
|
| 3415 | result: 'fail'
|
| 3416 | });
|
| 3417 | } else if (informationAll.simStatus != 'modem_imsi_waitnck') {
|
| 3418 | removeCallback(checkUnlockNetworkStatus);
|
| 3419 | callback({
|
| 3420 | result: 'success'
|
| 3421 | });
|
| 3422 | }
|
| 3423 | checkPoint++;
|
| 3424 | }
|
| 3425 | }
|
| 3426 | function getNetworkUnlockTimes() {
|
| 3427 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3428 | function prepare(values, isPost) {
|
| 3429 | return {
|
| 3430 | cmd: "unlock_nck_time"
|
| 3431 | };
|
| 3432 | }
|
| 3433 | function deal(paramD) {
|
| 3434 | if (paramD) {
|
| 3435 | return paramD;
|
| 3436 | } else {
|
| 3437 | return errUnknownObj;
|
| 3438 | }
|
| 3439 | }
|
| 3440 | }
|
| 3441 | function setUpdateInfoWarning() {
|
| 3442 | var callback = arguments[1];
|
| 3443 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3444 | function prepare(values) {
|
| 3445 | return {
|
| 3446 | goformId: "SET_UPGRADE_NOTICE",
|
| 3447 | upgrade_notice_flag: values.upgrade_notice_flag,
|
| 3448 | notCallback: true
|
| 3449 | };
|
| 3450 | }
|
| 3451 | function deal(paramD) {
|
| 3452 | if (paramD.result == "success") {
|
| 3453 | callback(true);
|
| 3454 | } else {
|
| 3455 | callback(false);
|
| 3456 | }
|
| 3457 | }
|
| 3458 | }
|
| 3459 | function getUpdateInfoWarning() {
|
| 3460 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3461 | function prepare(values, isPost) {
|
| 3462 | return {
|
| 3463 | cmd: "upgrade_notice_flag"
|
| 3464 | };
|
| 3465 | }
|
| 3466 | function deal(paramD) {
|
| 3467 | if (paramD) {
|
| 3468 | return paramD;
|
| 3469 | } else {
|
| 3470 | return errUnknownObj;
|
| 3471 | }
|
| 3472 | }
|
| 3473 | }
|
| 3474 | function getAPStationBasic() {
|
| 3475 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3476 | function prepare(values, isPost) {
|
| 3477 | return {
|
| 3478 | multi_data: 1,
|
| 3479 | cmd: "wifi_sta_connection,pswan_priority,wifiwan_priority,ethwan_priority"
|
| 3480 | };
|
| 3481 | }
|
| 3482 | function deal(paramD) {
|
| 3483 | if (paramD) {
|
| 3484 | return {
|
| 3485 | ap_station_enable: paramD.wifi_sta_connection,
|
| 3486 | ap_station_mode: parseInt(paramD.wifiwan_priority, 10) > parseInt(paramD.pswan_priority, 10) ? "wifi_pref" : "dial_pref"
|
| 3487 | }
|
| 3488 | } else {
|
| 3489 | return errUnknownObj;
|
| 3490 | }
|
| 3491 | }
|
| 3492 | }
|
| 3493 | function setAPStationBasic() {
|
| 3494 | var tmp = arguments[0];
|
| 3495 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3496 | function prepare(values) {
|
| 3497 | return {
|
| 3498 | goformId: "WIFI_STA_CONTROL",
|
| 3499 | wifi_sta_connection: values.ap_station_enable
|
| 3500 | };
|
| 3501 | }
|
| 3502 | function deal(paramD) {
|
| 3503 | if (paramD && paramD.result == "success") {
|
| 3504 | informationAll.ap_station_enable = tmp.ap_station_enable == 1;
|
| 3505 | return paramD;
|
| 3506 | } else {
|
| 3507 | return errUnknownObj;
|
| 3508 | }
|
| 3509 | }
|
| 3510 | }
|
| 3511 | function refreshAPStationStatus() {
|
| 3512 | return getAPStationBasic({}, function (paramD) {
|
| 3513 | informationAll.ap_station_enable = paramD.ap_station_enable == 1;
|
| 3514 | informationAll.ap_station_mode = paramD.ap_station_mode;
|
| 3515 | });
|
| 3516 | }
|
| 3517 | function getHotspotList() {
|
| 3518 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3519 | function prepare(values, isPost) {
|
| 3520 | var cmdStr = "wifi_profile_num,wifi_profile";
|
| 3521 | for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
|
| 3522 | cmdStr = cmdStr + ",wifi_profile" + i;
|
| 3523 | }
|
| 3524 | return {
|
| 3525 | multi_data: 1,
|
| 3526 | cmd: cmdStr
|
| 3527 | };
|
| 3528 | }
|
| 3529 | function deal(paramD) {
|
| 3530 | if (paramD) {
|
| 3531 | var wifiList = [];
|
| 3532 | for (var i = 0; i < config.AP_STATION_LIST_LENGTH; i++) {
|
| 3533 | var wifiStr = "";
|
| 3534 | if (i == 0) {
|
| 3535 | wifiStr = paramD.wifi_profile;
|
| 3536 | } else {
|
| 3537 | wifiStr = paramD["wifi_profile" + i];
|
| 3538 | }
|
| 3539 | var wifiArray = wifiStr.split(";");
|
| 3540 | for (var j = 0; j < wifiArray.length; j++) {
|
| 3541 | var item = wifiArray[j].split(",");
|
| 3542 | if (!item[0]) {
|
| 3543 | break;
|
| 3544 | }
|
| 3545 | var wifiJson = {
|
| 3546 | profileName: item[0],
|
| 3547 | fromProvider: item[1],
|
| 3548 | connectStatus: item[2],
|
| 3549 | signal: item[3],
|
| 3550 | ssid: item[4],
|
| 3551 | authMode: item[5],
|
| 3552 | encryptType: item[6],
|
| 3553 | password: item[7] == "0" ? "" : item[7],
|
| 3554 | keyID: item[8],
|
| 3555 | mac: item[9]
|
| 3556 | };
|
| 3557 | wifiList.push(wifiJson);
|
| 3558 | }
|
| 3559 | }
|
| 3560 | return {
|
| 3561 | hotspotList: wifiList
|
| 3562 | };
|
| 3563 | } else {
|
| 3564 | return errUnknownObj;
|
| 3565 | }
|
| 3566 | }
|
| 3567 | }
|
| 3568 | function searchHotspot() {
|
| 3569 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3570 | function prepare(values) {
|
| 3571 | return {
|
| 3572 | goformId: "WLAN_SET_STA_REFRESH"
|
| 3573 | };
|
| 3574 | }
|
| 3575 | function deal(paramD) {
|
| 3576 | if (paramD) {
|
| 3577 | return paramD;
|
| 3578 | } else {
|
| 3579 | return errUnknownObj;
|
| 3580 | }
|
| 3581 | }
|
| 3582 | }
|
| 3583 | function getSearchHotspotList() {
|
| 3584 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3585 | function prepare(values, isPost) {
|
| 3586 | return {
|
| 3587 | multi_data: 1,
|
| 3588 | cmd: "scan_finish,EX_APLIST,EX_APLIST1"
|
| 3589 | }
|
| 3590 | }
|
| 3591 | function deal(paramD) {
|
| 3592 | if (paramD) {
|
| 3593 | if (paramD.scan_finish == "0") {
|
| 3594 | return {
|
| 3595 | scan_finish: "0",
|
| 3596 | hotspotList: []
|
| 3597 | };
|
| 3598 | }
|
| 3599 | if (paramD.scan_finish == "2") {
|
| 3600 | return {
|
| 3601 | scan_finish: "2",
|
| 3602 | hotspotList: []
|
| 3603 | };
|
| 3604 | }
|
| 3605 | var wifiList = [];
|
| 3606 | for (var i = 0; i <= 1; i++) {
|
| 3607 | var wifiStr;
|
| 3608 | if (i == 0) {
|
| 3609 | wifiStr = paramD.EX_APLIST;
|
| 3610 | } else {
|
| 3611 | wifiStr = paramD.EX_APLIST1;
|
| 3612 | }
|
| 3613 | var wifiArray = wifiStr.split(";");
|
| 3614 | for (var j = 0; j < wifiArray.length; j++) {
|
| 3615 | var item = wifiArray[j].split(",");
|
| 3616 | if (!item[0]) {
|
| 3617 | break;
|
| 3618 | }
|
| 3619 | var wifiJson = {
|
| 3620 | fromProvider: item[0],
|
| 3621 | connectStatus: item[1],
|
| 3622 | ssid: item[2],
|
| 3623 | signal: item[3],
|
| 3624 | channel: item[4],
|
| 3625 | authMode: item[5],
|
| 3626 | encryptType: item[6],
|
| 3627 | mac: item[7]
|
| 3628 | }
|
| 3629 | wifiList.push(wifiJson);
|
| 3630 | }
|
| 3631 | }
|
| 3632 | return {
|
| 3633 | scan_finish: "1",
|
| 3634 | hotspotList: wifiList
|
| 3635 | };
|
| 3636 | } else {
|
| 3637 | return errUnknownObj;
|
| 3638 | }
|
| 3639 | }
|
| 3640 | }
|
| 3641 | function creatHotspotString(hotspot) {
|
| 3642 | var tmp = [];
|
| 3643 | tmp.push(hotspot.profileName);
|
| 3644 | tmp.push(hotspot.fromProvider || "0");
|
| 3645 | tmp.push(hotspot.connectStatus || "0");
|
| 3646 | tmp.push(hotspot.signal);
|
| 3647 | tmp.push(hotspot.ssid);
|
| 3648 | tmp.push(hotspot.authMode);
|
| 3649 | tmp.push(hotspot.encryptType);
|
| 3650 | tmp.push(hotspot.password || "0");
|
| 3651 | tmp.push(hotspot.keyID);
|
| 3652 | tmp.push(hotspot.mac);
|
| 3653 | return tmp.join(",");
|
| 3654 | }
|
| 3655 | function saveHotspot() {
|
| 3656 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3657 | function prepare(values) {
|
| 3658 | var apList = values.apList;
|
| 3659 | var action = "modify";
|
| 3660 | if (values.profileName == "") {
|
| 3661 | action = "add";
|
| 3662 | var newName = (jQuery.fn.jquery + Math.random()).replace(/\D/g, "");
|
| 3663 | values.profileName = newName;
|
| 3664 | apList.push({
|
| 3665 | profileName: newName,
|
| 3666 | fromProvider: "0",
|
| 3667 | connectStatus: "0",
|
| 3668 | signal: values.signal,
|
| 3669 | ssid: values.ssid,
|
| 3670 | authMode: values.authMode,
|
| 3671 | encryptType: values.encryptType,
|
| 3672 | password: values.password || "0",
|
| 3673 | keyID: values.keyID,
|
| 3674 | mac: values.mac
|
| 3675 | });
|
| 3676 | }
|
| 3677 | var wifi = {
|
| 3678 | "profile0": []
|
| 3679 | };
|
| 3680 | for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
|
| 3681 | wifi["profile" + i] = [];
|
| 3682 | }
|
| 3683 | var activeHotspotStr = "";
|
| 3684 | for (var i = 0; i < apList.length; i++) {
|
| 3685 | var hotspotStr = "";
|
| 3686 | if (values.profileName == apList[i].profileName) {
|
| 3687 | hotspotStr = creatHotspotString(values);
|
| 3688 | activeHotspotStr = hotspotStr;
|
| 3689 | } else {
|
| 3690 | hotspotStr = creatHotspotString(apList[i]);
|
| 3691 | }
|
| 3692 | var index = parseInt(i % 10);
|
| 3693 | wifi["profile" + index].push(hotspotStr);
|
| 3694 | }
|
| 3695 | var profileParams = {
|
| 3696 | wifi_profile: wifi.profile0.join(";")
|
| 3697 | };
|
| 3698 | for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
|
| 3699 | profileParams["wifi_profile" + i] = wifi["profile" + i].join(";");
|
| 3700 | }
|
| 3701 | var valueReq = $.extend({
|
| 3702 | goformId: "WIFI_SPOT_PROFILE_UPDATE",
|
| 3703 | wifi_profile_num: apList.length,
|
| 3704 | wifi_update_profile: activeHotspotStr,
|
| 3705 | action: action
|
| 3706 | }, profileParams);
|
| 3707 | return valueReq;
|
| 3708 | }
|
| 3709 | function deal(paramD) {
|
| 3710 | if (paramD) {
|
| 3711 | return paramD;
|
| 3712 | } else {
|
| 3713 | return errUnknownObj;
|
| 3714 | }
|
| 3715 | }
|
| 3716 | }
|
| 3717 | function deleteHotspot() {
|
| 3718 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3719 | function prepare(values) {
|
| 3720 | var apList = values.apList;
|
| 3721 | var wifi = {
|
| 3722 | "profile0": []
|
| 3723 | };
|
| 3724 | for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
|
| 3725 | wifi["profile" + i] = [];
|
| 3726 | }
|
| 3727 | var foundDelete = false;
|
| 3728 | var activeHotspotStr = "";
|
| 3729 | for (var i = 0; i < apList.length; i++) {
|
| 3730 | var hotspotStr = creatHotspotString(apList[i]);
|
| 3731 | if (apList[i].profileName == values.profileName) {
|
| 3732 | foundDelete = true;
|
| 3733 | activeHotspotStr = hotspotStr;
|
| 3734 | continue;
|
| 3735 | }
|
| 3736 | var idIndex = i;
|
| 3737 | if (foundDelete) {
|
| 3738 | idIndex = i - 1;
|
| 3739 | }
|
| 3740 | var index = parseInt(idIndex % 10);
|
| 3741 | wifi["profile" + index].push(hotspotStr);
|
| 3742 | }
|
| 3743 | var num = foundDelete ? apList.length - 1 : apList.length;
|
| 3744 | var profileParams = {
|
| 3745 | wifi_profile: wifi.profile0.join(";")
|
| 3746 | };
|
| 3747 | for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
|
| 3748 | profileParams["wifi_profile" + i] = wifi["profile" + i].join(";");
|
| 3749 | }
|
| 3750 | var valueReq = $.extend({
|
| 3751 | goformId: "WIFI_SPOT_PROFILE_UPDATE",
|
| 3752 | wifi_profile_num: num,
|
| 3753 | wifi_update_profile: activeHotspotStr,
|
| 3754 | action: "delete"
|
| 3755 | }, profileParams);
|
| 3756 | return valueReq;
|
| 3757 | }
|
| 3758 | function deal(paramD) {
|
| 3759 | if (paramD) {
|
| 3760 | return paramD;
|
| 3761 | } else {
|
| 3762 | return errUnknownObj;
|
| 3763 | }
|
| 3764 | }
|
| 3765 | }
|
| 3766 | function connectHotspot() {
|
| 3767 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3768 | function prepare(values) {
|
| 3769 | return {
|
| 3770 | goformId: "WLAN_SET_STA_CON",
|
| 3771 | EX_SSID1: values.EX_SSID1,
|
| 3772 | EX_AuthMode: values.EX_AuthMode,
|
| 3773 | EX_EncrypType: values.EX_EncrypType,
|
| 3774 | EX_DefaultKeyID: values.EX_DefaultKeyID,
|
| 3775 | EX_WEPKEY: values.EX_WEPKEY,
|
| 3776 | EX_WPAPSK1: values.EX_WPAPSK1,
|
| 3777 | EX_wifi_profile: values.EX_wifi_profile,
|
| 3778 | EX_mac: values.EX_mac
|
| 3779 | };
|
| 3780 | }
|
| 3781 | function deal(paramD) {
|
| 3782 | if (paramD && (paramD.result == "success" || paramD.result == "processing")) {
|
| 3783 | return paramD;
|
| 3784 | } else {
|
| 3785 | return errUnknownObj;
|
| 3786 | }
|
| 3787 | }
|
| 3788 | }
|
| 3789 | function disconnectHotspot() {
|
| 3790 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3791 | function prepare(values) {
|
| 3792 | return {
|
| 3793 | goformId: "WLAN_SET_STA_DISCON"
|
| 3794 | };
|
| 3795 | }
|
| 3796 | function deal(paramD) {
|
| 3797 | if (paramD && paramD.result == "success") {
|
| 3798 | return paramD;
|
| 3799 | } else {
|
| 3800 | return errUnknownObj;
|
| 3801 | }
|
| 3802 | }
|
| 3803 | }
|
| 3804 | function getOpMode() {
|
| 3805 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3806 | function prepare(values, isPost) {
|
| 3807 | return {
|
| 3808 | multi_data: 1,
|
| 3809 | cmd: "blc_wan_mode,blc_wan_auto_mode,loginfo,ppp_status,rj45_state,ethwan_mode"
|
| 3810 | };
|
| 3811 | }
|
| 3812 | function deal(paramD) {
|
| 3813 | if (paramD) {
|
| 3814 | var result = {};
|
| 3815 | if (paramD.blc_wan_mode == 'AUTO') {
|
| 3816 | result.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';
|
| 3817 | } else {
|
| 3818 | result.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';
|
| 3819 | }
|
| 3820 | result.loginfo = paramD.loginfo;
|
| 3821 | result.ppp_status = paramD.ppp_status;
|
| 3822 | result.rj45_state = (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state;
|
| 3823 | result.ethwan_mode = paramD.ethwan_mode.toUpperCase();
|
| 3824 | return result;
|
| 3825 | } else {
|
| 3826 | return errUnknownObj;
|
| 3827 | }
|
| 3828 | }
|
| 3829 | }
|
| 3830 | function getRj45PlugState() {
|
| 3831 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3832 | function prepare(values, isPost) {
|
| 3833 | return {
|
| 3834 | cmd: "rj45_plug"
|
| 3835 | };
|
| 3836 | }
|
| 3837 | function deal(paramD) {
|
| 3838 | if (paramD) {
|
| 3839 | var result = {};
|
| 3840 | result.rj45_plug = paramD.rj45_plug == "" ? "wan_lan_off" : paramD.rj45_plug;
|
| 3841 | return result;
|
| 3842 | } else {
|
| 3843 | return errUnknownObj;
|
| 3844 | }
|
| 3845 | }
|
| 3846 | }
|
| 3847 | function checkOpMode(opmode, rj45state) {
|
| 3848 | if (config.RJ45_SUPPORT) {
|
| 3849 | if (rj45state == "dead" || rj45state == "") {
|
| 3850 | return 'PPP';
|
| 3851 | } else if (!opmode || opmode == "undefined") {
|
| 3852 | if (rj45state == "working") {
|
| 3853 | return 'PPPOE';
|
| 3854 | } else {
|
| 3855 | return 'PPP';
|
| 3856 | }
|
| 3857 | } else {
|
| 3858 | return opmode;
|
| 3859 | }
|
| 3860 | } else {
|
| 3861 | return 'PPP';
|
| 3862 | }
|
| 3863 | }
|
| 3864 | function SetOperationMode(values, callback) {
|
| 3865 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3866 | function prepare(values) {
|
| 3867 | var valueReq = $.extend({
|
| 3868 | goformId: "OPERATION_MODE"
|
| 3869 | }, values);
|
| 3870 | return valueReq;
|
| 3871 | }
|
| 3872 | function deal(paramD) {
|
| 3873 | if (paramD && paramD.result == "success") {
|
| 3874 | return paramD;
|
| 3875 | } else {
|
| 3876 | return errUnknownObj;
|
| 3877 | }
|
| 3878 | }
|
| 3879 | }
|
| 3880 | function getPppoeParams() {
|
| 3881 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3882 | function prepare(values, isPost) {
|
| 3883 | return {
|
| 3884 | multi_data: 1,
|
| 3885 | cmd: "opms_wan_auto_mode,ethwan_mode,pppoe_username,pppoe_cc,ethwan_dialmode,ppp_status,static_wan_ipaddr,static_wan_netmask,static_wan_gateway,static_wan_primary_dns,static_wan_secondary_dns,rj45_state,lan_ipaddr,lan_netmask"
|
| 3886 | };
|
| 3887 | }
|
| 3888 | function deal(paramD) {
|
| 3889 | if (paramD) {
|
| 3890 | return {
|
| 3891 | opms_wan_auto_mode: paramD.opms_wan_auto_mode,
|
| 3892 | ethwan_mode: paramD.ethwan_mode.toUpperCase(),
|
| 3893 | pppoe_username: paramD.pppoe_username,
|
| 3894 | pppoe_cc: paramD.pppoe_cc,
|
| 3895 | ethwan_dialmode: paramD.ethwan_dialmode == "manual" ? "manual_dial" : "auto_dial",
|
| 3896 | ppp_status: paramD.ppp_status,
|
| 3897 | static_wan_ipaddr: paramD.static_wan_ipaddr,
|
| 3898 | static_wan_netmask: paramD.static_wan_netmask,
|
| 3899 | static_wan_gateway: paramD.static_wan_gateway,
|
| 3900 | static_wan_primary_dns: paramD.static_wan_primary_dns,
|
| 3901 | static_wan_secondary_dns: paramD.static_wan_secondary_dns,
|
| 3902 | rj45_state: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state,
|
| 3903 | lan_ipaddr: paramD.lan_ipaddr,
|
| 3904 | lan_netmask: paramD.lan_netmask
|
| 3905 | }
|
| 3906 | } else {
|
| 3907 | return errUnknownObj;
|
| 3908 | }
|
| 3909 | }
|
| 3910 | }
|
| 3911 | function setPppoeDialMode(values, callback) {
|
| 3912 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3913 | function prepare(values) {
|
| 3914 | var valueReq = $.extend({
|
| 3915 | notCallback: true
|
| 3916 | }, values);
|
| 3917 | return valueReq;
|
| 3918 | }
|
| 3919 | function deal(paramD) {
|
| 3920 | if (paramD.result == "success") {
|
| 3921 | callback({
|
| 3922 | result: true
|
| 3923 | });
|
| 3924 | } else {
|
| 3925 | callback({
|
| 3926 | result: false
|
| 3927 | });
|
| 3928 | }
|
| 3929 | }
|
| 3930 | }
|
| 3931 | function getSntpParams(values, callback) {
|
| 3932 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 3933 | function prepare(values, isPost) {
|
| 3934 | return {
|
| 3935 | multi_data: 1,
|
| 3936 | cmd: "sntp_year,sntp_month,sntp_day,sntp_hour,sntp_minute,sntp_second,sntp_time_set_mode,sntp_static_server0,sntp_static_server1,sntp_static_server2,sntp_server0,sntp_server1,sntp_server2,sntp_server3,sntp_server4,sntp_server5,sntp_server6,sntp_server7,sntp_server8,sntp_server9,sntp_other_server0,sntp_other_server1,sntp_other_server2,sntp_timezone,sntp_timezone_index,sntp_dst_enable,ppp_status,sntp_process_result,rj45_state"
|
| 3937 | };
|
| 3938 | }
|
| 3939 | function deal(paramD) {
|
| 3940 | if (paramD) {
|
| 3941 | var sntp_servers = getSntpServers(paramD);
|
| 3942 | return {
|
| 3943 | sntp_year: paramD.sntp_year,
|
| 3944 | sntp_month: paramD.sntp_month,
|
| 3945 | sntp_day: paramD.sntp_day,
|
| 3946 | sntp_hour: paramD.sntp_hour,
|
| 3947 | sntp_minute: paramD.sntp_minute,
|
| 3948 | sntp_second: paramD.sntp_second,
|
| 3949 | sntp_time_set_mode: paramD.sntp_time_set_mode,
|
| 3950 | sntp_servers: sntp_servers,
|
| 3951 | sntp_server0: paramD.sntp_server0,
|
| 3952 | sntp_server1: paramD.sntp_server1,
|
| 3953 | sntp_server2: paramD.sntp_server2,
|
| 3954 | sntp_static_server0: paramD.sntp_static_server0,
|
| 3955 | sntp_static_server1: paramD.sntp_static_server1,
|
| 3956 | sntp_static_server2: paramD.sntp_static_server2,
|
| 3957 | sntp_other_server0: paramD.sntp_other_server0,
|
| 3958 | sntp_other_server1: paramD.sntp_other_server1,
|
| 3959 | sntp_other_server2: paramD.sntp_other_server2,
|
| 3960 | sntp_timezone: paramD.sntp_timezone,
|
| 3961 | sntp_timezone_index: paramD.sntp_timezone_index ? paramD.sntp_timezone_index : "0",
|
| 3962 | sntp_dst_enable: paramD.sntp_dst_enable,
|
| 3963 | ppp_status: paramD.ppp_status,
|
| 3964 | blc_wan_mode: informationAll.blc_wan_mode,
|
| 3965 | sntp_process_result: paramD.sntp_process_result,
|
| 3966 | rj45_state: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state
|
| 3967 | }
|
| 3968 | } else {
|
| 3969 | return errUnknownObj;
|
| 3970 | }
|
| 3971 | }
|
| 3972 | function getSntpServers(paramD) {
|
| 3973 | var serverArray = [];
|
| 3974 | for (var i = 0; i < 3; i++) {
|
| 3975 | var tmp = "sntp_static_server" + (i).toString();
|
| 3976 | if (paramD[tmp] != "") {
|
| 3977 | var obj = {};
|
| 3978 | obj.name = paramD[tmp];
|
| 3979 | obj.value = paramD[tmp];
|
| 3980 | serverArray.push(obj);
|
| 3981 | }
|
| 3982 | }
|
| 3983 | var otherArray = [{
|
| 3984 | name: "Other",
|
| 3985 | value: "Other"
|
| 3986 | }, {
|
| 3987 | name: "NONE",
|
| 3988 | value: ""
|
| 3989 | }
|
| 3990 | ];
|
| 3991 | for (var j = 0; j < 2; j++) {
|
| 3992 | serverArray.push(otherArray[j]);
|
| 3993 | }
|
| 3994 | return serverArray;
|
| 3995 | }
|
| 3996 | }
|
| 3997 | function setSNTPDate(values, callback) {
|
| 3998 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 3999 | function prepare(values) {
|
| 4000 | var valueReq = $.extend({}, values);
|
| 4001 | return valueReq;
|
| 4002 | }
|
| 4003 | function deal(paramD) {
|
| 4004 | if (paramD && paramD.result == "success") {
|
| 4005 | return paramD;
|
| 4006 | } else {
|
| 4007 | return errUnknownObj;
|
| 4008 | }
|
| 4009 | }
|
| 4010 | }
|
| 4011 | function setSntpSetting(values, callback) {
|
| 4012 | var valueReq = $.extend({}, values); {
|
| 4013 | $.post("reqproc/proc_post", valueReq, function (paramD) {
|
| 4014 | if (paramD && paramD.result == "success") {
|
| 4015 | if (values.manualsettime == "auto") {
|
| 4016 | setTimeout(checkSyncStatus, 2000);
|
| 4017 | callback(paramD);
|
| 4018 | } else {
|
| 4019 | callback(true);
|
| 4020 | }
|
| 4021 | } else if (paramD && paramD.result == "processing") {
|
| 4022 | callback(paramD);
|
| 4023 | } else {
|
| 4024 | callback(false);
|
| 4025 | }
|
| 4026 | }, "json");
|
| 4027 | }
|
| 4028 | function checkSyncStatus() {
|
| 4029 | $.ajax({
|
| 4030 | url: "reqproc/proc_get",
|
| 4031 | dataType: "json",
|
| 4032 | data: {
|
| 4033 | cmd: "sntp_process_result"
|
| 4034 | },
|
| 4035 | cache: false,
|
| 4036 | async: false,
|
| 4037 | success: function (paramD) {
|
| 4038 | if (paramD.sntp_process_result == "failure") {
|
| 4039 | callback(false);
|
| 4040 | } else if (paramD.sntp_process_result == "success") {
|
| 4041 | callback(true);
|
| 4042 | } else {
|
| 4043 | setTimeout(checkSyncStatus, 2000);
|
| 4044 | }
|
| 4045 | },
|
| 4046 | error: function () {
|
| 4047 | callback(false);
|
| 4048 | }
|
| 4049 | });
|
| 4050 | }
|
| 4051 | }
|
| 4052 | function addUrlFilterRule(values, callback) {
|
| 4053 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4054 | function prepare(values) {
|
| 4055 | var valueReq = $.extend({}, values);
|
| 4056 | return valueReq;
|
| 4057 | }
|
| 4058 | function deal(paramD) {
|
| 4059 | if (paramD && paramD.result == "success") {
|
| 4060 | return paramD;
|
| 4061 | } else {
|
| 4062 | return errUnknownObj;
|
| 4063 | }
|
| 4064 | }
|
| 4065 | }
|
| 4066 | function getUrlFilterList() {
|
| 4067 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4068 | function prepare(values, isPost) {
|
| 4069 | return {
|
| 4070 | cmd: "websURLFilters"
|
| 4071 | };
|
| 4072 | }
|
| 4073 | function deal(paramD) {
|
| 4074 | var urlFilterRules = [];
|
| 4075 | if (paramD) {
|
| 4076 | if (paramD.websURLFilters.length == 0) {
|
| 4077 | return {
|
| 4078 | urlFilterRules: []
|
| 4079 | };
|
| 4080 | } else {
|
| 4081 | var tempArray = paramD.websURLFilters.split(";");
|
| 4082 | for (var i = 0; i < tempArray.length; i++) {
|
| 4083 | var aRule = {};
|
| 4084 | aRule.index = i;
|
| 4085 | aRule.url = tempArray[i];
|
| 4086 | urlFilterRules.push(aRule);
|
| 4087 | }
|
| 4088 | return {
|
| 4089 | urlFilterRules: urlFilterRules
|
| 4090 | };
|
| 4091 | }
|
| 4092 | } else {
|
| 4093 | return errUnknownObj;
|
| 4094 | }
|
| 4095 | }
|
| 4096 | }
|
| 4097 | function deleteSelectedRules(values, callback) {
|
| 4098 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4099 | function prepare(values) {
|
| 4100 | var valueReq = $.extend({}, values);
|
| 4101 | return valueReq;
|
| 4102 | }
|
| 4103 | function deal(paramD) {
|
| 4104 | if (paramD && paramD.result == "success") {
|
| 4105 | return paramD;
|
| 4106 | } else {
|
| 4107 | return errUnknownObj;
|
| 4108 | }
|
| 4109 | }
|
| 4110 | }
|
| 4111 | function getWdsInfo() {
|
| 4112 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4113 | function prepare(values, isPost) {
|
| 4114 | return {
|
| 4115 | multi_data: "1",
|
| 4116 | cmd: "wifi_wds_mode,wifi_wds_ssid,wifi_wds_AuthMode,wifi_wds_EncrypType,wifi_wds_WPAPSK1,wifi_cur_state "
|
| 4117 | };
|
| 4118 | }
|
| 4119 | function deal(paramD) {
|
| 4120 | if (paramD) {
|
| 4121 | return {
|
| 4122 | currentMode: paramD.wifi_wds_mode,
|
| 4123 | wdsSSID: paramD.wifi_wds_ssid,
|
| 4124 | wdsAuthMode: paramD.wifi_wds_AuthMode,
|
| 4125 | wdsEncrypType: paramD.wifi_wds_EncrypType,
|
| 4126 | wdsWPAPSK1: paramD.wifi_wds_WPAPSK1,
|
| 4127 | RadioOff: paramD.wifi_cur_state == "1" ? "1" : "0"
|
| 4128 | };
|
| 4129 | } else {
|
| 4130 | return errUnknownObj;
|
| 4131 | }
|
| 4132 | }
|
| 4133 | }
|
| 4134 | function setWDS(values, callback) {
|
| 4135 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4136 | function prepare(values) {
|
| 4137 | var valueReq = $.extend({}, values);
|
| 4138 | return valueReq;
|
| 4139 | }
|
| 4140 | function deal(paramD) {
|
| 4141 | if (paramD && paramD.result == "success") {
|
| 4142 | return paramD;
|
| 4143 | } else {
|
| 4144 | return errUnknownObj;
|
| 4145 | }
|
| 4146 | }
|
| 4147 | }
|
| 4148 | function getSyslogInfo() {
|
| 4149 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4150 | function prepare(values, isPost) {
|
| 4151 | return {
|
| 4152 | multi_data: "1",
|
| 4153 | cmd: "syslog_mode,debug_level"
|
| 4154 | };
|
| 4155 | }
|
| 4156 | function deal(paramD) {
|
| 4157 | if (paramD) {
|
| 4158 | return {
|
| 4159 | currentMode: paramD.syslog_mode,
|
| 4160 | debugLevel: paramD.debug_level
|
| 4161 | };
|
| 4162 | } else {
|
| 4163 | return errUnknownObj;
|
| 4164 | }
|
| 4165 | }
|
| 4166 | }
|
| 4167 | function setSysLog(values, callback) {
|
| 4168 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4169 | function prepare(values) {
|
| 4170 | var valueReq = $.extend({}, values);
|
| 4171 | return valueReq;
|
| 4172 | }
|
| 4173 | function deal(paramD) {
|
| 4174 | if (paramD && paramD.result == "success") {
|
| 4175 | return paramD;
|
| 4176 | } else {
|
| 4177 | return errUnknownObj;
|
| 4178 | }
|
| 4179 | }
|
| 4180 | }
|
| 4181 | function getMacFilterInfo() {
|
| 4182 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4183 | function prepare(values, isPost) {
|
| 4184 | return {
|
| 4185 | multi_data: "1",
|
| 4186 | cmd: "ACL_mode,wifi_mac_black_list,wifi_hostname_black_list,wifi_cur_state,user_ip_addr,client_mac_address,wifi_mac_white_list"
|
| 4187 | };
|
| 4188 | }
|
| 4189 | function deal(paramD) {
|
| 4190 | if (paramD) {
|
| 4191 | return {
|
| 4192 | ACL_mode: paramD.ACL_mode,
|
| 4193 | wifi_mac_black_list: paramD.wifi_mac_black_list,
|
| 4194 | wifi_hostname_black_list: paramD.wifi_hostname_black_list,
|
| 4195 | RadioOff: paramD.wifi_cur_state == "1" ? "1" : "0",
|
| 4196 | user_ip_addr: paramD.user_ip_addr,
|
| 4197 | client_mac_address: paramD.client_mac_address,
|
| 4198 | wifi_mac_white_list: paramD.wifi_mac_white_list
|
| 4199 | };
|
| 4200 | } else {
|
| 4201 | return errUnknownObj;
|
| 4202 | }
|
| 4203 | }
|
| 4204 | }
|
| 4205 | function setMacFilter() {
|
| 4206 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4207 | function prepare(values) {
|
| 4208 | var valueReq = $.extend({
|
| 4209 | goformId: 'WIFI_MAC_FILTER',
|
| 4210 | }, values);
|
| 4211 | return valueReq;
|
| 4212 | }
|
| 4213 | function deal(paramD) {
|
| 4214 | if (paramD && paramD.result == "success") {
|
| 4215 | return paramD;
|
| 4216 | } else {
|
| 4217 | return errUnknownObj;
|
| 4218 | }
|
| 4219 | }
|
| 4220 | }
|
| 4221 | function getFastbootSetting() {
|
| 4222 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4223 | function prepare(values) {
|
| 4224 | return {
|
| 4225 | cmd: "mgmt_quicken_power_on,need_hard_reboot,need_sim_pin",
|
| 4226 | multi_data: 1
|
| 4227 | };
|
| 4228 | }
|
| 4229 | function deal(paramD) {
|
| 4230 | return {
|
| 4231 | fastbootEnabled: paramD.mgmt_quicken_power_on == '1' ? '1' : '0',
|
| 4232 | need_hard_reboot: paramD.need_hard_reboot,
|
| 4233 | need_sim_pin: paramD.need_sim_pin == 'yes' ? 'yes' : 'no'
|
| 4234 | };
|
| 4235 | }
|
| 4236 | }
|
| 4237 | function setFastbootSetting() {
|
| 4238 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4239 | function prepare(values) {
|
| 4240 | return {
|
| 4241 | goformId: "MGMT_CONTROL_POWER_ON_SPEED",
|
| 4242 | mgmt_quicken_power_on: values.fastbootEnabled
|
| 4243 | };
|
| 4244 | }
|
| 4245 | function deal(paramD) {
|
| 4246 | if (paramD && paramD.result == "success") {
|
| 4247 | return paramD;
|
| 4248 | } else {
|
| 4249 | return errUnknownObj;
|
| 4250 | }
|
| 4251 | }
|
| 4252 | }
|
| 4253 | function turnOffDevice() {
|
| 4254 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4255 | function prepare(values, isPost) {
|
| 4256 | var valueReq = {};
|
| 4257 | valueReq.goformId = "TURN_OFF_DEVICE";
|
| 4258 | return valueReq;
|
| 4259 | }
|
| 4260 | function deal(paramD) {
|
| 4261 | if (paramD) {
|
| 4262 | return paramD;
|
| 4263 | } else {
|
| 4264 | return errUnknownObj;
|
| 4265 | }
|
| 4266 | }
|
| 4267 | }
|
| 4268 | function restart() {
|
| 4269 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4270 | function prepare(values, isPost) {
|
| 4271 | var valueReq = {};
|
| 4272 | valueReq.goformId = "REBOOT_DEVICE";
|
| 4273 | return valueReq;
|
| 4274 | }
|
| 4275 | function deal(paramD) {
|
| 4276 | if (paramD) {
|
| 4277 | return paramD;
|
| 4278 | } else {
|
| 4279 | return errUnknownObj;
|
| 4280 | }
|
| 4281 | }
|
| 4282 | }
|
| 4283 | function getScheduleSetting() {
|
| 4284 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4285 | function prepare(values, isPost) {
|
| 4286 | var valueReq = {};
|
| 4287 | valueReq.cmd = "schedule_restart_enable,schedule_restart_hour,schedule_restart_minute";
|
| 4288 | valueReq.multi_data = 1;
|
| 4289 | return valueReq;
|
| 4290 | }
|
| 4291 | function deal(paramD) {
|
| 4292 | if (paramD) {
|
| 4293 | var result = {};
|
| 4294 | result.scheduleSetting = paramD.schedule_restart_enable == "1" ? "1" : "0";
|
| 4295 | result.scheduleHour = paramD.schedule_restart_hour;
|
| 4296 | result.scheduleMinute = paramD.schedule_restart_minute;
|
| 4297 | return result;
|
| 4298 | } else {
|
| 4299 | return errUnknownObj;
|
| 4300 | }
|
| 4301 | }
|
| 4302 | }
|
| 4303 | function setScheduleSetting() {
|
| 4304 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4305 | function prepare(values, isPost) {
|
| 4306 | var valueReq = {};
|
| 4307 | valueReq.goformId = "SCHEDULE_SETTING";
|
| 4308 | valueReq.scheduleEnabled = values.scheduleSetting;
|
| 4309 | if (valueReq.scheduleEnabled == '1') {
|
| 4310 | valueReq.scheduleHour = values.scheduleHour;
|
| 4311 | valueReq.scheduleMinute = values.scheduleMinute;
|
| 4312 | }
|
| 4313 | return valueReq;
|
| 4314 | }
|
| 4315 | function deal(paramD) {
|
| 4316 | if (paramD) {
|
| 4317 | return paramD;
|
| 4318 | } else {
|
| 4319 | return errUnknownObj;
|
| 4320 | }
|
| 4321 | }
|
| 4322 | }
|
| 4323 | function getPingResult() {
|
| 4324 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4325 | function prepare(values, isPost) {
|
| 4326 | var valueReq = {};
|
| 4327 | valueReq.cmd = "ping_result";
|
| 4328 | return valueReq;
|
| 4329 | }
|
| 4330 | function deal(paramD) {
|
| 4331 | if (paramD) {
|
| 4332 | var result = {};
|
| 4333 | result.pingResult = paramD.ping_result;
|
| 4334 | return result;
|
| 4335 | } else {
|
| 4336 | return errUnknownObj;
|
| 4337 | }
|
| 4338 | }
|
| 4339 | }
|
| 4340 | function pingResultClear() {
|
| 4341 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4342 | function prepare(values, isPost) {
|
| 4343 | var valueReq = {};
|
| 4344 | valueReq.goformId = "PING_RESULT_CLEAR";
|
| 4345 | return valueReq;
|
| 4346 | }
|
| 4347 | function deal(paramD) {
|
| 4348 | if (paramD) {
|
| 4349 | return paramD;
|
| 4350 | } else {
|
| 4351 | return errUnknownObj;
|
| 4352 | }
|
| 4353 | }
|
| 4354 | }
|
| 4355 | function getPingSetting() {
|
| 4356 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4357 | function prepare(values, isPost) {
|
| 4358 | var valueReq = {};
|
| 4359 | valueReq.cmd = "ping_repetition_count,ping_diag_addr";
|
| 4360 | valueReq.multi_data = 1;
|
| 4361 | return valueReq;
|
| 4362 | }
|
| 4363 | function deal(paramD) {
|
| 4364 | if (paramD) {
|
| 4365 | var result = {};
|
| 4366 | result.pingTimes = paramD.ping_repetition_count;
|
| 4367 | result.pingURL = paramD.ping_diag_addr;
|
| 4368 | return result;
|
| 4369 | } else {
|
| 4370 | return errUnknownObj;
|
| 4371 | }
|
| 4372 | }
|
| 4373 | }
|
| 4374 | function setPingSettingStart() {
|
| 4375 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4376 | function prepare(values, isPost) {
|
| 4377 | var valueReq = {};
|
| 4378 | valueReq.goformId = "PINT_DIAGNOSTICS_START";
|
| 4379 | valueReq.ping_repetition_count = values.pingTimes;
|
| 4380 | valueReq.ping_diag_addr = values.pingURL;
|
| 4381 | return valueReq;
|
| 4382 | }
|
| 4383 | function deal(paramD) {
|
| 4384 | if (paramD) {
|
| 4385 | return paramD;
|
| 4386 | } else {
|
| 4387 | return errUnknownObj;
|
| 4388 | }
|
| 4389 | }
|
| 4390 | }
|
| 4391 | function getNewVersionState() {
|
| 4392 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4393 | function prepare(values, isPost) {
|
| 4394 | var valueReq = {};
|
| 4395 | valueReq.cmd = "fota_new_version_state,fota_current_upgrade_state,fota_package_already_download";
|
| 4396 | valueReq.multi_data = 1;
|
| 4397 | return valueReq;
|
| 4398 | }
|
| 4399 | function deal(paramD) {
|
| 4400 | if (paramD) {
|
| 4401 | var hasNewVersion = (paramD.fota_new_version_state == 'has_critical' || paramD.fota_new_version_state == 'has_optional' || paramD.fota_new_version_state == 'already_has_pkg');
|
| 4402 | paramD.hasNewVersion = hasNewVersion;
|
| 4403 | return paramD;
|
| 4404 | } else {
|
| 4405 | return errUnknownObj;
|
| 4406 | }
|
| 4407 | }
|
| 4408 | }
|
| 4409 | function getMandatory() {
|
| 4410 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4411 | function prepare(values, isPost) {
|
| 4412 | var valueReq = {};
|
| 4413 | if (config.UPGRADE_TYPE == "OTA") {
|
| 4414 | valueReq.cmd = "is_mandatory";
|
| 4415 | } else {
|
| 4416 | valueReq.cmd = "fota_new_version_state";
|
| 4417 | }
|
| 4418 | return valueReq;
|
| 4419 | }
|
| 4420 | function deal(paramD) {
|
| 4421 | if (paramD) {
|
| 4422 | if (config.UPGRADE_TYPE == "OTA") {
|
| 4423 | return {
|
| 4424 | "is_mandatory": paramD.is_mandatory == "1"
|
| 4425 | };
|
| 4426 | } else {
|
| 4427 | return {
|
| 4428 | "is_mandatory": paramD.fota_new_version_state == "has_critical"
|
| 4429 | };
|
| 4430 | }
|
| 4431 | } else {
|
| 4432 | return errUnknownObj;
|
| 4433 | }
|
| 4434 | }
|
| 4435 | }
|
| 4436 | function getUpgradeResult() {
|
| 4437 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4438 | function prepare(values, isPost) {
|
| 4439 | var valueReq = {};
|
| 4440 | valueReq.cmd = "upgrade_result";
|
| 4441 | return valueReq;
|
| 4442 | }
|
| 4443 | function deal(paramD) {
|
| 4444 | if (paramD) {
|
| 4445 | return paramD;
|
| 4446 | } else {
|
| 4447 | return errUnknownObj;
|
| 4448 | }
|
| 4449 | }
|
| 4450 | }
|
| 4451 | function getCurrentUpgradeState() {
|
| 4452 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4453 | function prepare(values, isPost) {
|
| 4454 | var valueReq = {};
|
| 4455 | valueReq.cmd = "fota_current_upgrade_state";
|
| 4456 | return valueReq;
|
| 4457 | }
|
| 4458 | function deal(paramD) {
|
| 4459 | if (paramD) {
|
| 4460 | paramD.current_upgrade_state = paramD.fota_current_upgrade_state;
|
| 4461 | return paramD;
|
| 4462 | } else {
|
| 4463 | return errUnknownObj;
|
| 4464 | }
|
| 4465 | }
|
| 4466 | }
|
| 4467 | function getPackSizeInfo() {
|
| 4468 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4469 | function prepare(values, isPost) {
|
| 4470 | var valueReq = {};
|
| 4471 | valueReq.cmd = "fota_pkg_total_size,fota_dl_pkg_size";
|
| 4472 | valueReq.multi_data = 1;
|
| 4473 | return valueReq;
|
| 4474 | }
|
| 4475 | function deal(paramD) {
|
| 4476 | if (paramD) {
|
| 4477 | return paramD;
|
| 4478 | } else {
|
| 4479 | return errUnknownObj;
|
| 4480 | }
|
| 4481 | }
|
| 4482 | }
|
| 4483 | function setUpgradeSelectOp() {
|
| 4484 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4485 | function prepare(values, isPost) {
|
| 4486 | var valueReq = {};
|
| 4487 | valueReq.goformId = "IF_UPGRADE";
|
| 4488 | valueReq.select_op = values.selectOp;
|
| 4489 | if (valueReq.select_op == 'check') {
|
| 4490 | valueReq.ota_manual_check_roam_state = 1;
|
| 4491 | }
|
| 4492 | return valueReq;
|
| 4493 | }
|
| 4494 | function deal(paramD) {
|
| 4495 | if (paramD) {
|
| 4496 | return paramD;
|
| 4497 | } else {
|
| 4498 | return errUnknownObj;
|
| 4499 | }
|
| 4500 | }
|
| 4501 | }
|
| 4502 | function getOTAUpdateSetting() {
|
| 4503 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4504 | function prepare(values, isPost) {
|
| 4505 | var valueReq = {};
|
| 4506 | valueReq.cmd = "fota_updateMode,fota_updateIntervalDay,fota_allowRoamingUpdate";
|
| 4507 | valueReq.multi_data = 1;
|
| 4508 | return valueReq;
|
| 4509 | }
|
| 4510 | function deal(paramD) {
|
| 4511 | if (paramD) {
|
| 4512 | return {
|
| 4513 | updateMode: paramD.fota_updateMode,
|
| 4514 | updateIntervalDay: paramD.fota_updateIntervalDay,
|
| 4515 | allowRoamingUpdate: paramD.fota_allowRoamingUpdate
|
| 4516 | };
|
| 4517 | } else {
|
| 4518 | return errUnknownObj;
|
| 4519 | }
|
| 4520 | }
|
| 4521 | }
|
| 4522 | function setOTAUpdateSetting() {
|
| 4523 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4524 | function prepare(values, isPost) {
|
| 4525 | var valueReq = {};
|
| 4526 | valueReq.goformId = "SetUpgAutoSetting";
|
| 4527 | valueReq.UpgMode = values.updateMode;
|
| 4528 | valueReq.UpgIntervalDay = values.updateIntervalDay;
|
| 4529 | valueReq.UpgRoamPermission = values.allowRoamingUpdate;
|
| 4530 | return valueReq;
|
| 4531 | }
|
| 4532 | function deal(paramD) {
|
| 4533 | if (paramD && paramD.result == "success") {
|
| 4534 | return paramD;
|
| 4535 | } else {
|
| 4536 | return errUnknownObj;
|
| 4537 | }
|
| 4538 | }
|
| 4539 | }
|
| 4540 | function getManualOTAUpdateSetting() {
|
| 4541 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4542 | function prepare(values, isPost) {
|
| 4543 | var valueReq = {};
|
| 4544 | valueReq.cmd = "fota_manualUpgradeURL";
|
| 4545 | valueReq.multi_data = 1;
|
| 4546 | return valueReq;
|
| 4547 | }
|
| 4548 | function deal(paramD) {
|
| 4549 | if (paramD) {
|
| 4550 | return {
|
| 4551 | updateURL: paramD.fota_manualUpgradeURL
|
| 4552 | };
|
| 4553 | } else {
|
| 4554 | return errUnknownObj;
|
| 4555 | }
|
| 4556 | }
|
| 4557 | }
|
| 4558 | function setManualOTAUpdateSetting() {
|
| 4559 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4560 | function prepare(values, isPost) {
|
| 4561 | var valueReq = {};
|
| 4562 | valueReq.goformId = "SetUpgManualSetting";
|
| 4563 | valueReq.UpgURL = values.updateURL;
|
| 4564 | return valueReq;
|
| 4565 | }
|
| 4566 | function deal(paramD) {
|
| 4567 | if (paramD && paramD.result == "success") {
|
| 4568 | return paramD;
|
| 4569 | } else {
|
| 4570 | return errUnknownObj;
|
| 4571 | }
|
| 4572 | }
|
| 4573 | }
|
| 4574 | function getOTAlastCheckTime() {
|
| 4575 | return getParams({
|
| 4576 | nv: ['dm_last_check_time']
|
| 4577 | }, arguments[1], arguments[2]);
|
| 4578 | }
|
| 4579 | function getSignalStrength() {
|
| 4580 | return getParams({
|
| 4581 | nv: ['network_type', 'sub_network_type', 'rssi', 'rscp', 'lte_rsrp']
|
| 4582 | }, arguments[1], arguments[2]);
|
| 4583 | }
|
| 4584 | function clearUpdateResult() {
|
| 4585 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4586 | function prepare(values, isPost) {
|
| 4587 | var valueReq = {};
|
| 4588 | valueReq.goformId = "RESULT_RESTORE";
|
| 4589 | return valueReq;
|
| 4590 | }
|
| 4591 | function deal(paramD) {
|
| 4592 | if (paramD && paramD.result == "success") {
|
| 4593 | return paramD;
|
| 4594 | } else {
|
| 4595 | return errUnknownObj;
|
| 4596 | }
|
| 4597 | }
|
| 4598 | }
|
| 4599 | function childGroupList() {
|
| 4600 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4601 | function prepare(values, isPost) {
|
| 4602 | var valueReq = {
|
| 4603 | cmd: "childGroupList"
|
| 4604 | };
|
| 4605 | return valueReq;
|
| 4606 | }
|
| 4607 | function deal(paramD) {
|
| 4608 | if (paramD && (paramD.childGroupList || paramD.devices)) {
|
| 4609 | return paramD;
|
| 4610 | } else {
|
| 4611 | return {
|
| 4612 | devices: []
|
| 4613 | };
|
| 4614 | }
|
| 4615 | }
|
| 4616 | }
|
| 4617 | function addChildGroup() {
|
| 4618 | return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
|
| 4619 | : {
|
| 4620 | errorType: 'no_auth'
|
| 4621 | }, prepare, deal, null, true);
|
| 4622 | function prepare(values, isPost) {
|
| 4623 | var valueReq = {
|
| 4624 | goformId: "ADD_DEVICE",
|
| 4625 | mac: values.macAddress
|
| 4626 | };
|
| 4627 | return valueReq;
|
| 4628 | }
|
| 4629 | function deal(paramD) {
|
| 4630 | if (paramD && paramD.result == 'success') {
|
| 4631 | return paramD;
|
| 4632 | } else {
|
| 4633 | return errUnknownObj;
|
| 4634 | }
|
| 4635 | }
|
| 4636 | }
|
| 4637 | function removeChildGroup() {
|
| 4638 | return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
|
| 4639 | : {
|
| 4640 | errorType: 'no_auth'
|
| 4641 | }, prepare, deal, null, true);
|
| 4642 | function prepare(values, isPost) {
|
| 4643 | var valueReq = {
|
| 4644 | goformId: "DEL_DEVICE",
|
| 4645 | mac: values.mac
|
| 4646 | };
|
| 4647 | return valueReq;
|
| 4648 | }
|
| 4649 | function deal(paramD) {
|
| 4650 | if (paramD && paramD.result == 'success') {
|
| 4651 | return paramD;
|
| 4652 | } else {
|
| 4653 | return errUnknownObj;
|
| 4654 | }
|
| 4655 | }
|
| 4656 | }
|
| 4657 | function checkCurrentUserInChildGroup(devices) {
|
| 4658 | if (typeof config.currentUserInChildGroup == "undefined") {
|
| 4659 | var childGroupDevice = [];
|
| 4660 | if (typeof devices != "undefined") {
|
| 4661 | childGroupDevice = devices;
|
| 4662 | } else {
|
| 4663 | childGroupDevice = childGroupList({}).devices;
|
| 4664 | }
|
| 4665 | var userMacAddr = getUserMacAddr({}).get_user_mac_addr;
|
| 4666 | var found = _.find(childGroupDevice, function (item) {
|
| 4667 | return item.mac == userMacAddr;
|
| 4668 | });
|
| 4669 | config.currentUserInChildGroup = typeof found != 'undefined';
|
| 4670 | return {
|
| 4671 | result: typeof found != 'undefined'
|
| 4672 | };
|
| 4673 | }
|
| 4674 | return {
|
| 4675 | result: config.currentUserInChildGroup
|
| 4676 | };
|
| 4677 | }
|
| 4678 | function getUserMacAddr() {
|
| 4679 | return getParams({
|
| 4680 | nv: 'get_user_mac_addr'
|
| 4681 | }, arguments[1], arguments[2]);
|
| 4682 | }
|
| 4683 | function getHostNameList() {
|
| 4684 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4685 | function prepare(values, isPost) {
|
| 4686 | var valueReq = {
|
| 4687 | cmd: "hostNameList"
|
| 4688 | };
|
| 4689 | return valueReq;
|
| 4690 | }
|
| 4691 | function deal(paramD) {
|
| 4692 | if (paramD && (paramD.hostNameList || paramD.devices)) {
|
| 4693 | return paramD;
|
| 4694 | } else {
|
| 4695 | return {
|
| 4696 | devices: []
|
| 4697 | };
|
| 4698 | }
|
| 4699 | }
|
| 4700 | }
|
| 4701 | function editHostName() {
|
| 4702 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4703 | function prepare(values, isPost) {
|
| 4704 | var valueReq = {
|
| 4705 | goformId: "EDIT_HOSTNAME",
|
| 4706 | mac: values.mac,
|
| 4707 | hostname: values.hostname
|
| 4708 | };
|
| 4709 | return valueReq;
|
| 4710 | }
|
| 4711 | function deal(paramD) {
|
| 4712 | if (paramD && paramD.result == 'success') {
|
| 4713 | return paramD;
|
| 4714 | } else {
|
| 4715 | return errUnknownObj;
|
| 4716 | }
|
| 4717 | }
|
| 4718 | }
|
| 4719 | function getSiteWhiteList() {
|
| 4720 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4721 | function prepare(values, isPost) {
|
| 4722 | var valueReq = {
|
| 4723 | cmd: "site_white_list"
|
| 4724 | };
|
| 4725 | return valueReq;
|
| 4726 | }
|
| 4727 | function deal(paramD) {
|
| 4728 | if (paramD && (paramD.site_white_list || paramD.siteList)) {
|
| 4729 | return paramD;
|
| 4730 | } else {
|
| 4731 | return {
|
| 4732 | siteList: []
|
| 4733 | };
|
| 4734 | }
|
| 4735 | }
|
| 4736 | }
|
| 4737 | function removeSiteWhite() {
|
| 4738 | return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
|
| 4739 | : {
|
| 4740 | errorType: 'no_auth'
|
| 4741 | }, prepare, deal, null, true);
|
| 4742 | function prepare(values, isPost) {
|
| 4743 | var valueReq = {
|
| 4744 | goformId: "REMOVE_WHITE_SITE",
|
| 4745 | ids: values.ids.join(',')
|
| 4746 | };
|
| 4747 | return valueReq;
|
| 4748 | }
|
| 4749 | function deal(paramD) {
|
| 4750 | if (paramD && paramD.result == 'success') {
|
| 4751 | return paramD;
|
| 4752 | } else {
|
| 4753 | return errUnknownObj;
|
| 4754 | }
|
| 4755 | }
|
| 4756 | }
|
| 4757 | function saveSiteWhite() {
|
| 4758 | return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
|
| 4759 | : {
|
| 4760 | errorType: 'no_auth'
|
| 4761 | }, prepare, deal, null, true);
|
| 4762 | function prepare(values, isPost) {
|
| 4763 | var valueReq = {
|
| 4764 | goformId: "ADD_WHITE_SITE",
|
| 4765 | name: values.name,
|
| 4766 | site: values.site
|
| 4767 | };
|
| 4768 | return valueReq;
|
| 4769 | }
|
| 4770 | function deal(paramD) {
|
| 4771 | if (paramD && paramD.result == 'success') {
|
| 4772 | return paramD;
|
| 4773 | } else {
|
| 4774 | return errUnknownObj;
|
| 4775 | }
|
| 4776 | }
|
| 4777 | }
|
| 4778 | function getTimeLimited() {
|
| 4779 | var defaultResult = {
|
| 4780 | '0': [],
|
| 4781 | '1': [],
|
| 4782 | '2': [],
|
| 4783 | '3': [],
|
| 4784 | '4': [],
|
| 4785 | '5': [],
|
| 4786 | '6': []
|
| 4787 | };
|
| 4788 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4789 | function prepare(values, isPost) {
|
| 4790 | var valueReq = {
|
| 4791 | cmd: "time_limited"
|
| 4792 | };
|
| 4793 | return valueReq;
|
| 4794 | }
|
| 4795 | function deal(paramD) {
|
| 4796 | if (paramD) {
|
| 4797 | return parseTimeLimited(paramD);
|
| 4798 | } else {
|
| 4799 | return defaultResult;
|
| 4800 | }
|
| 4801 | }
|
| 4802 | function parseTimeLimited(paramD) {
|
| 4803 | if (paramD.time_limited == '') {
|
| 4804 | return {
|
| 4805 | time_limited: []
|
| 4806 | };
|
| 4807 | }
|
| 4808 | var weeks = paramD.time_limited.split(';');
|
| 4809 | _.each(weeks, function (week) {
|
| 4810 | var weekTime = week.split('+');
|
| 4811 | if (weekTime.length == 2) {
|
| 4812 | defaultResult[weekTime[0]] = weekTime[1].split(',');
|
| 4813 | }
|
| 4814 | });
|
| 4815 | return defaultResult;
|
| 4816 | }
|
| 4817 | }
|
| 4818 | function saveTimeLimited() {
|
| 4819 | return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
|
| 4820 | : {
|
| 4821 | errorType: 'no_auth'
|
| 4822 | }, prepare, deal, null, true);
|
| 4823 | function prepare(values, isPost) {
|
| 4824 | var valueReq = {
|
| 4825 | goformId: "SAVE_TIME_LIMITED",
|
| 4826 | time_limited: values.time
|
| 4827 | };
|
| 4828 | return valueReq;
|
| 4829 | }
|
| 4830 | function deal(paramD) {
|
| 4831 | if (paramD && paramD.result == 'success') {
|
| 4832 | return paramD;
|
| 4833 | } else {
|
| 4834 | return errUnknownObj;
|
| 4835 | }
|
| 4836 | }
|
| 4837 | }
|
| 4838 | function getTsw() {
|
| 4839 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4840 | function prepare(values, isPost) {
|
| 4841 | var valueReq = {
|
| 4842 | cmd: "openEnable,closeEnable,openTime,closeTime",
|
| 4843 | multi_data: '1'
|
| 4844 | };
|
| 4845 | return valueReq;
|
| 4846 | }
|
| 4847 | function deal(paramD) {
|
| 4848 | if (paramD) {
|
| 4849 | if (paramD.openTime.indexOf(':') != -1) {
|
| 4850 | var open = paramD.openTime.split(':');
|
| 4851 | paramD.openH = leftInsert(open[0], 2, '0');
|
| 4852 | paramD.openM = leftInsert(open[1], 2, '0');
|
| 4853 | } else {
|
| 4854 | paramD.openH = '06';
|
| 4855 | paramD.openM = '00';
|
| 4856 | }
|
| 4857 | if (paramD.closeTime.indexOf(':') != -1) {
|
| 4858 | var close = paramD.closeTime.split(':');
|
| 4859 | paramD.closeH = leftInsert(close[0], 2, '0');
|
| 4860 | paramD.closeM = leftInsert(close[1], 2, '0');
|
| 4861 | } else {
|
| 4862 | paramD.closeH = '22';
|
| 4863 | paramD.closeM = '00';
|
| 4864 | }
|
| 4865 | return paramD;
|
| 4866 | } else {
|
| 4867 | return errUnknownObj;
|
| 4868 | }
|
| 4869 | }
|
| 4870 | }
|
| 4871 | function saveTsw() {
|
| 4872 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4873 | function prepare(values, isPost) {
|
| 4874 | var valueReq = {
|
| 4875 | goformId: "SAVE_TSW",
|
| 4876 | openEnable: values.openEnable,
|
| 4877 | closeEnable: values.closeEnable
|
| 4878 | };
|
| 4879 | if (values.openEnable == '1') {
|
| 4880 | valueReq.openTime = values.openTime;
|
| 4881 | valueReq.closeTime = values.closeTime;
|
| 4882 | }
|
| 4883 | return valueReq;
|
| 4884 | }
|
| 4885 | function deal(paramD) {
|
| 4886 | if (paramD && paramD.result == 'success') {
|
| 4887 | return paramD;
|
| 4888 | } else if (paramD && paramD.result == 'failure') {
|
| 4889 | return paramD;
|
| 4890 | } else {
|
| 4891 | return errUnknownObj;
|
| 4892 | }
|
| 4893 | }
|
| 4894 | }
|
| 4895 | function trafficCalibration() {
|
| 4896 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4897 | function prepare(values, isPost) {
|
| 4898 | var valueReq = {
|
| 4899 | goformId: "FLOW_CALIBRATION_MANUAL",
|
| 4900 | calibration_way: values.way,
|
| 4901 | time: values.way == 'time' ? values.value : 0,
|
| 4902 | data: values.way == 'data' ? values.value : 0
|
| 4903 | };
|
| 4904 | return valueReq;
|
| 4905 | }
|
| 4906 | function deal(paramD) {
|
| 4907 | if (paramD && paramD.result == 'success') {
|
| 4908 | return paramD;
|
| 4909 | } else {
|
| 4910 | return errUnknownObj;
|
| 4911 | }
|
| 4912 | }
|
| 4913 | }
|
| 4914 | function getParams() {
|
| 4915 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4916 | function prepare(values, isPost) {
|
| 4917 | var valueReq = {};
|
| 4918 | if (_.isArray(values.nv)) {
|
| 4919 | valueReq.cmd = values.nv.join(',');
|
| 4920 | valueReq.multi_data = 1;
|
| 4921 | } else {
|
| 4922 | valueReq.cmd = values.nv;
|
| 4923 | }
|
| 4924 | return valueReq;
|
| 4925 | }
|
| 4926 | function deal(paramD) {
|
| 4927 | if (paramD) {
|
| 4928 | return paramD;
|
| 4929 | } else {
|
| 4930 | return errUnknownObj;
|
| 4931 | }
|
| 4932 | }
|
| 4933 | }
|
| 4934 | function getRedirectData() {
|
| 4935 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4936 | function prepare(values, isPost) {
|
| 4937 | var valueReq = {};
|
| 4938 | valueReq.cmd = "vwim_mc_state,traffic_overrun,detect_new_version";
|
| 4939 | valueReq.multi_data = 1;
|
| 4940 | return valueReq;
|
| 4941 | }
|
| 4942 | function deal(paramD) {
|
| 4943 | if (paramD) {
|
| 4944 | var result = {};
|
| 4945 | result.vwim_mc_state = paramD.vwim_mc_state;
|
| 4946 | result.traffic_overrun = paramD.traffic_overrun;
|
| 4947 | result.detect_new_version = paramD.detect_new_version;
|
| 4948 | result.blc_wan_mode = informationAll.blc_wan_mode;
|
| 4949 | return result;
|
| 4950 | } else {
|
| 4951 | return errUnknownObj;
|
| 4952 | }
|
| 4953 | }
|
| 4954 | }
|
| 4955 | function clearRedirectFlag() {
|
| 4956 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4957 | function prepare(values, isPost) {
|
| 4958 | var valueReq = {};
|
| 4959 | valueReq.goformId = "CLEAR_REDIRECT_FLAG";
|
| 4960 | valueReq.flag_id = values.redirectFlags;
|
| 4961 | return valueReq;
|
| 4962 | }
|
| 4963 | function deal(paramD) {
|
| 4964 | if (paramD) {
|
| 4965 | return paramD;
|
| 4966 | } else {
|
| 4967 | return errUnknownObj;
|
| 4968 | }
|
| 4969 | }
|
| 4970 | }
|
| 4971 | function getV4Switch() {
|
| 4972 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 4973 | function prepare(values, isPost) {
|
| 4974 | var valueReq = {};
|
| 4975 | valueReq.cmd = "lock_zone_enable,pin_interlock_and_V4_lock";
|
| 4976 | valueReq.multi_data = 1;
|
| 4977 | return valueReq;
|
| 4978 | }
|
| 4979 | function deal(paramD) {
|
| 4980 | if (paramD) {
|
| 4981 | return paramD;
|
| 4982 | } else {
|
| 4983 | return errUnknownObj;
|
| 4984 | }
|
| 4985 | }
|
| 4986 | }
|
| 4987 | function setV4Switch() {
|
| 4988 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 4989 | function prepare(values, isPost) {
|
| 4990 | var valueReq = {};
|
| 4991 | valueReq.goformId = "PIN_LOCK_V4_ENCODE";
|
| 4992 | valueReq.pin_interlock_and_V4_lock = values.pin_interlock_and_V4_lock;
|
| 4993 | valueReq.TspLock_key_data = values.TspLock_key_data;
|
| 4994 | return valueReq;
|
| 4995 | }
|
| 4996 | function deal(paramD) {
|
| 4997 | if (paramD && paramD.result == "success") {
|
| 4998 | return paramD;
|
| 4999 | } else {
|
| 5000 | return errUnknownObj;
|
| 5001 | }
|
| 5002 | }
|
| 5003 | }
|
| 5004 | function getCellId() {
|
| 5005 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 5006 | function prepare(values, isPost) {
|
| 5007 | var valueReq = {};
|
| 5008 | valueReq.cmd = "cell_id_list,global_cell_id,network_type,sub_network_type,cell_not_correct";
|
| 5009 | valueReq.multi_data = 1;
|
| 5010 | return valueReq;
|
| 5011 | }
|
| 5012 | function deal(paramD) {
|
| 5013 | if (paramD) {
|
| 5014 | return paramD;
|
| 5015 | } else {
|
| 5016 | return errUnknownObj;
|
| 5017 | }
|
| 5018 | }
|
| 5019 | }
|
| 5020 | function setCellIdSwitch() {
|
| 5021 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 5022 | function prepare(values, isPost) {
|
| 5023 | var valueReq = {};
|
| 5024 | valueReq.goformId = "LOCK_ZONE";
|
| 5025 | valueReq.lock_zone_enable = values.lock_zone_enable;
|
| 5026 | return valueReq;
|
| 5027 | }
|
| 5028 | function deal(paramD) {
|
| 5029 | if (paramD && paramD.result == "success") {
|
| 5030 | return paramD;
|
| 5031 | } else {
|
| 5032 | return errUnknownObj;
|
| 5033 | }
|
| 5034 | }
|
| 5035 | }
|
| 5036 | function getUpdateType() {
|
| 5037 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 5038 | function prepare(values, isPost) {
|
| 5039 | var valueReq = {
|
| 5040 | cmd: "update_type"
|
| 5041 | };
|
| 5042 | return valueReq;
|
| 5043 | }
|
| 5044 | function deal(paramD) {
|
| 5045 | return {
|
| 5046 | update_type: paramD.update_type ? paramD.update_type : "mifi_fota"
|
| 5047 | }
|
| 5048 | }
|
| 5049 | }
|
| 5050 | function getSecurityInfo() {
|
| 5051 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 5052 | function prepare(values, isPost) {
|
| 5053 | var valueReq = {};
|
| 5054 | valueReq.cmd = "AuthMode,passPhrase";
|
| 5055 | valueReq.multi_data = 1;
|
| 5056 | return valueReq;
|
| 5057 | }
|
| 5058 | function deal(paramD) {
|
| 5059 | if (paramD) {
|
| 5060 | var result = {};
|
| 5061 | result.AuthMode = paramD.AuthMode;
|
| 5062 | result.passPhrase = config.PASSWORD_ENCODE ? Base64.decode(paramD.passPhrase) : paramD.passPhrase;
|
| 5063 | return result;
|
| 5064 | } else {
|
| 5065 | return errUnknownObj;
|
| 5066 | }
|
| 5067 | }
|
| 5068 | }
|
| 5069 | //can delete
|
| 5070 | function setSecurityInfo() {
|
| 5071 | return stuffMake(arguments, {}, prepare, deal, null, true);
|
| 5072 | function prepare(values, isPost) {
|
| 5073 | var valueReq = {};
|
| 5074 | valueReq.goformId = "SET_WIFI_SECURITY_INFO";
|
| 5075 | valueReq.AuthMode = values.AuthMode;
|
| 5076 | if (valueReq.AuthMode == "WPAPSKWPA2PSK") {
|
| 5077 | valueReq.passPhrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;
|
| 5078 | }
|
| 5079 | return valueReq;
|
| 5080 | }
|
| 5081 | function deal(paramD) {
|
| 5082 | if (paramD) {
|
| 5083 | return paramD;
|
| 5084 | } else {
|
| 5085 | return errUnknownObj;
|
| 5086 | }
|
| 5087 | }
|
| 5088 | }
|
| 5089 | function setWifiBasic() {
|
| 5090 | stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
|
| 5091 | function prepare(values) {
|
| 5092 | var valueReq = {
|
| 5093 | goformId: "SET_WIFI_SSID1_SETTINGS",
|
| 5094 | ssid: values.SSID,
|
| 5095 | broadcastSsidEnabled: values.broadcast,
|
| 5096 | MAX_Access_num: values.station,
|
| 5097 | security_mode: values.AuthMode,
|
| 5098 | cipher: values.cipher,
|
| 5099 | NoForwarding: values.NoForwarding,
|
| 5100 | show_qrcode_flag: values.show_qrcode_flag
|
| 5101 | };
|
| 5102 | if (config.WIFI_WEP_SUPPORT) {
|
| 5103 | valueReq.wep_default_key = values.wep_default_key;
|
| 5104 | valueReq.wep_key_1 = values.wep_key_1;
|
| 5105 | valueReq.wep_key_2 = values.wep_key_2;
|
| 5106 | valueReq.wep_key_3 = values.wep_key_3;
|
| 5107 | valueReq.wep_key_4 = values.wep_key_4;
|
| 5108 | if (values.wep_default_key == '1') {
|
| 5109 | valueReq.WEP2Select = values.WEP2Select;
|
| 5110 | } else if (values.wep_default_key == '2') {
|
| 5111 | valueReq.WEP3Select = values.WEP3Select;
|
| 5112 | } else if (values.wep_default_key == '3') {
|
| 5113 | valueReq.WEP4Select = values.WEP4Select;
|
| 5114 | } else {
|
| 5115 | valueReq.WEP1Select = values.WEP1Select;
|
| 5116 | }
|
| 5117 | }
|
| 5118 | if (values.AuthMode == "WPAPSK" || values.AuthMode == "WPA2PSK" || values.AuthMode == "WPAPSKWPA2PSK" || values.AuthMode == "WPA3Personal" || values.AuthMode == "WPA2WPA3") {
|
| 5119 | valueReq.security_shared_mode = values.cipher;
|
| 5120 | valueReq.passphrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;
|
| 5121 | } else if (values.AuthMode == "SHARED") {
|
| 5122 | valueReq.security_shared_mode = "WEP";
|
| 5123 | valueReq.security_mode = "SHARED";
|
| 5124 | } else {
|
| 5125 | if (values.encryptType == "WEP") {
|
| 5126 | valueReq.security_shared_mode = "WEP";
|
| 5127 | valueReq.security_mode = "OPEN";
|
| 5128 | } else {
|
| 5129 | valueReq.security_shared_mode = "NONE";
|
| 5130 | }
|
| 5131 | }
|
| 5132 | return valueReq;
|
| 5133 | }
|
| 5134 | function deal(paramD) {
|
| 5135 | if (paramD) {
|
| 5136 | return paramD;
|
| 5137 | } else {
|
| 5138 | return errUnknownObj;
|
| 5139 | }
|
| 5140 | }
|
| 5141 | }
|
| 5142 | function setWifiBasic4SSID2() {
|
| 5143 | stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
|
| 5144 | function prepare(values) {
|
| 5145 | var valueReq = {
|
| 5146 | goformId: "SET_WIFI_SSID2_SETTINGS",
|
| 5147 | m_SSID: values.m_SSID,
|
| 5148 | m_HideSSID: values.m_broadcast,
|
| 5149 | m_MAX_Access_num: values.m_station,
|
| 5150 | m_AuthMode: values.m_AuthMode,
|
| 5151 | cipher: values.m_cipher,
|
| 5152 | m_NoForwarding: values.m_NoForwarding,
|
| 5153 | m_show_qrcode_flag: values.m_show_qrcode_flag
|
| 5154 | };
|
| 5155 | if (config.WIFI_WEP_SUPPORT) {
|
| 5156 | valueReq.m_DefaultKeyID = values.m_wep_default_key;
|
| 5157 | valueReq.m_Key1Str1 = values.m_wep_key_1;
|
| 5158 | valueReq.m_Key2Str1 = values.m_wep_key_2;
|
| 5159 | valueReq.m_Key3Str1 = values.m_wep_key_3;
|
| 5160 | valueReq.m_Key4Str1 = values.m_wep_key_4;
|
| 5161 | if (values.m_wep_default_key == '1') {
|
| 5162 | valueReq.m_Key2Type = values.m_WEP2Select;
|
| 5163 | } else if (values.m_wep_default_key == '2') {
|
| 5164 | valueReq.m_Key3Type = values.m_WEP3Select;
|
| 5165 | } else if (values.m_wep_default_key == '3') {
|
| 5166 | valueReq.m_Key4Type = values.m_WEP4Select;
|
| 5167 | } else {
|
| 5168 | valueReq.m_Key1Type = values.m_WEP1Select;
|
| 5169 | }
|
| 5170 | }
|
| 5171 | if (values.m_AuthMode == "WPAPSK" || values.m_AuthMode == "WPA2PSK" || values.m_AuthMode == "WPAPSKWPA2PSK" || values.m_AuthMode == "WPA3Personal" || values.m_AuthMode == "WPA2WPA3") {
|
| 5172 | valueReq.m_EncrypType = values.m_cipher;
|
| 5173 | valueReq.m_WPAPSK1 = config.PASSWORD_ENCODE ? Base64.encode(values.m_passPhrase) : values.m_passPhrase;
|
| 5174 | } else if (values.m_AuthMode == "SHARED") {
|
| 5175 | valueReq.m_EncrypType = "WEP";
|
| 5176 | valueReq.m_security_mode = "SHARED";
|
| 5177 | } else {
|
| 5178 | if (values.m_encryptType == "WEP") {
|
| 5179 | valueReq.m_EncrypType = "WEP";
|
| 5180 | valueReq.m_security_mode = "OPEN";
|
| 5181 | } else {
|
| 5182 | valueReq.m_EncrypType = "NONE";
|
| 5183 | }
|
| 5184 | }
|
| 5185 | return valueReq;
|
| 5186 | }
|
| 5187 | function deal(paramD) {
|
| 5188 | if (paramD) {
|
| 5189 | return paramD;
|
| 5190 | } else {
|
| 5191 | return errUnknownObj;
|
| 5192 | }
|
| 5193 | }
|
| 5194 | }
|
| 5195 | function getWifiBasic() {
|
| 5196 | return stuffMake(arguments, {}, prepare, deal, null, false);
|
| 5197 | function prepare(values, isPost) {
|
| 5198 | var valueReq = {};
|
| 5199 | var wpapsk = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "imei,rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";
|
| 5200 | valueReq.cmd = "m_ssid_enable,wifi_cur_state,NoForwarding,m_NoForwarding," + wpapsk + "MAX_Station_num," + "SSID1,AuthMode,HideSSID,MAX_Access_num,show_qrcode_flag,EncrypType,Key1Str1,Key2Str1,Key3Str1,Key4Str1,DefaultKeyID," + "m_SSID,m_AuthMode,m_HideSSID,m_MAX_Access_num,m_EncrypType,m_show_qrcode_flag,m_DefaultKeyID,m_Key1Str1,m_Key2Str1,m_Key3Str1,m_Key4Str1,rotationFlag,wifi_sta_connection";
|
| 5201 | valueReq.multi_data = 1;
|
| 5202 | return valueReq;
|
| 5203 | }
|
| 5204 | function deal(paramD) {
|
| 5205 | if (paramD) {
|
| 5206 | var result = {
|
| 5207 | wifi_enable: paramD.wifi_cur_state == "1" ? "1" : "0",
|
| 5208 | multi_ssid_enable: paramD.m_ssid_enable,
|
| 5209 | MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,
|
| 5210 | AuthMode: paramD.AuthMode,
|
| 5211 | SSID: paramD.SSID1,
|
| 5212 | broadcast: paramD.HideSSID,
|
| 5213 | apIsolation: paramD.NoForwarding,
|
| 5214 | passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),
|
| 5215 | MAX_Access_num: paramD.MAX_Access_num,
|
| 5216 | cipher: paramD.EncrypType == "TKIP" ? "0" : paramD.EncrypType == "AES" ? 1 : 2,
|
| 5217 | encryptType: paramD.EncrypType,
|
| 5218 | show_qrcode_flag: paramD.show_qrcode_flag == "1" ? true : false,
|
| 5219 | keyID: paramD.DefaultKeyID,
|
| 5220 | Key1Str1: paramD.Key1Str1,
|
| 5221 | Key2Str1: paramD.Key2Str1,
|
| 5222 | Key3Str1: paramD.Key3Str1,
|
| 5223 | Key4Str1: paramD.Key4Str1,
|
| 5224 | m_SSID: paramD.m_SSID,
|
| 5225 | m_broadcast: paramD.m_HideSSID,
|
| 5226 | m_apIsolation: paramD.m_NoForwarding,
|
| 5227 | m_MAX_Access_num: paramD.m_MAX_Access_num,
|
| 5228 | m_AuthMode: paramD.m_AuthMode,
|
| 5229 | m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),
|
| 5230 | m_cipher: paramD.m_EncrypType == "TKIP" ? "0" : paramD.m_EncrypType == "AES" ? 1 : 2,
|
| 5231 | m_show_qrcode_flag: paramD.m_show_qrcode_flag == "1" ? true : false,
|
| 5232 | m_encryptType: paramD.m_EncrypType,
|
| 5233 | m_keyID: paramD.m_DefaultKeyID,
|
| 5234 | m_Key1Str1: paramD.m_Key1Str1,
|
| 5235 | m_Key2Str1: paramD.m_Key2Str1,
|
| 5236 | m_Key3Str1: paramD.m_Key3Str1,
|
| 5237 | m_Key4Str1: paramD.m_Key4Str1,
|
| 5238 | rotationFlag: paramD.rotationFlag,
|
| 5239 | ap_station_enable: paramD.wifi_sta_connection
|
| 5240 | };
|
| 5241 | return result;
|
| 5242 | } else {
|
| 5243 | return errUnknownObj;
|
| 5244 | }
|
| 5245 | }
|
| 5246 | }
|
| 5247 | function setWifiBasicMultiSSIDSwitch() {
|
| 5248 | stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
|
| 5249 | function prepare(values) {
|
| 5250 | var paraTemp = values;
|
| 5251 | if (values.wifiEnabled == '0') {
|
| 5252 | paraTemp = {
|
| 5253 | wifiEnabled: values.wifiEnabled
|
| 5254 | }
|
| 5255 | }
|
| 5256 | var valueReq = $.extend({
|
| 5257 | goformId: "SET_WIFI_INFO",
|
| 5258 | }, paraTemp);
|
| 5259 | return valueReq;
|
| 5260 | }
|
| 5261 | function deal(paramD) {
|
| 5262 | if (paramD) {
|
| 5263 | return paramD;
|
| 5264 | } else {
|
| 5265 | return errUnknownObj;
|
| 5266 | }
|
| 5267 | }
|
| 5268 | }
|
| 5269 | function stuffMake(array, result, prepare, dealMethod, errorObject, isPost) {
|
| 5270 | var values = array[0],
|
| 5271 | callback = array[1],
|
| 5272 | errorCallback = array[2];
|
| 5273 | var objectToReturn;
|
| 5274 | if (result && typeof result.errorType === 'string') {
|
| 5275 | objectToReturn = $.extend(errUnknownObj, result);
|
| 5276 | if (!callback) {
|
| 5277 | return objectToReturn;
|
| 5278 | }
|
| 5279 | doCallback(objectToReturn, callback, errorCallback);
|
| 5280 | } else {
|
| 5281 | objectToReturn = $.extend({}, result);
|
| 5282 | var valueReq;
|
| 5283 | if (prepare) {
|
| 5284 | valueReq = prepare(values, isPost);
|
| 5285 | } else {
|
| 5286 | valueReq = values;
|
| 5287 | }
|
| 5288 | if (!callback) {
|
| 5289 | if (valueReq && (valueReq.cmd || valueReq.goformId)) {
|
| 5290 | var r = reqSync(valueReq, isPost);
|
| 5291 | if (dealMethod) {
|
| 5292 | objectToReturn = $.extend({}, dealMethod(r));
|
| 5293 | } else {
|
| 5294 | objectToReturn = r;
|
| 5295 | }
|
| 5296 | }
|
| 5297 | return objectToReturn;
|
| 5298 | } else {
|
| 5299 | if (valueReq && (valueReq.cmd || valueReq.goformId)) {
|
| 5300 | reqAsync(valueReq, function (paramD) {
|
| 5301 | if (dealMethod) {
|
| 5302 | objectToReturn = $.extend({}, dealMethod(paramD));
|
| 5303 | } else {
|
| 5304 | objectToReturn = $.extend({}, paramD);
|
| 5305 | }
|
| 5306 | if (!valueReq.notCallback) {
|
| 5307 | doCallback(objectToReturn, callback, errorCallback);
|
| 5308 | }
|
| 5309 | }, function () {
|
| 5310 | if (errorObject) {
|
| 5311 | objectToReturn = $.extend(errUnknownObj, errorObject);
|
| 5312 | } else {
|
| 5313 | objectToReturn = $.extend(errUnknownObj, {
|
| 5314 | errorType: 'Unknown'
|
| 5315 | });
|
| 5316 | }
|
| 5317 | doCallback(objectToReturn, callback, errorCallback);
|
| 5318 | }, isPost);
|
| 5319 | } else {
|
| 5320 | doCallback(objectToReturn, callback, errorCallback);
|
| 5321 | }
|
| 5322 | }
|
| 5323 | }
|
| 5324 | function doCallback(resultToReturn, callback, errorCallback) {
|
| 5325 | errorCallback = errorCallback ? errorCallback : callback;
|
| 5326 | if (isErrorObject(resultToReturn)) {
|
| 5327 | switch (resultToReturn.errorType) {
|
| 5328 | case 'cellularNetworkError':
|
| 5329 | case 'deviceError':
|
| 5330 | case 'wifiConnectionError':
|
| 5331 | window.receivedNonSpecificError(resultToReturn);
|
| 5332 | break;
|
| 5333 | default:
|
| 5334 | errorCallback(resultToReturn);
|
| 5335 | }
|
| 5336 | } else {
|
| 5337 | callback(resultToReturn);
|
| 5338 | }
|
| 5339 | }
|
| 5340 | }
|
| 5341 | function reqSync(values, isPost) {
|
| 5342 | return reqAJAX(values, null, null, false, isPost);
|
| 5343 | }
|
| 5344 | function reqAsync(values, successCallback, errorCallback, isPost) {
|
| 5345 | reqAJAX(values, successCallback, errorCallback, true, isPost);
|
| 5346 | }
|
| 5347 | function getString(values){
|
| 5348 | var regexp = /^[A-z0-9]+$/;
|
| 5349 | var matches = values.match(regexp);
|
| 5350 | if (matches == null){
|
| 5351 | return "error";
|
| 5352 | } else {
|
| 5353 | return values;
|
| 5354 | }
|
| 5355 | }
|
| 5356 | function reqAJAX(values, successCallback, errorCallback, async, isPost) {
|
| 5357 | var result = null;
|
| 5358 | $.ajax({
|
| 5359 | type: !!isPost ? "POST" : "GET",
|
| 5360 | url: isPost ? "/reqproc/proc_post" : values.cmd ? "/reqproc/proc_get" : "/reqproc/proc_post",
|
| 5361 | data: values,
|
| 5362 | dataType: "json",
|
| 5363 | async: !!async,
|
| 5364 | cache: false,
|
| 5365 | error: function (paramD) {
|
| 5366 | if (async) {
|
| 5367 | errorCallback(paramD);
|
| 5368 | } else if (paramD.status == 200) {
|
| 5369 | result = jQuery.parseJSON('(' + getString(paramD.responseText) + ')');
|
| 5370 | }
|
| 5371 | },
|
| 5372 | success: function (paramD) {
|
| 5373 | if (async) {
|
| 5374 | successCallback(paramD);
|
| 5375 | } else {
|
| 5376 | result = paramD;
|
| 5377 | }
|
| 5378 | }
|
| 5379 | });
|
| 5380 | if (!async) {
|
| 5381 | return result;
|
| 5382 | }
|
| 5383 | }
|
| 5384 | var informationAll = {
|
| 5385 | networkType: "",
|
| 5386 | signalImg: "0",
|
| 5387 | spn_b1_flag: "1",
|
| 5388 | spn_name_data: "",
|
| 5389 | spn_b2_flag: "1",
|
| 5390 | networkOperator: "China Mobile",
|
| 5391 | connectStatus: "ppp_disconnected",
|
| 5392 | rj45ConnectStatus: "rj45_dead",
|
| 5393 | attachedDevices: [],
|
| 5394 | ssid1AttachedNum: 0,
|
| 5395 | ssid2AttachedNum: 0,
|
| 5396 | data_counter: {
|
| 5397 | uploadRate: 0,
|
| 5398 | downloadRate: 0,
|
| 5399 | totalSent: 0,
|
| 5400 | totalReceived: 0,
|
| 5401 | totalConnectedTime: 0,
|
| 5402 | currentSent: 0,
|
| 5403 | currentReceived: 0,
|
| 5404 | currentConnectedTime: 0,
|
| 5405 | monthlySent: 0,
|
| 5406 | monthlyReceived: 0,
|
| 5407 | monthlyConnectedTime: 0,
|
| 5408 | month: ''
|
| 5409 | },
|
| 5410 | newSmsReceived: false,
|
| 5411 | smsReportReceived: false,
|
| 5412 | smsUnreadCount: "0",
|
| 5413 | isLoggedIn: undefined,
|
| 5414 | limitVolumeEnable: false,
|
| 5415 | limitVolumeType: '1',
|
| 5416 | limitVolumePercent: "100",
|
| 5417 | limitVolumeSize: "0",
|
| 5418 | allowRoamingUpdate: "0",
|
| 5419 | blc_wan_mode: "",
|
| 5420 | ap_station_enable: undefined,
|
| 5421 | ap_station_mode: undefined,
|
| 5422 | dialMode: '',
|
| 5423 | ethWanMode: 'AUTO',
|
| 5424 | fota_user_selector: '',
|
| 5425 | defaultWanName: ""
|
| 5426 | };
|
| 5427 | var errUnknownObj = {
|
| 5428 | errorType: 'UnknownError',
|
| 5429 | errorId: '123',
|
| 5430 | errorText: 'UnknownError'
|
| 5431 | };
|
| 5432 | var updateTimerFlag = true;
|
| 5433 | return {
|
| 5434 | clearRedirectFlag: clearRedirectFlag,
|
| 5435 | connect: connect,
|
| 5436 | disconnect: disconnect,
|
| 5437 | getSIMPhoneBookCapacity: getSIMPhoneBookCapacity,
|
| 5438 | getDevicePhoneBookCapacity: getDevicePhoneBookCapacity,
|
| 5439 | getDevicePhoneBooks: getDevicePhoneBooks,
|
| 5440 | getSIMPhoneBooks: getSIMPhoneBooks,
|
| 5441 | getPhoneBooks: getPhoneBooks,
|
| 5442 | getPhoneBookReady: getPhoneBookReady,
|
| 5443 | getPhoneBooksByGroup: getPhoneBooksByGroup,
|
| 5444 | deletePhoneBooks: deletePhoneBooks,
|
| 5445 | deleteAllPhoneBooks: deleteAllPhoneBooks,
|
| 5446 | deleteAllPhoneBooksByGroup: deleteAllPhoneBooksByGroup,
|
| 5447 | savePhoneBook: savePhoneBook,
|
| 5448 | deleteAllMessages: deleteAllMessages,
|
| 5449 | deleteMessage: deleteMessage,
|
| 5450 | setSmsRead: setSmsRead,
|
| 5451 | sendSMS: sendSMS,
|
| 5452 | saveSMS: saveSMS,
|
| 5453 | getSMSReady: getSMSReady,
|
| 5454 | getSMSMessages: getSMSMessages,
|
| 5455 | getSMSDeliveryReport: getSMSDeliveryReport,
|
| 5456 | getSmsCapability: getSmsCapability,
|
| 5457 | resetNewSmsReceivedVar: resetNewSmsReceivedVar,
|
| 5458 | resetSmsReportReceivedVar: resetSmsReportReceivedVar,
|
| 5459 | getSmsSetting: getSmsSetting,
|
| 5460 | setSmsSetting: setSmsSetting,
|
| 5461 | getAttachedCableDevices: getAttachedCableDevices,
|
| 5462 | getCurrentlyAttachedDevicesInfo: getCurrentlyAttachedDevicesInfo,
|
| 5463 | getConnectionInfo: getConnectionInfo,
|
| 5464 | getRedirectData: getRedirectData,
|
| 5465 | getLanguage: getLanguage,
|
| 5466 | setLanguage: setLanguage,
|
| 5467 | getNetSelectInfo: getNetSelectInfo,
|
| 5468 | getSecurityInfo: getSecurityInfo,
|
| 5469 | setSecurityInfo: setSecurityInfo,
|
| 5470 | getStatusInfo: getStatusInfo,
|
| 5471 | getConnectionMode: getConnectionMode,
|
| 5472 | setConnectionMode: setConnectionMode,
|
| 5473 | getWifiBasic: getWifiBasic,
|
| 5474 | setWifiBasic: setWifiBasic,
|
| 5475 | setWifiBasic4SSID2: setWifiBasic4SSID2,
|
| 5476 | setWifiBasicMultiSSIDSwitch: setWifiBasicMultiSSIDSwitch,
|
| 5477 | getWpsInfo: getWpsInfo,
|
| 5478 | openWps: openWps,
|
| 5479 | getSleepMode: getSleepMode,
|
| 5480 | setSleepMode: setSleepMode,
|
| 5481 | getWifiAdvance: getWifiAdvance,
|
| 5482 | setWifiAdvance: setWifiAdvance,
|
| 5483 | getWifiRange: getWifiRange,
|
| 5484 | setWifiRange: setWifiRange,
|
| 5485 |
|
| 5486 | getLoginStatus: getLoginStatus,
|
| 5487 | getLoginData: getLoginData,
|
| 5488 | login: login,
|
| 5489 | logout: logout,
|
| 5490 | changeManageInfo: changeManageInfo,
|
| 5491 | getPinData: getPinData,
|
| 5492 | enablePin: enablePin,
|
| 5493 | disablePin: disablePin,
|
| 5494 | changePin: changePin,
|
| 5495 | enterPIN: enterPIN,
|
| 5496 | enterPUK: enterPUK,
|
| 5497 | getLanInfo: getLanInfo,
|
| 5498 | setLanInfo: setLanInfo,
|
| 5499 | getApnSettings: getApnSettings,
|
| 5500 | getNetworkStatus: getNetworkStatus,
|
| 5501 | deleteApn: deleteApn,
|
| 5502 | setDefaultApn: setDefaultApn,
|
| 5503 | addOrEditApn: addOrEditApn,
|
| 5504 | getQuickSettingInfo: getQuickSettingInfo,
|
| 5505 | setQuickSetting4IPv6: setQuickSetting4IPv6,
|
| 5506 | scanForNetwork: scanForNetwork,
|
| 5507 | setBearerPreference: setBearerPreference,
|
| 5508 | editHostName: editHostName,
|
| 5509 | getSiteWhiteList: getSiteWhiteList,
|
| 5510 | removeSiteWhite: removeSiteWhite,
|
| 5511 | saveSiteWhite: saveSiteWhite,
|
| 5512 | setNetwork: setNetwork,
|
| 5513 | getUpnpSetting: getUpnpSetting,
|
| 5514 | setUpnpSetting: setUpnpSetting,
|
| 5515 | getDmzSetting: getDmzSetting,
|
| 5516 | setDmzSetting: setDmzSetting,
|
| 5517 | getDeviceInfo: getDeviceInfo,
|
| 5518 | getDeviceInfoLow: getDeviceInfoLow,
|
| 5519 | getPortForward: getPortForward,
|
| 5520 | setPortForward: setPortForward,
|
| 5521 | getPortFilter: getPortFilter,
|
| 5522 | setPortFilterBasic: setPortFilterBasic,
|
| 5523 | setPortFilter: setPortFilter,
|
| 5524 | deleteFilterRules: deleteFilterRules,
|
| 5525 | getPortMap: getPortMap,
|
| 5526 | setPortMap: setPortMap,
|
| 5527 | enablePortMap: enablePortMap,
|
| 5528 | deleteMapRules: deleteMapRules,
|
| 5529 | getTrafficAlertInfo: getTrafficAlertInfo,
|
| 5530 | setTrafficAlertInfo: setTrafficAlertInfo,
|
| 5531 | getCurrentUpgradeState: getCurrentUpgradeState,
|
| 5532 | setUpgradeSelectOp: setUpgradeSelectOp,
|
| 5533 | addTimerThings: addTimerSomething,
|
| 5534 | removeTimerThings: removeTimerSomething,
|
| 5535 | getPackSizeInfo: getPackSizeInfo,
|
| 5536 | getMandatory: getMandatory,
|
| 5537 | getOTAUpdateSetting: getOTAUpdateSetting,
|
| 5538 | setOTAUpdateSetting: setOTAUpdateSetting,
|
| 5539 | getManualOTAUpdateSetting: getManualOTAUpdateSetting,
|
| 5540 | setManualOTAUpdateSetting: setManualOTAUpdateSetting,
|
| 5541 | getSignalStrength: getSignalStrength,
|
| 5542 | getOTAlastCheckTime: getOTAlastCheckTime,
|
| 5543 | clearUpdateResult: clearUpdateResult,
|
| 5544 | refreshAPStationStatus: refreshAPStationStatus,
|
| 5545 | getSntpParams: getSntpParams,
|
| 5546 | setSntpSetting: setSntpSetting,
|
| 5547 | setSNTPDate: setSNTPDate,
|
| 5548 | restoreFactorySettings: restoreFactorySettings,
|
| 5549 | checkRestoreStatus: checkRestoreStatus,
|
| 5550 | getSysSecurity: getSysSecurity,
|
| 5551 | setSysSecurity: setSysSecurity,
|
| 5552 | deleteForwardRules: deleteForwardRules,
|
| 5553 | enableVirtualServer: enableVirtualServer,
|
| 5554 | getSDConfiguration: getSDConfiguration,
|
| 5555 | setSdCardMode: setSdCardMode,
|
| 5556 | checkFileExists: checkFileExists,
|
| 5557 | getFileList: getFileList,
|
| 5558 | fileRename: fileRename,
|
| 5559 | getSdMemorySizes: getSdMemorySizes,
|
| 5560 | deleteFilesAndFolders: deleteFilesAndFolders,
|
| 5561 | createFolder: createFolder,
|
| 5562 | setSdCardSharing: setSdCardSharing,
|
| 5563 | setUpdateInfoWarning: setUpdateInfoWarning,
|
| 5564 | getUpdateInfoWarning: getUpdateInfoWarning,
|
| 5565 | getAPStationBasic: getAPStationBasic,
|
| 5566 | setAPStationBasic: setAPStationBasic,
|
| 5567 | getWdsInfo: getWdsInfo,
|
| 5568 | setWDS: setWDS,
|
| 5569 | addUrlFilterRule: addUrlFilterRule,
|
| 5570 | getUrlFilterList: getUrlFilterList,
|
| 5571 | deleteSelectedRules: deleteSelectedRules,
|
| 5572 | getMacFilterInfo: getMacFilterInfo,
|
| 5573 | setMacFilter: setMacFilter,
|
| 5574 | getFastbootSetting: getFastbootSetting,
|
| 5575 | setFastbootSetting: setFastbootSetting,
|
| 5576 | turnOffDevice: turnOffDevice,
|
| 5577 | restart: restart,
|
| 5578 | getScheduleSetting: getScheduleSetting,
|
| 5579 | setScheduleSetting: setScheduleSetting,
|
| 5580 | getPingResult: getPingResult,
|
| 5581 | pingResultClear: pingResultClear,
|
| 5582 | getPingSetting: getPingSetting,
|
| 5583 | setPingSettingStart: setPingSettingStart,
|
| 5584 | updateTimerFlag: updateTimerFlag,
|
| 5585 | childGroupList: childGroupList,
|
| 5586 | addChildGroup: addChildGroup,
|
| 5587 | removeChildGroup: removeChildGroup,
|
| 5588 | checkCurrentUserInChildGroup: checkCurrentUserInChildGroup,
|
| 5589 | getTimeLimited: getTimeLimited,
|
| 5590 | saveTimeLimited: saveTimeLimited,
|
| 5591 | getHostNameList: getHostNameList,
|
| 5592 | getHotspotList: getHotspotList,
|
| 5593 | searchHotspot: searchHotspot,
|
| 5594 | getSearchHotspotList: getSearchHotspotList,
|
| 5595 | saveHotspot: saveHotspot,
|
| 5596 | deleteHotspot: deleteHotspot,
|
| 5597 | connectHotspot: connectHotspot,
|
| 5598 | disconnectHotspot: disconnectHotspot,
|
| 5599 | getOpMode: getOpMode,
|
| 5600 | getRj45PlugState: getRj45PlugState,
|
| 5601 | SetOperationMode: SetOperationMode,
|
| 5602 | getPppoeParams: getPppoeParams,
|
| 5603 | setPppoeDialMode: setPppoeDialMode,
|
| 5604 | getTsw: getTsw,
|
| 5605 | saveTsw: saveTsw,
|
| 5606 | trafficCalibration: trafficCalibration,
|
| 5607 | getParams: getParams,
|
| 5608 | getNewVersionState: getNewVersionState,
|
| 5609 | getUpgradeResult: getUpgradeResult,
|
| 5610 | getV4Switch: getV4Switch,
|
| 5611 | setV4Switch: setV4Switch,
|
| 5612 | getCellId: getCellId,
|
| 5613 | setCellIdSwitch: setCellIdSwitch,
|
| 5614 | getDdnsParams: getDdnsParams,
|
| 5615 | setDDNSForward: setDDNSForward,
|
| 5616 | getUpdateType: getUpdateType,
|
| 5617 | getCurretnMAC: getCurretnMAC,
|
| 5618 | getUSSDResponse: getUSSDResponse,
|
| 5619 | USSDReplyCancel: USSDReplyCancel,
|
| 5620 | getNetworkUnlockTimes: getNetworkUnlockTimes,
|
| 5621 | unlockNetwork: unlockNetwork,
|
| 5622 | getSyslogInfo: getSyslogInfo,
|
| 5623 | setSysLog: setSysLog,
|
| 5624 | };
|
| 5625 | });
|
| 5626 |
|
| 5627 | // Router����
|
| 5628 |
|
| 5629 | define("adm_lan","jquery knockout set service".split(" "),
|
| 5630 |
|
| 5631 | function ($, ko, config, service) {
|
| 5632 |
|
| 5633 | var originfrmLan = "";
|
| 5634 |
|
| 5635 | // ��ȡ·������������Ϣ
|
| 5636 | function getLanInfo() {
|
| 5637 | return service.getLanInfo();
|
| 5638 | }
|
| 5639 |
|
| 5640 | function hex(val) {
|
| 5641 | var h = (val - 0).toString(16);
|
| 5642 | if (h.length == 1)
|
| 5643 | h = '0' + h;
|
| 5644 | return h.toUpperCase();
|
| 5645 | }
|
| 5646 |
|
| 5647 | function LanViewModel() {
|
| 5648 | var target = this;
|
| 5649 |
|
| 5650 | var info = getLanInfo();
|
| 5651 |
|
| 5652 | target.dhcpStart = ko.observable(info.dhcpStart);
|
| 5653 | target.dhcpEnd = ko.observable(info.dhcpEnd);
|
| 5654 | target.dhcpLease = ko.observable(info.dhcpLease);
|
| 5655 |
|
| 5656 | target.ipAddress = ko.observable(info.ipAddress);
|
| 5657 | target.subnetMask = ko.observable(info.subnetMask);
|
| 5658 | target.dhcpServer = ko.observable(info.dhcpServer);
|
| 5659 |
|
| 5660 | target.macAddress = ko.observable(info.macAddress);
|
| 5661 | target.showMacAddress = ko.observable(config.SHOW_MAC_ADDRESS);
|
| 5662 |
|
| 5663 | target.hasWifi = ko.observable(config.HAS_WIFI);
|
| 5664 | target.hasUssd = config.HAS_USSD;
|
| 5665 | target.hasDdns = config.DDNS_SUPPORT;
|
| 5666 |
|
| 5667 | target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
|
| 5668 |
|
| 5669 | target.clear = function () {
|
| 5670 | clearTimer();
|
| 5671 | init();
|
| 5672 | clearValidateMsg();
|
| 5673 | };
|
| 5674 |
|
| 5675 | target.refreshStatus = function () {
|
| 5676 | var connInfo = service.getConnectionInfo();
|
| 5677 | if (connInfo.connectStatus == 'ppp_disconnected') {
|
| 5678 | $('input', '#frmLan').each(function () {
|
| 5679 | $(this).attr("disabled", false);
|
| 5680 | });
|
| 5681 | } else {
|
| 5682 | $('input', '#frmLan').each(function () {
|
| 5683 | $(this).attr("disabled", true);
|
| 5684 | });
|
| 5685 |
|
| 5686 | clearValidateMsg();
|
| 5687 | }
|
| 5688 | };
|
| 5689 |
|
| 5690 | // ������Ӧ�������������ñ���
|
| 5691 | target.saveAct = function () {
|
| 5692 | showLoading();
|
| 5693 | var params = {
|
| 5694 | ipAddress: target.ipAddress(),
|
| 5695 | subnetMask: target.subnetMask(),
|
| 5696 | dhcpServer: target.dhcpServer(),
|
| 5697 | dhcpStart: target.dhcpStart(),
|
| 5698 | dhcpEnd: target.dhcpEnd(),
|
| 5699 | dhcpLease: target.dhcpLease()
|
| 5700 | };
|
| 5701 |
|
| 5702 | service.setLanInfo(params, function (result) {
|
| 5703 | if (result.result == "success") {
|
| 5704 | successOverlay();
|
| 5705 | target.clear();
|
| 5706 | } else {
|
| 5707 | errorOverlay();
|
| 5708 | }
|
| 5709 | });
|
| 5710 | };
|
| 5711 |
|
| 5712 | // ������Ӧ�������������ñ���
|
| 5713 | target.save = function () {
|
| 5714 | var frmLanObj = $('#frmLan').serialize();
|
| 5715 | if (frmLanObj == originfrmLan) {
|
| 5716 | showAlert("setting_no_change");
|
| 5717 | return false;
|
| 5718 | }
|
| 5719 | if (config.RJ45_SUPPORT) {
|
| 5720 | var pppObj = service.getPppoeParams();
|
| 5721 | if (sf_isValidate_StaticIP(pppObj.static_wan_ipaddr, target.ipAddress(), target.subnetMask())) {
|
| 5722 | showAlert("lan_tip_staticip_notsame");
|
| 5723 | return false;
|
| 5724 | }
|
| 5725 | }
|
| 5726 | showConfirm("lan_confirm_reopen", function () {
|
| 5727 | target.saveAct();
|
| 5728 | });
|
| 5729 | };
|
| 5730 |
|
| 5731 | target.refreshStatus();
|
| 5732 | // dhcpServer�л���Ӧ����
|
| 5733 | target.dhcpServerHandler = function () {
|
| 5734 | $("#txtIpAddress").parent().find(".error").hide();
|
| 5735 | $("#txtIpAddress").show();
|
| 5736 | return true;
|
| 5737 | };
|
| 5738 | addTimeout(function () {
|
| 5739 | originfrmLan = $('#frmLan').serialize();
|
| 5740 | }, 500);
|
| 5741 | }
|
| 5742 |
|
| 5743 |
|
| 5744 | function sf_opAnd4Byte(i_v1, i_v2) {
|
| 5745 | var index;
|
| 5746 | var var1 = [];
|
| 5747 | var var2 = [];
|
| 5748 | var result='0x';
|
| 5749 |
|
| 5750 | for (index=2,index_tmp=0; index<10; index+=2,index_tmp++) {
|
| 5751 | var1[index_tmp]='0x'+i_v1.substring(index,index+2);
|
| 5752 | var2[index_tmp]='0x'+i_v2.substring(index,index+2);
|
| 5753 | }
|
| 5754 |
|
| 5755 | for (index=0; index<4; index++) {
|
| 5756 | result = result + hex(var1[index]&var2[index]);
|
| 5757 | }
|
| 5758 |
|
| 5759 | return result - 0;
|
| 5760 | }
|
| 5761 |
|
| 5762 | // �������ر���У������
|
| 5763 | $.validator.addMethod("dhcp_check", function (i_value, i_element, i_parameter) {
|
| 5764 | var dhcpIp = i_parameter == "start" ? $('#txtDhcpIpPoolStart').val() : $('#txtDhcpIpPoolEnd').val();
|
| 5765 | var result = sf_isValidate_Gateway($('#txtIpAddress').val(), $('#txtSubnetMask').val(), dhcpIp);
|
| 5766 | return this.optional(i_element) || result;
|
| 5767 | });
|
| 5768 |
|
| 5769 | $.validator.addMethod("dhcpCompare", function (i_value, i_element, i_parameter) {
|
| 5770 | var result;
|
| 5771 | if(i_parameter == "#txtDhcpIpPoolStart") {
|
| 5772 | result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), $(i_parameter).val(), i_value);
|
| 5773 | }
|
| 5774 | else {
|
| 5775 | result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), i_value, $(i_parameter).val());
|
| 5776 | }
|
| 5777 | return result != 1;
|
| 5778 | });
|
| 5779 |
|
| 5780 | $.validator.addMethod("ipRange", function (i_value, i_element, i_parameter) {
|
| 5781 | var DHCP_flag = false;
|
| 5782 | if($('#dhcpEnable').is(':checked')){
|
| 5783 | DHCP_flag = true;
|
| 5784 | }
|
| 5785 | var result = sf_isValidate_StartEndIp(i_value, $('#txtSubnetMask').val(), $('#txtDhcpIpPoolStart').val(), $('#txtDhcpIpPoolEnd').val(), DHCP_flag);
|
| 5786 | return result != 2;
|
| 5787 | });
|
| 5788 |
|
| 5789 | $.validator.addMethod("subnetmask_check", function (i_value, i_element, i_parameter) {
|
| 5790 | var result = sf_isValidate_Netmask(i_value);
|
| 5791 | return this.optional(i_element) || result;
|
| 5792 | });
|
| 5793 |
|
| 5794 |
|
| 5795 | // ��̬��ЧIPУ�麯��
|
| 5796 | function sf_isValidate_StaticIP(i_ip, i_lanIp, i_lanMask){
|
| 5797 | if(!i_ip || !i_lanIp || !i_lanMask){//������������
|
| 5798 | return false;
|
| 5799 | }
|
| 5800 |
|
| 5801 | //������IP����
|
| 5802 | if (i_ip == i_lanIp) {
|
| 5803 | return true;
|
| 5804 | }
|
| 5805 |
|
| 5806 | var res1 = [];
|
| 5807 | var res2 = [];
|
| 5808 |
|
| 5809 | var mask_array = [];
|
| 5810 |
|
| 5811 | ip_array = i_ip.split(".");
|
| 5812 | lanIp_array = i_lanIp.split(".");
|
| 5813 | mask_array = i_lanMask.split(".");
|
| 5814 | for(var index = 0; index < ip_array.length; index += 1){
|
| 5815 | res1.push(parseInt(mask_array[index]) & parseInt(ip_array[index]));
|
| 5816 | res2.push(parseInt(mask_array[index]) & parseInt(lanIp_array[index]));
|
| 5817 | }
|
| 5818 | if(res2.join(".") != res1.join(".")){//�ڲ�ͬ����
|
| 5819 | return false;
|
| 5820 | }else{//��ͬһ����
|
| 5821 | return true;
|
| 5822 | }
|
| 5823 | }
|
| 5824 |
|
| 5825 |
|
| 5826 | function sf_isValidate_NetmaskIP(i_ip) {
|
| 5827 | return (i_ip == 255
|
| 5828 | || i_ip == 254
|
| 5829 | || i_ip == 252
|
| 5830 | || i_ip == 248
|
| 5831 | || i_ip == 240
|
| 5832 | || i_ip == 224
|
| 5833 | || i_ip == 192
|
| 5834 | || i_ip == 128
|
| 5835 | || i_ip == 0);
|
| 5836 | }
|
| 5837 |
|
| 5838 | function sf_convertIpToString(i_ip)
|
| 5839 | {
|
| 5840 | var s_i1 = i_ip.indexOf('.');
|
| 5841 | var s_i2 = i_ip.indexOf('.', (s_i1 + 1));
|
| 5842 | var s_i3 = i_ip.indexOf('.', (s_i2 + 1));
|
| 5843 | o_ip = hex(i_ip.substring(0, s_i1)) + hex(i_ip.substring((s_i1 + 1), s_i2)) + hex(i_ip.substring((s_i2 + 1), s_i3)) + hex(i_ip.substring((s_i3 + 1), i_ip.length));
|
| 5844 | o_ip = '0x' + o_ip;
|
| 5845 |
|
| 5846 | return o_ip;
|
| 5847 | }
|
| 5848 |
|
| 5849 | function sf_getIpString_3(i_ip)
|
| 5850 | {
|
| 5851 | var i1 = i_ip.indexOf('.');
|
| 5852 | var i2 = i_ip.indexOf('.', (i1 + 1));
|
| 5853 | var i3 = i_ip.indexOf('.', (i2 + 1));
|
| 5854 | var i4 = i_ip.substring((i3+1),i_ip.length)-0;
|
| 5855 |
|
| 5856 | return i4;
|
| 5857 | }
|
| 5858 |
|
| 5859 |
|
| 5860 | // ����У�麯��
|
| 5861 | function sf_isValidate_Gateway(i_wanIp, i_netmaskIp, i_gatewayIp) {
|
| 5862 | var s_wanIp = sf_convertIpToString(i_wanIp);
|
| 5863 | var lan4 = sf_getIpString_3(i_wanIp);
|
| 5864 |
|
| 5865 | var s_netmaskIp = sf_convertIpToString(i_netmaskIp);
|
| 5866 | var mask4 = sf_getIpString_3(i_netmaskIp);
|
| 5867 |
|
| 5868 | var s_gatewayIp = sf_convertIpToString(i_gatewayIp);
|
| 5869 | var pool4 = sf_getIpString_3(i_gatewayIp);
|
| 5870 |
|
| 5871 | var net_no;
|
| 5872 | var lo_broadcast;
|
| 5873 |
|
| 5874 | if (sf_opAnd4Byte(s_wanIp, s_netmaskIp) != sf_opAnd4Byte(s_gatewayIp, s_netmaskIp)) {
|
| 5875 | return false;
|
| 5876 | }
|
| 5877 |
|
| 5878 | net_no = (lan4 & mask4);
|
| 5879 | lo_broadcast = (lan4 & mask4) + (255-mask4);
|
| 5880 |
|
| 5881 | return !(pool4==net_no || pool4==lo_broadcast);
|
| 5882 |
|
| 5883 | }
|
| 5884 |
|
| 5885 | // ��������У�麯��
|
| 5886 | function sf_isValidate_Netmask(i_netmask) {
|
| 5887 | var addr = i_netmask.split(".");
|
| 5888 |
|
| 5889 | if ("0.0.0.0" == i_netmask || "255.255.255.255" == i_netmask) {
|
| 5890 | return false;
|
| 5891 | }
|
| 5892 |
|
| 5893 | if (addr.length != 4) {
|
| 5894 | return false;
|
| 5895 | }
|
| 5896 |
|
| 5897 | addr[0] = parseInt(addr[0]);
|
| 5898 | addr[1] = parseInt(addr[1]);
|
| 5899 | addr[2] = parseInt(addr[2]);
|
| 5900 | addr[3] = parseInt(addr[3]);
|
| 5901 |
|
| 5902 | if (addr[3] != 0) {
|
| 5903 | if (addr[0] != 255 || addr[1] != 255 || addr[2] != 255) {
|
| 5904 | return false;
|
| 5905 | } else {
|
| 5906 | if (!sf_isValidate_NetmaskIP(addr[3])) {
|
| 5907 | return false;
|
| 5908 | }
|
| 5909 | }
|
| 5910 | }
|
| 5911 |
|
| 5912 | if (addr[2] != 0) {
|
| 5913 | if (addr[0] != 255 || addr[1] != 255) {
|
| 5914 | return false;
|
| 5915 | } else {
|
| 5916 | if (!sf_isValidate_NetmaskIP(addr[2])) {
|
| 5917 | return false;
|
| 5918 | }
|
| 5919 | }
|
| 5920 | }
|
| 5921 |
|
| 5922 | if (addr[1] != 0) {
|
| 5923 | if (addr[0] != 255) {
|
| 5924 | return false;
|
| 5925 | } else {
|
| 5926 | if (!sf_isValidate_NetmaskIP(addr[1])) {
|
| 5927 | return false;
|
| 5928 | }
|
| 5929 | }
|
| 5930 | }
|
| 5931 |
|
| 5932 | if (addr[0] != 255) {
|
| 5933 | return false;
|
| 5934 | }
|
| 5935 |
|
| 5936 | return true;
|
| 5937 | }
|
| 5938 |
|
| 5939 | // DHCP IP��У�麯��
|
| 5940 | function sf_isValidate_StartEndIp(i_lanIpaddr, i_netIp, i_startIp, i_endIp, i_DHCPFlag) {
|
| 5941 | s_startIp = sf_convertIpToString(i_startIp);
|
| 5942 | s_endIp = sf_convertIpToString(i_endIp);
|
| 5943 | s_lanIp = sf_convertIpToString(i_lanIpaddr);
|
| 5944 |
|
| 5945 | if(s_startIp>s_endIp) {
|
| 5946 | return 1;
|
| 5947 | }
|
| 5948 |
|
| 5949 | if(s_lanIp >= s_startIp && s_lanIp <= s_endIp) {
|
| 5950 | return 2;
|
| 5951 | }
|
| 5952 |
|
| 5953 | return 0;
|
| 5954 | }
|
| 5955 |
|
| 5956 |
|
| 5957 | function init() {
|
| 5958 | var container = $('#container');
|
| 5959 | ko.cleanNode(container[0]);
|
| 5960 | var fwVm = new LanViewModel();
|
| 5961 | ko.applyBindings(fwVm, container[0]);
|
| 5962 |
|
| 5963 | addInterval(fwVm.refreshStatus, 1000);
|
| 5964 |
|
| 5965 | $('#frmLan').validate({
|
| 5966 | submitHandler:function () {
|
| 5967 | fwVm.save();
|
| 5968 | },
|
| 5969 |
|
| 5970 | rules:{
|
| 5971 | txtIpAddress: {
|
| 5972 | lanip_check: true,
|
| 5973 | ipRange: true
|
| 5974 | },
|
| 5975 | txtSubnetMask: {
|
| 5976 | ipv4: true,
|
| 5977 | subnetmask_check: true
|
| 5978 | },
|
| 5979 | txtDhcpIpPoolStart: {
|
| 5980 | lanip_check: true,
|
| 5981 | dhcp_check: "start",
|
| 5982 | dhcpCompare: "#txtDhcpIpPoolEnd"
|
| 5983 | },
|
| 5984 | txtDhcpIpPoolEnd: {
|
| 5985 | lanip_check: true,
|
| 5986 | dhcp_check: "end",
|
| 5987 | dhcpCompare: "#txtDhcpIpPoolStart"
|
| 5988 | },
|
| 5989 | txtDhcpLease: {
|
| 5990 | range: [1, 65535],
|
| 5991 | digits: true
|
| 5992 | }
|
| 5993 | },
|
| 5994 |
|
| 5995 | groups: {
|
| 5996 | lanip_check: "txtDhcpIpPoolStart txtDhcpIpPoolEnd"
|
| 5997 | },
|
| 5998 |
|
| 5999 | errorPlacement: function (error, element) {
|
| 6000 | if (element.attr("name") == "txtDhcpLease") {
|
| 6001 | error.insertAfter("#errorHolder");
|
| 6002 | } else if (element.attr("name") == "txtDhcpIpPoolStart") {
|
| 6003 | error.insertAfter("#txtDhcpIpPoolEnd");
|
| 6004 | } else {
|
| 6005 | error.insertAfter(element);
|
| 6006 | }
|
| 6007 | }
|
| 6008 | });
|
| 6009 |
|
| 6010 | }
|
| 6011 |
|
| 6012 |
|
| 6013 | return {
|
| 6014 | init:init
|
| 6015 | }
|
| 6016 | });
|
| 6017 |
|
| 6018 | // others �����:Fast Boot Settings��Restart and Reset��SNTP��Turn Off Device��PIN Management
|
| 6019 | define("adm_others","jquery knockout set service underscore".split(" "),
|
| 6020 |
|
| 6021 | function ($, ko, config, service, _) {
|
| 6022 |
|
| 6023 | var timeSetModes = _.map(config.sntpTimeSetMode, function(item) {
|
| 6024 | return new Option(item.name, item.value);
|
| 6025 | });
|
| 6026 |
|
| 6027 | var timeZones = _.map(config.timeZone, function(item){
|
| 6028 | return new Option(item.name, item.value);
|
| 6029 | });
|
| 6030 |
|
| 6031 | var daylightSave = _.map(config.daylightSave, function(item){
|
| 6032 | return new Option(item.name, item.value);
|
| 6033 | });
|
| 6034 |
|
| 6035 | var sv_sntpYears = [];
|
| 6036 | var sv_sntpMonths = [];
|
| 6037 | var sv_sntpDates = []; //���ݴ�С����������
|
| 6038 | var sv_sntpHours = [];
|
| 6039 | var sv_sntpMinutes = [];
|
| 6040 | var sc_startpHours = [];
|
| 6041 | var sc_startMinutes = [];
|
| 6042 | var sc_pingTimes = [];
|
| 6043 |
|
| 6044 | var sf_bigMonth = [1, 3, 5, 7, 8, 10, 12];
|
| 6045 | var sf_smallMonth = [4, 6, 9, 11];
|
| 6046 |
|
| 6047 | function sf_produceArray(start, end, arryName) {
|
| 6048 | var item = {};
|
| 6049 | for(var i = start; i <= end; i++) {
|
| 6050 | item.name = i;
|
| 6051 | item.value = i;
|
| 6052 | arryName.push(new Option(item.name, item.value));
|
| 6053 | }
|
| 6054 | }
|
| 6055 |
|
| 6056 | //�����ꡢ�¡�ʱ���ֵ�����
|
| 6057 | sf_produceArray(2000, 2030, sv_sntpYears);
|
| 6058 | sf_produceArray(1, 12, sv_sntpMonths);
|
| 6059 | sf_produceArray(0, 23, sv_sntpHours);
|
| 6060 | sf_produceArray(0, 59, sv_sntpMinutes);
|
| 6061 | sf_produceArray(0, 23, sc_startpHours);
|
| 6062 | sf_produceArray(0, 59, sc_startMinutes);
|
| 6063 | sf_produceArray(0, 59, sc_startMinutes);
|
| 6064 | sf_produceArray(1, 10, sc_pingTimes);
|
| 6065 |
|
| 6066 | function othersViewModel() {
|
| 6067 | var target = this;
|
| 6068 |
|
| 6069 | var inChildGroup = false;
|
| 6070 | var scheduleInfo = service.getScheduleSetting();
|
| 6071 | var pingDiagInfo = service.getPingSetting();
|
| 6072 |
|
| 6073 | target.fastbootSupport = config.FAST_BOOT_SUPPORT;
|
| 6074 | target.turnOffSupport = config.TURN_OFF_SUPPORT;
|
| 6075 | target.SNTPSupport = config.HAS_SNTP;
|
| 6076 | target.hasUssd = config.HAS_USSD;
|
| 6077 | target.hasDdns = config.DDNS_SUPPORT;
|
| 6078 | target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
|
| 6079 | target.scheduleSetting = ko.observable(scheduleInfo.scheduleSetting);
|
| 6080 | target.scheduleHour = ko.observable(parseInt(scheduleInfo.scheduleHour));
|
| 6081 | target.scheduleMinute = ko.observable(parseInt(scheduleInfo.scheduleMinute));
|
| 6082 | target.scr_hours = ko.observableArray(sc_startpHours);
|
| 6083 | target.scr_minutes = ko.observableArray(sc_startMinutes);
|
| 6084 | target.src_times = ko.observableArray(sc_pingTimes);
|
| 6085 | target.pingTimes = ko.observable(pingDiagInfo.pingTimes);
|
| 6086 | target.pingURL = ko.observable(pingDiagInfo.pingURL);
|
| 6087 |
|
| 6088 |
|
| 6089 | if (config.HAS_PARENTAL_CONTROL) {
|
| 6090 | inChildGroup = service.checkCurrentUserInChildGroup().result;
|
| 6091 | }
|
| 6092 | target.currentUserInChildGroup = ko.observable(inChildGroup);
|
| 6093 |
|
| 6094 | var sv_fastbootInfo = service.getFastbootSetting();
|
| 6095 | target.fastbootEnableFlag = ko.observable(config.RJ45_SUPPORT ? (sv_fastbootInfo.need_sim_pin != "yes" && service.getRj45PlugState().rj45_plug == "wan_lan_off") : sv_fastbootInfo.need_sim_pin != "yes");
|
| 6096 | target.fastbootSetting = ko.observable(sv_fastbootInfo.fastbootEnabled);
|
| 6097 |
|
| 6098 |
|
| 6099 | // @method addInterval
|
| 6100 | addInterval(function(){
|
| 6101 | target.fastbootEnableFlag(config.RJ45_SUPPORT ? (sv_fastbootInfo.need_sim_pin != "yes" && service.getRj45PlugState().rj45_plug == "wan_lan_off") : sv_fastbootInfo.need_sim_pin != "yes");
|
| 6102 | }, 1000);
|
| 6103 |
|
| 6104 | // �ָ���������
|
| 6105 | // @event restore
|
| 6106 | target.restore = function () {
|
| 6107 | showConfirm("restore_confirm", function () {
|
| 6108 | showLoading("restoring");
|
| 6109 | service.restoreFactorySettings({}, function (info) {
|
| 6110 | if (info && info.result == "success") {
|
| 6111 | successOverlay();
|
| 6112 | } else {
|
| 6113 | errorOverlay();
|
| 6114 | }
|
| 6115 | }, function (result) {
|
| 6116 | if (isErrorObject(result) && result.errorType == 'no_auth') {
|
| 6117 | errorOverlay();
|
| 6118 | }
|
| 6119 | });
|
| 6120 | });
|
| 6121 | };
|
| 6122 |
|
| 6123 | target.restart = function () {
|
| 6124 | showConfirm("restart_confirm", function () {
|
| 6125 | restartDevice(service);
|
| 6126 | });
|
| 6127 | };
|
| 6128 |
|
| 6129 | target.scheduleRestart = function () {
|
| 6130 | showLoading();
|
| 6131 | var params = {};
|
| 6132 | params.scheduleSetting = target.scheduleSetting();
|
| 6133 | params.scheduleHour = target.scheduleHour();
|
| 6134 | params.scheduleMinute = target.scheduleMinute();
|
| 6135 | service.setScheduleSetting(params, function (result) {
|
| 6136 | if (result.result != "success") {
|
| 6137 | errorOverlay();
|
| 6138 | } else {
|
| 6139 | successOverlay();
|
| 6140 | }
|
| 6141 | });
|
| 6142 | };
|
| 6143 |
|
| 6144 | target.pingResult = ko.observable();
|
| 6145 |
|
| 6146 | target.loadFileContent = function() {
|
| 6147 | var newPingResInfo = service.getPingResult();
|
| 6148 | if (newPingResInfo.pingResult !== target.pingResult()) {
|
| 6149 | target.pingResult(newPingResInfo.pingResult);
|
| 6150 | }
|
| 6151 | };
|
| 6152 |
|
| 6153 | function showinfo(msgObj, minHeight) {
|
| 6154 | var option = {
|
| 6155 | title: 'info',
|
| 6156 | img: 'pic/res_info.png',
|
| 6157 | msg: msgObj,
|
| 6158 | minHeight: minHeight
|
| 6159 | };
|
| 6160 | popup(option);
|
| 6161 |
|
| 6162 | $('#yesbtn, #nobtn, #okbtn').hide();
|
| 6163 |
|
| 6164 | setTimeout(function() {
|
| 6165 | $.modal.close();
|
| 6166 | }, 1000);
|
| 6167 | }
|
| 6168 |
|
| 6169 | setInterval(target.loadFileContent, 1000);
|
| 6170 |
|
| 6171 | target.pingStart = function () {
|
| 6172 | showinfo('ping_starting');
|
| 6173 | var params = {};
|
| 6174 | params.pingTimes = target.pingTimes();
|
| 6175 | params.pingURL = target.pingURL();
|
| 6176 | service.setPingSettingStart(params, function (result) {
|
| 6177 | if (result.result != "success") {
|
| 6178 | errorOverlay();
|
| 6179 | }
|
| 6180 | });
|
| 6181 | };
|
| 6182 |
|
| 6183 | target.pingClear = function () {
|
| 6184 | showLoading();
|
| 6185 | service.pingResultClear({}, function (result) {
|
| 6186 | if (result.result != "success") {
|
| 6187 | errorOverlay();
|
| 6188 | } else {
|
| 6189 | successOverlay();
|
| 6190 | }
|
| 6191 | });
|
| 6192 | };
|
| 6193 |
|
| 6194 | // ���ٿ��ػ�����
|
| 6195 | target.saveFastBoot = function() {
|
| 6196 | showLoading();
|
| 6197 | var params = {
|
| 6198 | fastbootEnabled: target.fastbootSetting(),
|
| 6199 | need_hard_reboot: sv_fastbootInfo.need_hard_reboot
|
| 6200 | };
|
| 6201 | service.setFastbootSetting(params, function(result) {
|
| 6202 | if (result.result == "success") {
|
| 6203 | successOverlay();
|
| 6204 | } else {
|
| 6205 | errorOverlay();
|
| 6206 | }
|
| 6207 | });
|
| 6208 | };
|
| 6209 |
|
| 6210 | // �ػ�
|
| 6211 | target.turnoff = function () {
|
| 6212 | showConfirm("turnoff_confirm", function () {
|
| 6213 | showLoading("turnoff");
|
| 6214 | service.turnOffDevice({}, function (info) {
|
| 6215 | if (info && info.result == "success") {
|
| 6216 | successOverlay();
|
| 6217 | } else {
|
| 6218 | errorOverlay();
|
| 6219 | }
|
| 6220 | }, $.noop);
|
| 6221 | });
|
| 6222 | };
|
| 6223 |
|
| 6224 | //SNTP����serverУ׼ʱ��
|
| 6225 | service.setSNTPDate({
|
| 6226 | goformId: "SNTP_Getdatastatic"
|
| 6227 | });
|
| 6228 |
|
| 6229 | var target = this;
|
| 6230 | var sntpInfo = service.getSntpParams();
|
| 6231 |
|
| 6232 | globalTime = new Date(parseInt(sntpInfo.sntp_year, 10),parseInt(sntpInfo.sntp_month, 10)-1, parseInt(sntpInfo.sntp_day, 10), parseInt(sntpInfo.sntp_hour, 10), parseInt(sntpInfo.sntp_minute, 10), parseInt(sntpInfo.sntp_second, 10));
|
| 6233 |
|
| 6234 | target.day = ko.observable();
|
| 6235 | target.localTime = ko.observable();
|
| 6236 |
|
| 6237 | //��ʼ����ǰ����ʱ��
|
| 6238 | //target.updateCurrentTime; cov_2
|
| 6239 | target.timeSetModes = ko.observableArray(timeSetModes);
|
| 6240 | target.isManualSetTime = ko.observable(false);
|
| 6241 | target.isAutoSntpTime = ko.observable(false);
|
| 6242 |
|
| 6243 | target.currentMode = ko.observable(sntpInfo.sntp_time_set_mode);
|
| 6244 |
|
| 6245 | changeSetTimeMode();
|
| 6246 | target.changeSetTimeMode = function(){
|
| 6247 | changeSetTimeMode();
|
| 6248 | };
|
| 6249 |
|
| 6250 | target.currentYear = ko.observable(parseInt(sntpInfo.sntp_year, 10));
|
| 6251 | target.currentMonth = ko.observable(parseInt(sntpInfo.sntp_month, 10));
|
| 6252 | target.currentDate = ko.observable(parseInt(sntpInfo.sntp_day, 10));
|
| 6253 | target.currentHour = ko.observable(parseInt(sntpInfo.sntp_hour, 10));
|
| 6254 | target.currentMinute = ko.observable(parseInt(sntpInfo.sntp_minute, 10));
|
| 6255 |
|
| 6256 |
|
| 6257 | // ��Ҫ��������ˢ�������б����ݣ�ע��˳��
|
| 6258 |
|
| 6259 | target.years = ko.observableArray(sv_sntpYears);
|
| 6260 | target.months = ko.observableArray(sv_sntpMonths);
|
| 6261 | //���û�ѡ���·ݵ�ʱ���ı�����ѡ������ѡ��
|
| 6262 | target.initDateList = function(){
|
| 6263 | initDateList();
|
| 6264 | target.dates(sv_sntpDates);
|
| 6265 | }
|
| 6266 |
|
| 6267 | //��ʼ�������б�
|
| 6268 | initDateList();
|
| 6269 | target.dates = ko.observableArray(sv_sntpDates);
|
| 6270 | target.hours = ko.observableArray(sv_sntpHours);
|
| 6271 | target.minutes = ko.observableArray(sv_sntpMinutes);
|
| 6272 |
|
| 6273 | //�Զ�SNTP��ȡʱ�����ݰ󶨴���
|
| 6274 | var serverArray = _.map(sntpInfo.sntp_servers, function(item) {
|
| 6275 | return new Option(item.name, item.value)
|
| 6276 | });
|
| 6277 |
|
| 6278 | target.serverList = ko.observableArray(serverArray);
|
| 6279 |
|
| 6280 | // �������ֲ����޸ģ��޸��޷�ˢ����ҳ
|
| 6281 |
|
| 6282 | target.currentServer0 = ko.observable(sntpInfo.sntp_server0);
|
| 6283 | target.currentServer1 = ko.observable(sntpInfo.sntp_server1);
|
| 6284 | target.currentServer2 = ko.observable(sntpInfo.sntp_server2);
|
| 6285 | target.customServer0 = ko.observable(sntpInfo.sntp_other_server0);
|
| 6286 | target.customServer1 = ko.observable(sntpInfo.sntp_other_server1);
|
| 6287 | target.customServer2 = ko.observable(sntpInfo.sntp_other_server2);
|
| 6288 | target.isOther0 = ko.observable(false);
|
| 6289 | target.isOther1 = ko.observable(false);
|
| 6290 | target.isOther2 = ko.observable(false);
|
| 6291 |
|
| 6292 | initOtherServer();
|
| 6293 |
|
| 6294 | target.changeServerSelect = function(){
|
| 6295 | initOtherServer();
|
| 6296 | }
|
| 6297 |
|
| 6298 | target.timeZones = ko.observableArray(timeZones);
|
| 6299 | target.currentTimeZone = ko.observable(sntpInfo.sntp_timezone + "_" + sntpInfo.sntp_timezone_index);
|
| 6300 | target.daylightSaves = ko.observableArray(daylightSave);
|
| 6301 | target.currentDaylightSave = ko.observable(sntpInfo.sntp_dst_enable);
|
| 6302 |
|
| 6303 | //���µ�ǰ��ʾʱ��
|
| 6304 | target.updateCurrentTime = function() {
|
| 6305 | var globalDay = globalTime.getDay();
|
| 6306 |
|
| 6307 | switch(globalDay){
|
| 6308 | case 6:
|
| 6309 | target.day($.i18n.prop("saturday"));
|
| 6310 | break;
|
| 6311 | case 5:
|
| 6312 | target.day($.i18n.prop("friday"));
|
| 6313 | break;
|
| 6314 | case 4:
|
| 6315 | target.day($.i18n.prop("thursday"));
|
| 6316 | break;
|
| 6317 | case 3:
|
| 6318 | target.day($.i18n.prop("wednesday"));
|
| 6319 | break;
|
| 6320 | case 2:
|
| 6321 | target.day($.i18n.prop("tuesday"));
|
| 6322 | break;
|
| 6323 | case 1:
|
| 6324 | target.day($.i18n.prop("monday"));
|
| 6325 | break;
|
| 6326 | case 0:
|
| 6327 | target.day($.i18n.prop("sunday"));
|
| 6328 | break;
|
| 6329 | default:
|
| 6330 | break;
|
| 6331 | }
|
| 6332 |
|
| 6333 | var localCurrentTime = globalTime.getFullYear() + "-" + getTwoDigit(globalTime.getMonth()+1) + "-" + getTwoDigit(globalTime.getDate()) + " " + getTwoDigit(globalTime.getHours()) + ":" + getTwoDigit(globalTime.getMinutes()) + ":" + getTwoDigit(globalTime.getSeconds());
|
| 6334 | target.localTime(localCurrentTime);
|
| 6335 | globalTime.setTime(globalTime.getTime()+1000);
|
| 6336 | };
|
| 6337 |
|
| 6338 | // SNTP����
|
| 6339 | target.apply = function(){
|
| 6340 | var tmpArray = [];
|
| 6341 | for(var i=0; i< sntpInfo.sntp_servers.length; i++){
|
| 6342 | tmpArray.push(sntpInfo.sntp_servers[i].value);
|
| 6343 | }
|
| 6344 | var staInfo = service.getStatusInfo();
|
| 6345 | if(!checkConnectedStatus(staInfo.connectStatus, staInfo.rj45ConnectStatus, staInfo.connectWifiStatus) && target.currentMode() == "auto"){
|
| 6346 | showAlert("sntp_syn_time_wan_connected");
|
| 6347 | return;
|
| 6348 | }
|
| 6349 |
|
| 6350 | showLoading("");
|
| 6351 | var requestParams = {
|
| 6352 | goformId: "SNTP",
|
| 6353 | manualsettime : target.currentMode(),
|
| 6354 | sntp_server1_ip : target.currentServer0(),
|
| 6355 | sntp_server2_ip : target.currentServer1(),
|
| 6356 | sntp_server3_ip : target.currentServer2(),
|
| 6357 | sntp_other_server0 : target.customServer0(),
|
| 6358 | sntp_other_server1 : target.customServer1(),
|
| 6359 | sntp_other_server2 : target.customServer2(),
|
| 6360 | timezone : target.currentTimeZone().split("_")[0],
|
| 6361 | sntp_timezone_index : target.currentTimeZone().split("_")[1],
|
| 6362 | DaylightEnabled : target.currentDaylightSave(),
|
| 6363 | time_year : target.currentYear(),
|
| 6364 | time_month : target.currentMonth(),
|
| 6365 | time_day : target.currentDate(),
|
| 6366 | time_hour : target.currentHour(),
|
| 6367 | time_minute : target.currentMinute()
|
| 6368 | };
|
| 6369 |
|
| 6370 | service.setSntpSetting(requestParams, function(data2){
|
| 6371 | if(data2) {
|
| 6372 | if(data2.result == "success" && target.currentMode() == "auto"){
|
| 6373 | successOverlay("sntp_req_success");
|
| 6374 | //hideLoading();
|
| 6375 | }else if(data2.result == "processing" && target.currentMode() == "auto"){
|
| 6376 | successOverlay("sntp_processing");
|
| 6377 | }else{
|
| 6378 | //����serverУ׼ʱ��
|
| 6379 | service.setSNTPDate({
|
| 6380 | goformId: "SNTP_Getdatastatic"
|
| 6381 | }, function(result){
|
| 6382 | var sntpInfo = service.getSntpParams();
|
| 6383 | globalTime = new Date(parseInt(sntpInfo.sntp_year, 10),parseInt(sntpInfo.sntp_month, 10)-1, parseInt(sntpInfo.sntp_day, 10), parseInt(sntpInfo.sntp_hour, 10), parseInt(sntpInfo.sntp_minute, 10), parseInt(sntpInfo.sntp_second, 10));
|
| 6384 | successOverlay();
|
| 6385 | });
|
| 6386 | }
|
| 6387 | } else {
|
| 6388 | errorOverlay();
|
| 6389 | }
|
| 6390 | });
|
| 6391 | }
|
| 6392 |
|
| 6393 | // �ֶ�/�Զ��л���Ӧ����
|
| 6394 | function changeSetTimeMode() {
|
| 6395 | if(target.currentMode() == "manual") {
|
| 6396 | target.isManualSetTime(true);
|
| 6397 | target.isAutoSntpTime(false);
|
| 6398 | } else {
|
| 6399 | target.isManualSetTime(false);
|
| 6400 | target.isAutoSntpTime(true);
|
| 6401 | }
|
| 6402 | return true;
|
| 6403 | }
|
| 6404 |
|
| 6405 | // ��ʼ��ʱ��
|
| 6406 | function initDateList(){
|
| 6407 | sv_sntpDates = [];
|
| 6408 | if($.inArray(parseInt(target.currentMonth(), 10), sf_smallMonth) != -1) {
|
| 6409 | sf_produceArray(1, 30, sv_sntpDates);
|
| 6410 | } else if($.inArray(parseInt(target.currentMonth(), 10), sf_bigMonth) != -1) {
|
| 6411 | sf_produceArray(1, 31, sv_sntpDates);
|
| 6412 | } else if(parseInt(target.currentYear(), 10)%4 == 0) {
|
| 6413 | sf_produceArray(1, 29, sv_sntpDates);
|
| 6414 | } else {
|
| 6415 | sf_produceArray(1, 28, sv_sntpDates);
|
| 6416 | }
|
| 6417 | }
|
| 6418 |
|
| 6419 | // ��ʼ������������
|
| 6420 | function initOtherServer(){
|
| 6421 | target.isOther0(target.currentServer0() == "Other");
|
| 6422 | target.isOther1(target.currentServer1() == "Other");
|
| 6423 | target.isOther2(target.currentServer2() == "Other");
|
| 6424 | !target.isOther0() && $("#sntp_server0").find(".error").hide();
|
| 6425 | !target.isOther1() && $("#sntp_server1").find(".error").hide();
|
| 6426 | !target.isOther2() && $("#sntp_server2").find(".error").hide();
|
| 6427 | }
|
| 6428 |
|
| 6429 |
|
| 6430 | }
|
| 6431 |
|
| 6432 | // ��ʼ�� ViewModel����������ͼ����
|
| 6433 | function init() {
|
| 6434 | var fwVm = new othersViewModel();
|
| 6435 | var container = $('#container')[0];
|
| 6436 | ko.cleanNode(container);
|
| 6437 | ko.applyBindings(fwVm, container);
|
| 6438 | fwVm.updateCurrentTime();
|
| 6439 |
|
| 6440 | addInterval(function(){
|
| 6441 | fwVm.updateCurrentTime();
|
| 6442 | }, 1000);
|
| 6443 |
|
| 6444 | $("#sntpForm").validate({
|
| 6445 | submitHandler: function(){
|
| 6446 | fwVm.apply();
|
| 6447 | },
|
| 6448 | rules: {
|
| 6449 | sntp_other_server0 : "sntp_invalid_server_name",
|
| 6450 | sntp_other_server1 : "sntp_invalid_server_name",
|
| 6451 | sntp_other_server2 : "sntp_invalid_server_name"
|
| 6452 | }
|
| 6453 | });
|
| 6454 | }
|
| 6455 |
|
| 6456 | return {
|
| 6457 | init:init
|
| 6458 | }
|
| 6459 | });
|
| 6460 | // �������� �
|
| 6461 |
|
| 6462 | define("adm_management","jquery knockout set service underscore CryptoJS".split(" "),
|
| 6463 |
|
| 6464 | function ($, ko, config, service, _, CryptoJS) {
|
| 6465 |
|
| 6466 | function manageViewModel() {
|
| 6467 | var target = this;
|
| 6468 |
|
| 6469 | target.currentValue = ko.observable();
|
| 6470 | target.newValue = ko.observable();
|
| 6471 | target.confirmValue = ko.observable();
|
| 6472 |
|
| 6473 | function sf_changeValue() {
|
| 6474 | var sv_manageInfo = {};
|
| 6475 | if (config.PASSWORD_ENCODE) {
|
| 6476 | sv_manageInfo.oldValue = target.currentValue();
|
| 6477 | sv_manageInfo.newValue = target.newValue();
|
| 6478 | } else {
|
| 6479 | var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
|
| 6480 |
|
| 6481 | if (!pwdRegex.test(target.newValue())) {
|
| 6482 | showConfirm("password_note_too_low", function () {
|
| 6483 |
|
| 6484 | var kparam = service.getDeviceInfoLow();
|
| 6485 | var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
|
| 6486 | var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
|
| 6487 | var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
|
| 6488 | iv: tiv,
|
| 6489 | mode: CryptoJS.mode.CBC,
|
| 6490 | padding: CryptoJS.pad.ZeroPadding
|
| 6491 | }).toString();
|
| 6492 | var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
|
| 6493 | iv: tiv,
|
| 6494 | mode: CryptoJS.mode.CBC,
|
| 6495 | padding: CryptoJS.pad.ZeroPadding
|
| 6496 | }).toString();
|
| 6497 |
|
| 6498 | sv_manageInfo.oldValue = cipherold;
|
| 6499 | sv_manageInfo.newValue = ciphernew;
|
| 6500 |
|
| 6501 | showLoading();
|
| 6502 |
|
| 6503 | service.changeManageInfo(sv_manageInfo, function (resultInfo) {
|
| 6504 | target.cancel();
|
| 6505 | if (resultInfo && resultInfo.result == true) {
|
| 6506 | successOverlay();
|
| 6507 | } else {
|
| 6508 | if (resultInfo && resultInfo.errorType == "badPassword") {
|
| 6509 | hideLoading();
|
| 6510 | showAlert("current_password_error",function(){
|
| 6511 | $("#txtCurrent").focus();
|
| 6512 | });
|
| 6513 | } else {
|
| 6514 | errorOverlay();
|
| 6515 | }
|
| 6516 | }
|
| 6517 | });
|
| 6518 | });
|
| 6519 | return;
|
| 6520 | }
|
| 6521 | var kparam = service.getDeviceInfoLow();
|
| 6522 | var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
|
| 6523 | var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
|
| 6524 | var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
|
| 6525 | iv: tiv,
|
| 6526 | mode: CryptoJS.mode.CBC,
|
| 6527 | padding: CryptoJS.pad.ZeroPadding
|
| 6528 | }).toString();
|
| 6529 | var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
|
| 6530 | iv: tiv,
|
| 6531 | mode: CryptoJS.mode.CBC,
|
| 6532 | padding: CryptoJS.pad.ZeroPadding
|
| 6533 | }).toString();
|
| 6534 |
|
| 6535 | sv_manageInfo.oldValue = cipherold;
|
| 6536 | sv_manageInfo.newValue = ciphernew;
|
| 6537 | }
|
| 6538 |
|
| 6539 | showLoading();
|
| 6540 |
|
| 6541 | service.changeManageInfo(sv_manageInfo, function (resultInfo) {
|
| 6542 | target.cancel();
|
| 6543 | if (resultInfo && resultInfo.result == true) {
|
| 6544 | successOverlay();
|
| 6545 | } else {
|
| 6546 | if (resultInfo && resultInfo.errorType == "badPassword") {
|
| 6547 | hideLoading();
|
| 6548 | showAlert("current_password_error",function(){
|
| 6549 | $("#txtCurrent").focus();
|
| 6550 | });
|
| 6551 | } else {
|
| 6552 | errorOverlay();
|
| 6553 | }
|
| 6554 | }
|
| 6555 | });
|
| 6556 | }
|
| 6557 |
|
| 6558 | // ��������������
|
| 6559 | function sf_cancel() {
|
| 6560 | target.currentValue("");
|
| 6561 | target.newValue("");
|
| 6562 | target.confirmValue("");
|
| 6563 | }
|
| 6564 |
|
| 6565 | target.cancel = sf_cancel;
|
| 6566 |
|
| 6567 | // �޸�����
|
| 6568 | target.changeValue = sf_changeValue;
|
| 6569 | }
|
| 6570 |
|
| 6571 | function init() {
|
| 6572 | var container = $('#container');
|
| 6573 | ko.cleanNode(container[0]);
|
| 6574 | var fwVm = new manageViewModel();
|
| 6575 | ko.applyBindings(fwVm, container[0]);
|
| 6576 |
|
| 6577 | $('#frmPassword').validate({
|
| 6578 | submitHandler:function () {
|
| 6579 | fwVm.changeValue();
|
| 6580 | },
|
| 6581 | rules:{
|
| 6582 | txtCurrent:"manage_info_check",
|
| 6583 | txtNew:"manage_info_check",
|
| 6584 | txtConfirm:{ equalTo:"#txtNew"}
|
| 6585 | }
|
| 6586 | });
|
| 6587 | }
|
| 6588 |
|
| 6589 | return {
|
| 6590 | init:init
|
| 6591 | }
|
| 6592 | }
|
| 6593 | );
|
| 6594 | // PIN�����
|
| 6595 |
|
| 6596 | define("adm_pin","jquery knockout set service".split(" "),
|
| 6597 |
|
| 6598 | function ($, ko, config, service) {
|
| 6599 | var pageState = {common:0, requirePin:1, modifyPin:2, requirePuk:3, destroyed:4};
|
| 6600 | var pinStatus = {enable:"1", disable:"0"};
|
| 6601 |
|
| 6602 |
|
| 6603 | function pinViewModel() {
|
| 6604 | var target = this;
|
| 6605 | var sv_currentPinData = service.getPinData();
|
| 6606 |
|
| 6607 | target.isDataCard = config.PRODUCT_TYPE == 'DATACARD';
|
| 6608 | target.originPinStatus = ko.observable(sv_currentPinData.pin_status);
|
| 6609 |
|
| 6610 | target.pinStatus = ko.observable(sv_currentPinData.pin_status);
|
| 6611 | target.pinNumber = ko.observable(sv_currentPinData.pinnumber);
|
| 6612 | target.pukNumber = ko.observable(sv_currentPinData.puknumber);
|
| 6613 |
|
| 6614 | target.currentPin = ko.observable();
|
| 6615 | target.newPin = ko.observable();
|
| 6616 | target.confirmPin = ko.observable();
|
| 6617 |
|
| 6618 | target.puk = ko.observable();
|
| 6619 |
|
| 6620 | target.pageState = ko.observable();
|
| 6621 | // �����������ɹ���־λ
|
| 6622 | target.operateSuccessFlag = true;
|
| 6623 |
|
| 6624 | target.callback = sf_callback;
|
| 6625 |
|
| 6626 | function sf_callback(info) {
|
| 6627 | if (info && info.result == true) {
|
| 6628 | target.operateSuccessFlag = true;
|
| 6629 | successOverlay();
|
| 6630 | } else {
|
| 6631 | target.operateSuccessFlag = false;
|
| 6632 |
|
| 6633 | // ����һ��ǰҪ������ʾ
|
| 6634 | if(target.pinNumber() == 2){
|
| 6635 | showAlert("last_enter_pin");
|
| 6636 | } else if(target.pukNumber() == 2){
|
| 6637 | showAlert("last_enter_puk");
|
| 6638 | }
|
| 6639 | else{
|
| 6640 | errorOverlay();
|
| 6641 | }
|
| 6642 | }
|
| 6643 | init(target);
|
| 6644 | }
|
| 6645 |
|
| 6646 |
|
| 6647 | // ȷ����ť�¼������������޸�PIN������PUK����PIN������PIN��ʹ��״̬
|
| 6648 |
|
| 6649 | function sf_changePin() {
|
| 6650 | if (target.isConnectedNetWork()) {
|
| 6651 | showAlert("cannot_operate_when_connected");
|
| 6652 | return;
|
| 6653 | }
|
| 6654 |
|
| 6655 | if (target.pageState() == pageState.common) {
|
| 6656 | return;
|
| 6657 | }
|
| 6658 |
|
| 6659 | var sv_pinPara = {
|
| 6660 | oldPin:target.currentPin(),
|
| 6661 | newPin:target.newPin()
|
| 6662 | };
|
| 6663 | showLoading();
|
| 6664 |
|
| 6665 | if (target.pageState() == pageState.modifyPin) {
|
| 6666 | service.changePin(sv_pinPara, target.callback);
|
| 6667 | } else if (target.pageState() == pageState.requirePuk) {
|
| 6668 | sv_pinPara = {
|
| 6669 | PinNumber:target.newPin(),
|
| 6670 | PUKNumber:target.puk()
|
| 6671 | };
|
| 6672 | service.enterPUK(sv_pinPara, target.callback);
|
| 6673 | } else {
|
| 6674 | if (target.pinStatus() == pinStatus.enable) {
|
| 6675 | service.enablePin(sv_pinPara, target.callback);
|
| 6676 | } else {
|
| 6677 | service.disablePin(sv_pinPara, target.callback);
|
| 6678 | }
|
| 6679 | }
|
| 6680 | }
|
| 6681 |
|
| 6682 |
|
| 6683 | // ȡ���¼�����
|
| 6684 | function sf_cancel() {
|
| 6685 | target.pageState(pageState.common);
|
| 6686 | target.pinStatus(target.originPinStatus());
|
| 6687 | target.clear();
|
| 6688 | }
|
| 6689 |
|
| 6690 | // ����ҳ�������ͼ�����Ϣ
|
| 6691 | function sf_clear() {
|
| 6692 | target.confirmPin("");
|
| 6693 | target.currentPin("");
|
| 6694 | target.newPin("");
|
| 6695 | target.puk("");
|
| 6696 | clearValidateMsg();
|
| 6697 | }
|
| 6698 |
|
| 6699 | // �������ݣ����õ�ǰ��ҳ��״̬
|
| 6700 | function sf_computePageState(i_pinData) {
|
| 6701 | if (i_pinData.pinnumber > 0) {
|
| 6702 | //�����ɹ�ҳ���ص���ʼ״̬������ʧ�ܲ���pinnumber>0,ҳ�治��ת
|
| 6703 | if (target.operateSuccessFlag) {
|
| 6704 | target.cancel();
|
| 6705 | } else {
|
| 6706 | target.clear();
|
| 6707 | }
|
| 6708 | } else {
|
| 6709 | target.clear();
|
| 6710 | if (i_pinData.puknumber > 0) {
|
| 6711 | target.pageState(pageState.requirePuk);
|
| 6712 | } else {
|
| 6713 | target.pageState(pageState.destroyed);
|
| 6714 | }
|
| 6715 | }
|
| 6716 | }
|
| 6717 |
|
| 6718 | // ����PIN�޸�״̬�¼�����
|
| 6719 | function sf_displayModifyPinPage() {
|
| 6720 | if (target.isConnectedNetWork()) {
|
| 6721 | showAlert("cannot_operate_when_connected");
|
| 6722 | return;
|
| 6723 | }
|
| 6724 | target.pinStatus(target.originPinStatus());
|
| 6725 | target.pageState(pageState.modifyPin);
|
| 6726 | target.clear();
|
| 6727 | }
|
| 6728 |
|
| 6729 | // ����ҳ��Ԫ�ص�ʹ��״̬
|
| 6730 | function sf_fixPageEnable() {
|
| 6731 | if (target.isConnectedNetWork()) {
|
| 6732 | $('#frmPin :input').each(function () {
|
| 6733 | disableBtn($(this));
|
| 6734 | });
|
| 6735 | clearValidateMsg();
|
| 6736 | } else {
|
| 6737 | $('#frmPin :input').each(function () {
|
| 6738 | if (this.id == "txtPin" || this.id == "btnPinApply") {
|
| 6739 | if (target.pageState() == pageState.common) {
|
| 6740 | disableBtn($(this));
|
| 6741 | return;
|
| 6742 | }
|
| 6743 | }
|
| 6744 | if (this.id == "btnModifyPin") {
|
| 6745 | if (target.originPinStatus() != pinStatus.enable) {
|
| 6746 | disableBtn($(this));
|
| 6747 | return;
|
| 6748 | }
|
| 6749 | }
|
| 6750 | if (this.id == "pinEnable" || this.id == "pinDisable") {
|
| 6751 | if (target.pageState() == pageState.modifyPin) {
|
| 6752 | disableBtn($(this));
|
| 6753 | return;
|
| 6754 | }
|
| 6755 | }
|
| 6756 | enableBtn($(this));
|
| 6757 | });
|
| 6758 |
|
| 6759 | }
|
| 6760 | }
|
| 6761 |
|
| 6762 | // �Ƿ�������
|
| 6763 | function sf_isConnectedNetWork() {
|
| 6764 | var info = service.getConnectionInfo();
|
| 6765 | return info.connectStatus == "ppp_connected";
|
| 6766 | }
|
| 6767 |
|
| 6768 | // PINʹ�ܸı�ʱ�¼�����
|
| 6769 | function sf_pinStatusChangeEvent() {
|
| 6770 | if (target.pinStatus() == target.originPinStatus()) {
|
| 6771 | target.pageState(pageState.common);
|
| 6772 | } else {
|
| 6773 | target.pageState(pageState.requirePin);
|
| 6774 | }
|
| 6775 | target.clear();
|
| 6776 | }
|
| 6777 |
|
| 6778 | target.changePin = sf_changePin;
|
| 6779 | target.cancel = sf_cancel;
|
| 6780 | target.clear = sf_clear;
|
| 6781 | target.computePageState = sf_computePageState;
|
| 6782 |
|
| 6783 | target.computePageState(sv_currentPinData);
|
| 6784 |
|
| 6785 | target.displayModifyPinPage = sf_displayModifyPinPage;
|
| 6786 | target.fixPageEnable = sf_fixPageEnable;
|
| 6787 | target.isConnectedNetWork = sf_isConnectedNetWork;
|
| 6788 |
|
| 6789 | target.pinStatusChangeEvent = ko.dependentObservable(sf_pinStatusChangeEvent, this);
|
| 6790 | }
|
| 6791 |
|
| 6792 | function init(oldViewModel) {
|
| 6793 |
|
| 6794 | var fwVm = oldViewModel;
|
| 6795 |
|
| 6796 | if (fwVm) {
|
| 6797 | var sv_currentPinData = service.getPinData();
|
| 6798 | fwVm.originPinStatus(sv_currentPinData.pin_status);
|
| 6799 | fwVm.pinNumber(sv_currentPinData.pinnumber);
|
| 6800 | fwVm.pukNumber(sv_currentPinData.puknumber);
|
| 6801 | fwVm.computePageState(sv_currentPinData);
|
| 6802 | } else {
|
| 6803 | fwVm = new pinViewModel();
|
| 6804 | addInterval(function () {
|
| 6805 | fwVm.fixPageEnable();
|
| 6806 | }, 1000);
|
| 6807 | }
|
| 6808 |
|
| 6809 | var container = $('#container')[0];
|
| 6810 | ko.cleanNode(container);
|
| 6811 | ko.applyBindings(fwVm, container);
|
| 6812 | fwVm.fixPageEnable();
|
| 6813 |
|
| 6814 | $('#frmPin').validate({
|
| 6815 | submitHandler:function () {
|
| 6816 | fwVm.changePin();
|
| 6817 | },
|
| 6818 | rules:{
|
| 6819 | txtPuk:"puk_check",
|
| 6820 | txtPin:"pin_check",
|
| 6821 | txtNewPin:"pin_check",
|
| 6822 | txtConfirmPin:{equalToPin:"#txtNewPin"}
|
| 6823 | }
|
| 6824 | });
|
| 6825 | }
|
| 6826 |
|
| 6827 | return {
|
| 6828 | init:init
|
| 6829 | }
|
| 6830 | }
|
| 6831 | );
|
| 6832 |
|
| 6833 | // ��������
|
| 6834 | define("adm_quick_set","jquery knockout set service underscore CryptoJS".split(" "),
|
| 6835 |
|
| 6836 | function ($, ko, config, service, _, CryptoJS) {
|
| 6837 |
|
| 6838 | var sv_wifiState = {ok:0, wps_on:1, wifi_off:2};
|
| 6839 | var sv_apnMode = {auto:"auto", manual:"manual"};
|
| 6840 | var sv_minStep = 1;
|
| 6841 | var sv_maxStep = 5;
|
| 6842 |
|
| 6843 | // ��ȡ��Ȩ��ʽ
|
| 6844 | function sf_fetchAuthenticationModes() {
|
| 6845 | return _.map(config.APN_AUTH_MODES, function (item) {
|
| 6846 | return new Option(item.name, item.value);
|
| 6847 | });
|
| 6848 | }
|
| 6849 |
|
| 6850 | // WIFI��ȫģʽѡ��
|
| 6851 | var sv_securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
|
| 6852 | return new Option(item.name, item.value);
|
| 6853 | });
|
| 6854 |
|
| 6855 |
|
| 6856 | function quickSettingViewModel() {
|
| 6857 | var target = this;
|
| 6858 |
|
| 6859 | var sv_quickSettingInfo = service.getQuickSettingInfo();
|
| 6860 |
|
| 6861 | target.currentStep = ko.observable(sv_minStep);
|
| 6862 | target.ipType = ko.observable(sv_quickSettingInfo.pdp_type == "IP" ? "IP" : sv_quickSettingInfo.ipv6_pdp_type);
|
| 6863 | target.supportIPv6 = config.IPV6_SUPPORT;
|
| 6864 | target.supportIpv4AndIpv6 = config.IPV4_AND_V6_SUPPORT;
|
| 6865 |
|
| 6866 | target.wpsFlag = ko.observable(sv_quickSettingInfo.WscModeOption);
|
| 6867 |
|
| 6868 | function sf_apnDisabled() {
|
| 6869 | return (sv_quickSettingInfo.apn_index < config.defaultApnSize || sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting");
|
| 6870 | }
|
| 6871 |
|
| 6872 | function sf_apnModeDisabled() {
|
| 6873 | return (sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting" || (!target.profileName() && target.apnMode() == sv_apnMode.auto));//ѡ��Ϊ�ջ��������ӻ�������
|
| 6874 | }
|
| 6875 |
|
| 6876 | function sf_currAPN() {
|
| 6877 | var sv_APNText = sv_quickSettingInfo["APN_configtmp" + sv_quickSettingInfo.apn_index];
|
| 6878 | var strIPv6APN = sv_quickSettingInfo["ipv6_APN_configtmp" + sv_quickSettingInfo.apn_index];
|
| 6879 |
|
| 6880 | var sv_apn = [];
|
| 6881 | var sv_ipv6APNItems = [];
|
| 6882 |
|
| 6883 | if (sv_APNText) {
|
| 6884 | sv_apn = sv_APNText.split("($)");
|
| 6885 | }
|
| 6886 |
|
| 6887 | if (strIPv6APN) {
|
| 6888 | sv_ipv6APNItems = strIPv6APN.split("($)");
|
| 6889 | }
|
| 6890 |
|
| 6891 | return {
|
| 6892 | m_profile_name:sv_apn[0],
|
| 6893 | wan_apn:sv_apn[1],
|
| 6894 | ppp_auth_mode: sv_apn[4] == "" || typeof(sv_apn[4]) == "undefined" ? "" : sv_apn[4].toLowerCase(),
|
| 6895 | ppp_username:sv_apn[5],
|
| 6896 | ppp_passtmp:sv_apn[6],
|
| 6897 | pdp_type: sv_apn[7],
|
| 6898 | ipv6_wan_apn:sv_ipv6APNItems[1],
|
| 6899 | ipv6_ppp_auth_mode:typeof(sv_ipv6APNItems[4]) == "undefined" || sv_ipv6APNItems[4] == ""? "" : sv_ipv6APNItems[4].toLowerCase(),
|
| 6900 | ipv6_ppp_username:sv_ipv6APNItems[5],
|
| 6901 | ipv6_ppp_passtmp:sv_ipv6APNItems[6],
|
| 6902 | ipv6_pdp_type:sv_ipv6APNItems[7]
|
| 6903 | }
|
| 6904 | }
|
| 6905 |
|
| 6906 | // ��ǰAPN����
|
| 6907 | target.currAPN = ko.computed(sf_currAPN);
|
| 6908 |
|
| 6909 | target.apn = ko.observable(target.currAPN().wan_apn);
|
| 6910 | target.ipv6_apn = ko.observable(target.currAPN().ipv6_wan_apn);
|
| 6911 | target.ipv6_selectedAuthMode = ko.observable(target.currAPN().ipv6_ppp_auth_mode);
|
| 6912 | target.ipv6_username = ko.observable(target.currAPN().ipv6_ppp_username);
|
| 6913 | target.ipv6_password = ko.observable(target.currAPN().ipv6_ppp_passtmp);
|
| 6914 | target.profileName = ko.observable(target.currAPN().m_profile_name);
|
| 6915 | target.selectedAuthMode = ko.observable(target.currAPN().ppp_auth_mode);
|
| 6916 | target.username = ko.observable(target.currAPN().ppp_username);
|
| 6917 | target.password = ko.observable(target.currAPN().ppp_passtmp);
|
| 6918 |
|
| 6919 | target.transAPN = ko.observable("apn_ipv4_apn");
|
| 6920 | target.transAPNIPv6 = ko.observable("apn_ipv6_apn");
|
| 6921 | target.transAuthMode = ko.observable("apn_authentication_ipv4");
|
| 6922 | target.transAuthModeIPv6 = ko.observable("apn_authentication_ipv6");
|
| 6923 | target.transUserName = ko.observable("apn_user_name_ipv4");
|
| 6924 | target.transPassword = ko.observable("apn_password_ipv4");
|
| 6925 | target.transUserNameIPv6 = ko.observable("apn_user_name_ipv6");
|
| 6926 | target.transPasswordIPv6 = ko.observable("apn_password_ipv6");
|
| 6927 |
|
| 6928 |
|
| 6929 |
|
| 6930 | target.apnDisabled = ko.computed(sf_apnDisabled);
|
| 6931 | target.apnMode = ko.observable(sv_quickSettingInfo.apn_mode);
|
| 6932 | target.apnModeDisabled = ko.computed(sf_apnModeDisabled);
|
| 6933 | target.authModes = ko.observableArray(sf_fetchAuthenticationModes());
|
| 6934 |
|
| 6935 | if (target.ipType() == "IPv6") {
|
| 6936 | target.showIPv4 = false;
|
| 6937 | target.showIPv6 = true;
|
| 6938 | target.transAPNIPv6("apn");
|
| 6939 | target.transAuthModeIPv6("apn_authentication");
|
| 6940 | target.transUserNameIPv6("apn_user_name");
|
| 6941 | target.transPasswordIPv6("apn_password");
|
| 6942 | } else if (config.IPV4_AND_V6_SUPPORT && target.ipType() == "IPv4v6") {
|
| 6943 | target.showIPv4 = true;
|
| 6944 | target.showIPv6 = true;
|
| 6945 | //ʹ��Ĭ��
|
| 6946 | } else if (target.ipType() == "IP" || target.ipType() == "IPv4") {
|
| 6947 | target.showIPv4 = true;
|
| 6948 | target.showIPv6 = false;
|
| 6949 | target.transAPN("apn");
|
| 6950 | target.transAuthMode("apn_authentication");
|
| 6951 | target.transUserName("apn_user_name");
|
| 6952 | target.transPassword("apn_password");
|
| 6953 | } else { //pdp_type == "IPv4v6" && config.IPV4V6_SUPPORT
|
| 6954 | target.showIPv4 = true;
|
| 6955 | target.showIPv6 = false;
|
| 6956 | target.transAPN("apn");
|
| 6957 | target.transAuthMode("apn_authentication");
|
| 6958 | target.transUserName("apn_user_name");
|
| 6959 | target.transPassword("apn_password");
|
| 6960 | }
|
| 6961 |
|
| 6962 | target.wifiDisabled = (sv_quickSettingInfo.wifi_cur_state != "1");
|
| 6963 | target.ssid = ko.observable(sv_quickSettingInfo.SSID1);
|
| 6964 | target.broadcast = ko.observable(sv_quickSettingInfo.HideSSID);
|
| 6965 | target.hasWifiWep = config.WIFI_WEP_SUPPORT;
|
| 6966 | target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
|
| 6967 | target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
|
| 6968 |
|
| 6969 | target.securityModes = ko.observableArray(sv_securityModes);
|
| 6970 | target.selectedSecurityMode = ko.observable(sv_quickSettingInfo.AuthMode);
|
| 6971 | target.WPAKey = ko.observable(sv_quickSettingInfo.WPAPSK1);
|
| 6972 |
|
| 6973 | target.apnMode_display = ko.observable("");
|
| 6974 |
|
| 6975 | target.apnMode_trans = ko.computed(sf_apnMode_trans);
|
| 6976 | target.selectedAuthMode_display = ko.computed(sf_selectedAuthMode_display);
|
| 6977 | target.ipv6_selectedAuthMode_display = ko.computed(sf_ipv6_selectedAuthMode_display);
|
| 6978 |
|
| 6979 | target.showWifiPassword = ko.observable(false);
|
| 6980 | target.showWifiPasswordHandler = sf_showWifiPasswordHandler;
|
| 6981 |
|
| 6982 | //�ж��Ƿ���802 n only��
|
| 6983 | var sv_adInfo = service.getWifiAdvance();
|
| 6984 | target.adBand = ko.observable(sv_adInfo.wifiBand);
|
| 6985 | target.adMode = ko.observable(sv_adInfo.mode);
|
| 6986 |
|
| 6987 | target.encryptType = ko.observable(sv_quickSettingInfo.EncrypType);
|
| 6988 | target.keyID = ko.observable(sv_quickSettingInfo.DefaultKeyID);
|
| 6989 | target.wepPassword = ko.observable("");
|
| 6990 |
|
| 6991 | target.getWepPassword = sf_getWepPassword;
|
| 6992 | target.wepPassword(target.getWepPassword());
|
| 6993 | target.profileChangeHandler = sf_profileChangeHandler;
|
| 6994 |
|
| 6995 | target.broadcast_display = ko.observable("");
|
| 6996 | target.broadcast_trans = ko.computed(sf_broadcast_trans);
|
| 6997 |
|
| 6998 | target.selectedSecurityMode_display = ko.observable();
|
| 6999 | target.selectedSecurityMode_trans = ko.computed(sf_selectedSecurityMode_trans);
|
| 7000 |
|
| 7001 |
|
| 7002 | target.callback = sf_callback;
|
| 7003 | target.next = sf_button_next;
|
| 7004 | target.previous = sf_button_previous;
|
| 7005 | target.save = sf_button_save;
|
| 7006 |
|
| 7007 | function sf_apnMode_trans() {
|
| 7008 | if (sv_apnMode.auto == target.apnMode()) {
|
| 7009 | target.apnMode_display($.i18n.prop("apn_auto_apn"));
|
| 7010 | return "apn_auto_apn";
|
| 7011 | } else {
|
| 7012 | target.apnMode_display($.i18n.prop("apn_manual_apn"));
|
| 7013 | return "apn_manual_apn";
|
| 7014 | }
|
| 7015 | }
|
| 7016 |
|
| 7017 | function sf_broadcast_trans() {
|
| 7018 | if ("0" == target.broadcast()) {
|
| 7019 | target.broadcast_display($.i18n.prop("enable"));
|
| 7020 | return "enable";
|
| 7021 | } else {
|
| 7022 | target.broadcast_display($.i18n.prop("disable"));
|
| 7023 | return "disable";
|
| 7024 | }
|
| 7025 | }
|
| 7026 |
|
| 7027 | function sf_button_next() {
|
| 7028 | var currentStep = target.currentStep();
|
| 7029 | var toStep = target.currentStep() + 1;
|
| 7030 | sf_changeStep(toStep);
|
| 7031 |
|
| 7032 | if (currentStep == 1 && target.apnMode() == sv_apnMode.auto) {
|
| 7033 | toStep = target.currentStep() + 1;
|
| 7034 | sf_changeStep(toStep);
|
| 7035 | }
|
| 7036 | }
|
| 7037 |
|
| 7038 | function sf_button_previous() {
|
| 7039 |
|
| 7040 | var currentStep = target.currentStep();
|
| 7041 | var toStep = target.currentStep() - 1;
|
| 7042 |
|
| 7043 | sf_changeStep(toStep);
|
| 7044 |
|
| 7045 | if (currentStep == 3 && target.apnMode() == sv_apnMode.auto) {
|
| 7046 | toStep = target.currentStep() - 1;
|
| 7047 | sf_changeStep(toStep);
|
| 7048 | }
|
| 7049 | }
|
| 7050 | function sf_button_save() {
|
| 7051 | var submit = function () {
|
| 7052 | sf_quickSetting4IPv6();
|
| 7053 | };
|
| 7054 | var result = sf_isDisabled_Wifi();
|
| 7055 | if(result == sv_wifiState.wifi_off){
|
| 7056 | showConfirm("quick_setting_wifi_disable_confirm", submit);
|
| 7057 | } else if (result == sv_wifiState.wps_on) {
|
| 7058 | showAlert("wps_on_info");
|
| 7059 | } else{
|
| 7060 | showConfirm("quick_setting_param_changed_confirm", submit);//submit();
|
| 7061 | }
|
| 7062 | }
|
| 7063 | // ���������ύ���Ļص�����
|
| 7064 | function sf_callback(data) {
|
| 7065 | if (data.result == "success") {
|
| 7066 | successOverlay();
|
| 7067 | location.hash = "#network_choose";
|
| 7068 | }
|
| 7069 | else {
|
| 7070 | errorOverlay();
|
| 7071 | }
|
| 7072 | }
|
| 7073 |
|
| 7074 | // �任����ʱ����
|
| 7075 | function sf_changeStep(i_step) {
|
| 7076 | if (i_step > sv_maxStep) {
|
| 7077 | i_step = sv_maxStep;
|
| 7078 | } else if (i_step < sv_minStep) {
|
| 7079 | i_step = sv_minStep;
|
| 7080 | }
|
| 7081 |
|
| 7082 | target.currentStep(i_step);
|
| 7083 | return true;
|
| 7084 | }
|
| 7085 |
|
| 7086 | function sf_ipv6_selectedAuthMode_display() {
|
| 7087 | var mode = target.ipv6_selectedAuthMode();
|
| 7088 | return sf_getAuthModeNameByValue(mode);
|
| 7089 | }
|
| 7090 | // ���ݼ�Ȩģʽ��ֵ��������
|
| 7091 | function sf_getAuthModeNameByValue(authMode) {
|
| 7092 | for (var i = 0; i < config.APN_AUTH_MODES.length; i++) {
|
| 7093 | if (authMode == config.APN_AUTH_MODES[i].value) {
|
| 7094 | return config.APN_AUTH_MODES[i].name;
|
| 7095 | }
|
| 7096 | }
|
| 7097 | }
|
| 7098 |
|
| 7099 | function sf_getWepPassword(){
|
| 7100 | return target.keyID() == '3' ? sv_quickSettingInfo.Key4Str1 : (target.keyID() == '2' ? sv_quickSettingInfo.Key3Str1 : target.keyID() == '1' ? sv_quickSettingInfo.Key2Str1 : sv_quickSettingInfo.Key1Str1);
|
| 7101 | }
|
| 7102 |
|
| 7103 | function sf_isDisabled_Wifi() {
|
| 7104 | var s_wpsInfo = service.getWpsInfo();
|
| 7105 | if(s_wpsInfo.radioFlag == "0"){
|
| 7106 | return sv_wifiState.wifi_off;
|
| 7107 | }else if (s_wpsInfo.wpsFlag == '1') {
|
| 7108 | return sv_wifiState.wps_on;
|
| 7109 | }
|
| 7110 | return sv_wifiState.ok;
|
| 7111 | }
|
| 7112 | function sf_profileChangeHandler(i_data, i_event) {
|
| 7113 | $("#pwdWepKey").parent().find("label[class='error']").hide();
|
| 7114 | target.wepPassword(target.getWepPassword());
|
| 7115 | return true;
|
| 7116 | }
|
| 7117 |
|
| 7118 | // ���������ύ(֧��IPv6��
|
| 7119 | function sf_quickSetting4IPv6() {
|
| 7120 | showLoading();
|
| 7121 | var useIPv4ForV6 = config.IPV4V6_SUPPORT && target.currAPN().pdp_type == "IPv4v6";
|
| 7122 |
|
| 7123 | var ciphertext = "";
|
| 7124 | if (config.PASSWORD_ENCODE) {
|
| 7125 | ciphertext = target.WPAKey();
|
| 7126 | } else {
|
| 7127 | var kparam = service.getDeviceInfoLow();
|
| 7128 | var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
|
| 7129 | var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
|
| 7130 | ciphertext = CryptoJS.AES.encrypt(target.WPAKey(), tkey, {
|
| 7131 | iv: tiv,
|
| 7132 | mode: CryptoJS.mode.CBC,
|
| 7133 | padding: CryptoJS.pad.ZeroPadding
|
| 7134 | }).toString();
|
| 7135 | }
|
| 7136 |
|
| 7137 | var s_quickSettingParameters = {
|
| 7138 | apn_index: sv_quickSettingInfo.apn_index,
|
| 7139 | apnMode: target.apnMode(),
|
| 7140 | Encryption_Mode_hid: target.selectedSecurityMode(),
|
| 7141 | ipv6_ppp_auth_mode: useIPv4ForV6 ? target.selectedAuthMode() : target.ipv6_selectedAuthMode(),
|
| 7142 | ipv6_ppp_username: useIPv4ForV6 ? target.username() : target.ipv6_username(),
|
| 7143 | ipv6_ppp_passtmp: useIPv4ForV6 ? target.password() : target.ipv6_password(),
|
| 7144 | ipv6_wan_apn: useIPv4ForV6 ? target.apn() : target.ipv6_apn(),
|
| 7145 | pdp_type: target.ipType(),
|
| 7146 | ppp_auth_mode: target.selectedAuthMode(),
|
| 7147 | ppp_username: target.username(),
|
| 7148 | ppp_passtmp: target.password(),
|
| 7149 | profile_name: target.profileName(),
|
| 7150 | //Ŀǰ����ģʽֻ��2�֣�����3������Ϊ�̶�ֵ
|
| 7151 | //������Ҫ����Ϊ5�֣�����ֵ��Ҫ����
|
| 7152 | security_shared_mode: "NONE",
|
| 7153 | SSID_Broadcast: target.broadcast(),
|
| 7154 | SSID_name: target.ssid(),
|
| 7155 | wan_apn: target.apn(),
|
| 7156 | wep_default_key: 0,
|
| 7157 | WPA_ENCRYPTION_hid: target.selectedSecurityMode() == "OPEN" ? "NONE" : target.selectedSecurityMode() == "WPA2PSK" ? 1 : 2,
|
| 7158 | WPA_PreShared_Key: ciphertext
|
| 7159 | }
|
| 7160 |
|
| 7161 | s_quickSettingParameters.wep_default_key = target.keyID();
|
| 7162 |
|
| 7163 | if(target.encryptType() == "SHARED" || target.selectedSecurityMode() == "WEP") {
|
| 7164 |
|
| 7165 | s_quickSettingParameters.security_shared_mode = "WEP";
|
| 7166 |
|
| 7167 | s_quickSettingParameters.wep_key_1 = sv_quickSettingInfo.Key1Str1;
|
| 7168 | s_quickSettingParameters.wep_key_2 = sv_quickSettingInfo.Key2Str1;
|
| 7169 | s_quickSettingParameters.wep_key_3 = sv_quickSettingInfo.Key3Str1;
|
| 7170 | s_quickSettingParameters.wep_key_4 = sv_quickSettingInfo.Key4Str1;
|
| 7171 |
|
| 7172 | var WEPSelectTmp = '0';
|
| 7173 |
|
| 7174 | if(target.wepPassword().length =='5' ||target.wepPassword().length =='13'){
|
| 7175 | WEPSelectTmp = '1';
|
| 7176 | }else{
|
| 7177 | WEPSelectTmp = '0';
|
| 7178 | }
|
| 7179 |
|
| 7180 | if(target.keyID() =='3'){
|
| 7181 | s_quickSettingParameters.wep_key_4 = target.wepPassword();
|
| 7182 | s_quickSettingParameters.WEP4Select = WEPSelectTmp;
|
| 7183 | }else if(target.keyID() =='2'){
|
| 7184 | s_quickSettingParameters.wep_key_3 = target.wepPassword();
|
| 7185 | s_quickSettingParameters.WEP3Select = WEPSelectTmp;
|
| 7186 | }else if(target.keyID() =='1'){
|
| 7187 | s_quickSettingParameters.wep_key_2 = target.wepPassword();
|
| 7188 | s_quickSettingParameters.WEP2Select = WEPSelectTmp;
|
| 7189 | }else{
|
| 7190 | s_quickSettingParameters.wep_key_1 = target.wepPassword();
|
| 7191 | s_quickSettingParameters.WEP1Select = WEPSelectTmp;
|
| 7192 | }
|
| 7193 | }else if(target.encryptType() == "WPAPSKWPA2PSK") {
|
| 7194 | s_quickSettingParameters.security_shared_mode = "NONE";
|
| 7195 | }else {
|
| 7196 | s_quickSettingParameters.security_shared_mode = "NONE";
|
| 7197 | }
|
| 7198 |
|
| 7199 | service.setQuickSetting4IPv6(s_quickSettingParameters, target.callback);
|
| 7200 | }
|
| 7201 |
|
| 7202 | function sf_selectedAuthMode_display() {
|
| 7203 | var mode = target.selectedAuthMode();
|
| 7204 | return sf_getAuthModeNameByValue(mode);
|
| 7205 | }
|
| 7206 |
|
| 7207 | function sf_selectedSecurityMode_trans() {
|
| 7208 | var mode = target.selectedSecurityMode();
|
| 7209 | var modesOption = config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES;
|
| 7210 | for (var i = 0; i < modesOption.length; i++) {
|
| 7211 | if (mode == modesOption[i].value) {
|
| 7212 | target.selectedSecurityMode_display($.i18n.prop("security_mode_" + modesOption[i].value));
|
| 7213 | return "security_mode_" + modesOption[i].value;
|
| 7214 | }
|
| 7215 | }
|
| 7216 | }
|
| 7217 |
|
| 7218 | function sf_showWifiPasswordHandler(){
|
| 7219 | $("#pwdWepKey").parent().find(".error").hide();
|
| 7220 | $("#codeWPAKey").parent().find(".error").hide();
|
| 7221 | var checkbox = $("#showWifiPassword:checked");
|
| 7222 | if(checkbox && checkbox.length == 0){
|
| 7223 | target.showWifiPassword(true);
|
| 7224 | }else{
|
| 7225 | target.showWifiPassword(false);
|
| 7226 | }
|
| 7227 | }
|
| 7228 |
|
| 7229 | }
|
| 7230 |
|
| 7231 | function init() {
|
| 7232 | var container = $('#container');
|
| 7233 | ko.cleanNode(container[0]);
|
| 7234 | var fwVm = new quickSettingViewModel();
|
| 7235 | ko.applyBindings(fwVm, container[0]);
|
| 7236 |
|
| 7237 | $('#quickSettingForm').validate({
|
| 7238 | submitHandler:function () {
|
| 7239 | if (fwVm.currentStep() < 5) {
|
| 7240 | fwVm.next();
|
| 7241 | } else {
|
| 7242 | fwVm.save();
|
| 7243 | }
|
| 7244 | },
|
| 7245 | rules:{
|
| 7246 | txtAPN:"apn_check",
|
| 7247 | txtIPv6APN:"apn_check",
|
| 7248 | txtSSID:'ssid',
|
| 7249 | pwdWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
|
| 7250 | txtWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
|
| 7251 | txtWPAKey:'wifi_password_check',
|
| 7252 | codeWPAKey:'wifi_password_check',
|
| 7253 | txtUserName:'ppp_username_check',
|
| 7254 | txtIPv6UserName:'ppp_username_check',
|
| 7255 | txtSecretCode:"ppp_secretcode_check",
|
| 7256 | txtIPv6SecretCode:"ppp_secretcode_check"
|
| 7257 | },
|
| 7258 | errorPlacement:function (error, element) {
|
| 7259 | var id = element.attr("id");
|
| 7260 | if (id == "pwdWepKey" || id == "txtWepKey"){
|
| 7261 | error.insertAfter("#lblShowWepPassword");
|
| 7262 | } else if (id == "txtWPAKey" || id == "codeWPAKey") {
|
| 7263 | error.insertAfter("#lblShowWifiPassword");
|
| 7264 | } else {
|
| 7265 | error.insertAfter(element);
|
| 7266 | }
|
| 7267 | }
|
| 7268 | });
|
| 7269 | }
|
| 7270 |
|
| 7271 | return {
|
| 7272 | init:init
|
| 7273 | };
|
| 7274 | }
|
| 7275 | );
|
| 7276 |
|
| 7277 | define("main","set service knockout underscore jquery statusBar echarts".split(" "), function (set, fnc, libko, libus, libjq, barStat, echarts) {
|
| 7278 |
|
| 7279 | var chartOptions = {
|
| 7280 | color: ['red', 'red', 'red', 'red', 'red'],
|
| 7281 | series: [{
|
| 7282 | name: '��������',
|
| 7283 | type: 'pie',
|
| 7284 | radius: ['0', '72'],
|
| 7285 | itemStyle: {
|
| 7286 | normal: {
|
| 7287 | label: {
|
| 7288 | show: false
|
| 7289 | },
|
| 7290 | labelLine: {
|
| 7291 | show: false
|
| 7292 | }
|
| 7293 | }
|
| 7294 | },
|
| 7295 | data: [],
|
| 7296 | selectedOffset: 3
|
| 7297 | }
|
| 7298 | ],
|
| 7299 | animation: false,
|
| 7300 | title: {
|
| 7301 | text: '',
|
| 7302 | x: 'center',
|
| 7303 | y: 'center',
|
| 7304 | itemGap: 0,
|
| 7305 | textStyle: {
|
| 7306 | color: '#FFF',
|
| 7307 | fontFamily: '΢���ź�',
|
| 7308 | fontSize: 20,
|
| 7309 | fontWeight: 'bolder'
|
| 7310 | },
|
| 7311 | subtextStyle: {
|
| 7312 | color: '#FFF',
|
| 7313 | fontFamily: '΢���ź�',
|
| 7314 | fontSize: 16,
|
| 7315 | fontWeight: 'bolder'
|
| 7316 | }
|
| 7317 | },
|
| 7318 | tooltip: {
|
| 7319 | formatter: "{b}"
|
| 7320 | },
|
| 7321 | };
|
| 7322 | var languageOld = window.language;
|
| 7323 | var num_refresh = 0;
|
| 7324 | var traffic_graphic_chart = null;
|
| 7325 | var connStat = {
|
| 7326 | CONNECTED: 1,
|
| 7327 | DISCONNECTED: 2,
|
| 7328 | CONNECTING: 3,
|
| 7329 | DISCONNECTING: 4
|
| 7330 | };
|
| 7331 | function init() {
|
| 7332 | num_refresh = 0;
|
| 7333 | homeUtil.oldUsedData = null;
|
| 7334 | homeUtil.oldAlarmData = null;
|
| 7335 | traffic_graphic_chart = echarts.init(libjq("#traffic_graphic")[0]);
|
| 7336 | var container = libjq('#container')[0];
|
| 7337 | libko.cleanNode(container);
|
| 7338 | var tmp = new VmHome();
|
| 7339 | libko.applyBindings(tmp, container);
|
| 7340 | var data = fnc.getLoginData();
|
| 7341 | var psw_flg = data.psw_changed;
|
| 7342 | if (psw_flg != "1") {
|
| 7343 | showConfirm("password_note_first_change", function () {
|
| 7344 | window.location.hash = '#pwd_mode';
|
| 7345 | });
|
| 7346 | return;
|
| 7347 | }
|
| 7348 | }
|
| 7349 |
|
| 7350 | var homeUtil = {
|
| 7351 | initStatus: null,
|
| 7352 | initShownStatus: function (data) {
|
| 7353 | this.initStatus = {};
|
| 7354 | var ipv6Mode = data.ipv6PdpType.toLowerCase().indexOf("v6") > 0;
|
| 7355 | if (set.RJ45_SUPPORT) {
|
| 7356 | var mode = checkCableMode(data.blc_wan_mode);
|
| 7357 | if (mode) {
|
| 7358 | this.initStatus.showIpv6WanIpAddr = false;
|
| 7359 | this.initStatus.showIpv4WanIpAddr = true;
|
| 7360 | } else if (set.IPV6_SUPPORT) {
|
| 7361 | if (data.pdpType == "IP") {
|
| 7362 | this.initStatus.showIpv6WanIpAddr = false;
|
| 7363 | this.initStatus.showIpv4WanIpAddr = true;
|
| 7364 | } else if (ipv6Mode) {
|
| 7365 | if (data.ipv6PdpType == "IPv6") {
|
| 7366 | this.initStatus.showIpv6WanIpAddr = true;
|
| 7367 | this.initStatus.showIpv4WanIpAddr = false;
|
| 7368 | } else {
|
| 7369 | this.initStatus.showIpv6WanIpAddr = true;
|
| 7370 | this.initStatus.showIpv4WanIpAddr = true;
|
| 7371 | }
|
| 7372 | }
|
| 7373 | } else {
|
| 7374 | this.initStatus.showIpv6WanIpAddr = false;
|
| 7375 | this.initStatus.showIpv4WanIpAddr = true;
|
| 7376 | }
|
| 7377 | } else {
|
| 7378 | if (set.IPV6_SUPPORT) {
|
| 7379 | if (data.pdpType == "IP") {
|
| 7380 | this.initStatus.showIpv6WanIpAddr = false;
|
| 7381 | this.initStatus.showIpv4WanIpAddr = true;
|
| 7382 | } else if (ipv6Mode) {
|
| 7383 | if (data.ipv6PdpType == "IPv6") {
|
| 7384 | this.initStatus.showIpv6WanIpAddr = true;
|
| 7385 | this.initStatus.showIpv4WanIpAddr = false;
|
| 7386 | } else {
|
| 7387 | this.initStatus.showIpv6WanIpAddr = true;
|
| 7388 | this.initStatus.showIpv4WanIpAddr = true;
|
| 7389 | }
|
| 7390 | }
|
| 7391 | } else {
|
| 7392 | this.initStatus.showIpv6WanIpAddr = false;
|
| 7393 | this.initStatus.showIpv4WanIpAddr = true;
|
| 7394 | }
|
| 7395 | }
|
| 7396 | },
|
| 7397 | wanIpGet: function (data) {
|
| 7398 | var addrInfo = {
|
| 7399 | wanIpAddress: '',
|
| 7400 | ipv6WanIpAddress: ''
|
| 7401 | };
|
| 7402 | addrInfo.wanIpAddress = verifyDeviceInfo(data.wanIpAddress);
|
| 7403 | addrInfo.ipv6WanIpAddress = verifyDeviceInfo(data.ipv6WanIpAddress);
|
| 7404 | return addrInfo;
|
| 7405 | },
|
| 7406 | cachedAPStationBasic: null,
|
| 7407 | cachedConnectionMode: null,
|
| 7408 | getCanConnectNetWork: function (param) {
|
| 7409 | var status = fnc.getStatusInfo();
|
| 7410 | if (status.simStatus != "modem_init_complete") {
|
| 7411 | return false;
|
| 7412 | }
|
| 7413 | var typeNetworkTmp = status.networkType.toLowerCase();
|
| 7414 | if (typeNetworkTmp == 'searching') {
|
| 7415 | return false;
|
| 7416 | }
|
| 7417 | if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
|
| 7418 | typeNetworkTmp = 'limited_service';
|
| 7419 | }
|
| 7420 | if (typeNetworkTmp == 'no service') {
|
| 7421 | typeNetworkTmp = 'no_service';
|
| 7422 | }
|
| 7423 | if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
|
| 7424 | if (param.cStatus() != connStat.CONNECTED) {
|
| 7425 | return false;
|
| 7426 | }
|
| 7427 | }
|
| 7428 | if (set.AP_STATION_SUPPORT) {
|
| 7429 | if (status.connectWifiStatus == "connect") {
|
| 7430 | if (status.ap_station_mode == "wifi_pref") {
|
| 7431 | return false;
|
| 7432 | }
|
| 7433 | }
|
| 7434 | }
|
| 7435 | return true;
|
| 7436 | },
|
| 7437 | doConnect: function () {
|
| 7438 | showLoading('connecting');
|
| 7439 | fnc.connect({}, function (data) {
|
| 7440 | if (data.result) {
|
| 7441 | successOverlay();
|
| 7442 | } else {
|
| 7443 | errorOverlay();
|
| 7444 | }
|
| 7445 | });
|
| 7446 | },
|
| 7447 | refreshHomeData: function (param) {
|
| 7448 | var info = fnc.getConnectionInfo();
|
| 7449 | param.connectStatus(info.connectStatus);
|
| 7450 | param.canConnect(this.getCanConnectNetWork(param));
|
| 7451 | param.networkType(homeUtil.getNetworkType(info.networkType));
|
| 7452 | if (info.connectStatus == "ppp_connected") {
|
| 7453 | param.current_Flux(transUnit(parseInt(info.data_counter.currentReceived, 10) + parseInt(info.data_counter.currentSent, 10), false));
|
| 7454 | param.connected_Time(transSecond2Time(info.data_counter.currentConnectedTime));
|
| 7455 | param.up_Speed(transUnit(info.data_counter.uploadRate, true));
|
| 7456 | param.down_Speed(transUnit(info.data_counter.downloadRate, true));
|
| 7457 | } else {
|
| 7458 | param.current_Flux(transUnit(0, false));
|
| 7459 | param.connected_Time(transSecond2Time(0));
|
| 7460 | param.up_Speed(transUnit(0, true));
|
| 7461 | param.down_Speed(transUnit(0, true));
|
| 7462 | }
|
| 7463 | param.trafficAlertEnable(info.limitVolumeEnable);
|
| 7464 | if (info.limitVolumeEnable) {
|
| 7465 | if (info.limitVolumeType == '1') {
|
| 7466 | param.trafficUsed(transUnit(parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10), false));
|
| 7467 | param.trafficLimited(transUnit(info.limitDataMonth, false));
|
| 7468 | } else {
|
| 7469 | param.trafficUsed(transSecond2Time(info.data_counter.monthlyConnectedTime));
|
| 7470 | param.trafficLimited(transSecond2Time(info.limitTimeMonth));
|
| 7471 | }
|
| 7472 | }
|
| 7473 | if (languageOld != window.language) {
|
| 7474 | languageOld = window.language;
|
| 7475 | num_refresh = 1;
|
| 7476 | }
|
| 7477 | if (param.showTraffic()) {
|
| 7478 | homeUtil.updateEcharts(info);
|
| 7479 | } else {
|
| 7480 | homeUtil.allFreeEcharts();
|
| 7481 | }
|
| 7482 | homeUtil.refreshStationInfo(param);
|
| 7483 | },
|
| 7484 | allFreeEcharts: function () {
|
| 7485 | var usedData = homeUtil.data.free;
|
| 7486 | usedData.value = 1;
|
| 7487 | usedData.selected = false;
|
| 7488 | usedData.name = libjq.i18n.prop("echarts_no");
|
| 7489 | chartOptions.series[0].data = [usedData];
|
| 7490 | chartOptions.title.text = '';
|
| 7491 | homeUtil.setEcharts(chartOptions, libjq.i18n.prop("echarts_no"));
|
| 7492 | },
|
| 7493 | getNetworkType: function (networkType) {
|
| 7494 | var typeNetworkTmp = networkType.toLowerCase();
|
| 7495 | if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
|
| 7496 | typeNetworkTmp = 'limited_service';
|
| 7497 | }
|
| 7498 | if (typeNetworkTmp == 'no service') {
|
| 7499 | typeNetworkTmp = 'no_service';
|
| 7500 | }
|
| 7501 | if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
|
| 7502 | return libjq.i18n.prop("network_type_" + typeNetworkTmp);
|
| 7503 | } else {
|
| 7504 | return networkType;
|
| 7505 | }
|
| 7506 | },
|
| 7507 | data: {
|
| 7508 | full: {
|
| 7509 | value: 30,
|
| 7510 | name: '��������',
|
| 7511 | itemStyle: {
|
| 7512 | normal: {
|
| 7513 | color: '#DF4313'
|
| 7514 | }
|
| 7515 | }
|
| 7516 | },
|
| 7517 | used: {
|
| 7518 | value: 30,
|
| 7519 | name: '��ʹ��',
|
| 7520 | itemStyle: {
|
| 7521 | normal: {
|
| 7522 | color: '#8CC916'
|
| 7523 | }
|
| 7524 | }
|
| 7525 | },
|
| 7526 | left1: {
|
| 7527 | value: 50,
|
| 7528 | name: '����ֵ��δʹ��',
|
| 7529 | itemStyle: {
|
| 7530 | normal: {
|
| 7531 | color: '#D8D8D8'
|
| 7532 | }
|
| 7533 | }
|
| 7534 | },
|
| 7535 | free: {
|
| 7536 | value: 50,
|
| 7537 | name: 'δʹ��',
|
| 7538 | itemStyle: {
|
| 7539 | normal: {
|
| 7540 | color: '#D8D8D8'
|
| 7541 | }
|
| 7542 | }
|
| 7543 | },
|
| 7544 | alert: {
|
| 7545 | value: 1,
|
| 7546 | name: '����ֵ',
|
| 7547 | itemStyle: {
|
| 7548 | normal: {
|
| 7549 | color: '#FF5500'
|
| 7550 | }
|
| 7551 | }
|
| 7552 | },
|
| 7553 | alarm: {
|
| 7554 | value: 19.7,
|
| 7555 | name: '������',
|
| 7556 | itemStyle: {
|
| 7557 | normal: {
|
| 7558 | color: '#8CC916'
|
| 7559 | }
|
| 7560 | }
|
| 7561 | },
|
| 7562 | start: {
|
| 7563 | value: 50,
|
| 7564 | name: '����ֵ��δʹ��',
|
| 7565 | itemStyle: {
|
| 7566 | normal: {
|
| 7567 | color: '#D8D8D8'
|
| 7568 | }
|
| 7569 | }
|
| 7570 | },
|
| 7571 | },
|
| 7572 | getDataInfo: function (value) {
|
| 7573 | return {
|
| 7574 | data: /\d+(.\d+)?/.exec(value)[0],
|
| 7575 | unit: /[A-Z]{1,2}/.exec(value)[0]
|
| 7576 | }
|
| 7577 | },
|
| 7578 | oldAlarmData: null,
|
| 7579 | oldUsedData: null,
|
| 7580 | updateEcharts: function (info) {
|
| 7581 | var startName = libjq.i18n.prop("echarts_no");
|
| 7582 | num_refresh++;
|
| 7583 | if (num_refresh % 10 != 2) {
|
| 7584 | return false;
|
| 7585 | }
|
| 7586 | var total = 0,
|
| 7587 | used = 0,
|
| 7588 | reach = 0,
|
| 7589 | left = 0,
|
| 7590 | alarm = 0,
|
| 7591 | left1 = 0;
|
| 7592 | if (info.limitVolumeEnable) {
|
| 7593 | startName = libjq.i18n.prop("echarts_used");
|
| 7594 | chartOptions.series[0].data = [];
|
| 7595 | if (info.limitVolumeType == '1') {
|
| 7596 | var limitedDataFormatted = transUnit(info.limitDataMonth, false);
|
| 7597 | chartOptions.series[0].data = [];
|
| 7598 | if (info.limitDataMonth == 0) {
|
| 7599 | var usedData = homeUtil.data.used;
|
| 7600 | usedData.value = 1;
|
| 7601 | usedData.selected = false;
|
| 7602 | usedData.name = libjq.i18n.prop("echarts_used");
|
| 7603 | chartOptions.series[0].data.push(usedData);
|
| 7604 | } else {
|
| 7605 | var dataInfo = homeUtil.getDataInfo(limitedDataFormatted);
|
| 7606 | total = dataInfo.data * homeUtil.getUnitValue(dataInfo.unit) * 1048576;
|
| 7607 | used = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
|
| 7608 | reach = total * info.limitVolumePercent / 100;
|
| 7609 | if (used >= total) {
|
| 7610 | var fullData = homeUtil.data.full;
|
| 7611 | fullData.value = 100;
|
| 7612 | fullData.name = libjq.i18n.prop("echarts_full");
|
| 7613 | chartOptions.series[0].data.push(fullData);
|
| 7614 | startName = libjq.i18n.prop("echarts_full");
|
| 7615 | } else {
|
| 7616 | if (reach - used > 0) {
|
| 7617 | left1 = reach - used;
|
| 7618 | left = total - reach;
|
| 7619 | } else {
|
| 7620 | alarm = used - reach;
|
| 7621 | left = total - used;
|
| 7622 | }
|
| 7623 | var usedData = homeUtil.data.used;
|
| 7624 | if (reach - used > 0) {
|
| 7625 | usedData.value = used;
|
| 7626 | } else {
|
| 7627 | usedData.value = reach;
|
| 7628 | }
|
| 7629 | usedData.name = libjq.i18n.prop("echarts_used");
|
| 7630 | chartOptions.series[0].data.push(usedData);
|
| 7631 | if (left1 > 0) {
|
| 7632 | var left1Data = homeUtil.data.left1;
|
| 7633 | left1Data.value = left1;
|
| 7634 | left1Data.name = libjq.i18n.prop("echarts_left1");
|
| 7635 | chartOptions.series[0].data.push(left1Data);
|
| 7636 | }
|
| 7637 | var alertData = homeUtil.data.alert;
|
| 7638 | alertData.value = total / 200;
|
| 7639 | alertData.name = libjq.i18n.prop("echarts_alert");
|
| 7640 | chartOptions.series[0].data.push(alertData);
|
| 7641 | if (alarm > 0) {
|
| 7642 | var alarmData = homeUtil.data.alarm;
|
| 7643 | alarmData.value = alarm;
|
| 7644 | alarmData.name = libjq.i18n.prop("echarts_alarm");
|
| 7645 | chartOptions.series[0].data.push(alarmData);
|
| 7646 | }
|
| 7647 | var freeData = homeUtil.data.free;
|
| 7648 | freeData.value = left;
|
| 7649 | freeData.name = libjq.i18n.prop("echarts_free");
|
| 7650 | chartOptions.series[0].data.push(freeData);
|
| 7651 | }
|
| 7652 | }
|
| 7653 | } else {
|
| 7654 | chartOptions.series[0].data = [];
|
| 7655 | if (info.limitTimeMonth == 0) {
|
| 7656 | var usedData = homeUtil.data.used;
|
| 7657 | usedData.value = 1;
|
| 7658 | usedData.selected = false;
|
| 7659 | usedData.name = libjq.i18n.prop("echarts_used");
|
| 7660 | chartOptions.series[0].data.push(usedData);
|
| 7661 | } else {
|
| 7662 | total = info.limitTimeMonth;
|
| 7663 | used = info.data_counter.monthlyConnectedTime;
|
| 7664 | reach = total * info.limitVolumePercent / 100;
|
| 7665 | if (used >= total) {
|
| 7666 | var fullTime = homeUtil.data.full;
|
| 7667 | fullTime.value = 100;
|
| 7668 | fullTime.name = libjq.i18n.prop("echarts_full");
|
| 7669 | chartOptions.series[0].data.push(fullTime);
|
| 7670 | startName = libjq.i18n.prop("echarts_full");
|
| 7671 | } else {
|
| 7672 | if (reach - used > 0) {
|
| 7673 | left1 = reach - used;
|
| 7674 | left = total - reach;
|
| 7675 | } else {
|
| 7676 | alarm = used - reach;
|
| 7677 | left = total - used;
|
| 7678 | }
|
| 7679 | var usedTime = homeUtil.data.used;
|
| 7680 | if (reach - used > 0) {
|
| 7681 | usedTime.value = used;
|
| 7682 | } else {
|
| 7683 | usedTime.value = reach;
|
| 7684 | }
|
| 7685 | usedTime.name = libjq.i18n.prop("echarts_used");
|
| 7686 | chartOptions.series[0].data.push(usedTime);
|
| 7687 | if (left1 > 0) {
|
| 7688 | var left1Time = homeUtil.data.left1;
|
| 7689 | left1Time.value = left1;
|
| 7690 | left1Time.name = libjq.i18n.prop("echarts_left1");
|
| 7691 | chartOptions.series[0].data.push(left1Time);
|
| 7692 | }
|
| 7693 | var alertTime = homeUtil.data.alert;
|
| 7694 | alertTime.value = total / 200;
|
| 7695 | alertTime.name = libjq.i18n.prop("echarts_alert");
|
| 7696 | chartOptions.series[0].data.push(alertTime);
|
| 7697 | if (alarm > 0) {
|
| 7698 | var alarmTime = homeUtil.data.alarm;
|
| 7699 | alarmTime.value = alarm;
|
| 7700 | alarmTime.name = libjq.i18n.prop("echarts_alarm");
|
| 7701 | chartOptions.series[0].data.push(alarmTime);
|
| 7702 | }
|
| 7703 | var freeTime = homeUtil.data.free;
|
| 7704 | freeTime.value = left;
|
| 7705 | freeTime.name = libjq.i18n.prop("echarts_free");
|
| 7706 | chartOptions.series[0].data.push(freeTime);
|
| 7707 | }
|
| 7708 | }
|
| 7709 | }
|
| 7710 | } else {
|
| 7711 | var usedData = homeUtil.data.used;
|
| 7712 | usedData.value = 1;
|
| 7713 | usedData.selected = false;
|
| 7714 | usedData.name = libjq.i18n.prop("echarts_no");
|
| 7715 | chartOptions.series[0].data = [usedData];
|
| 7716 | chartOptions.title.text = '';
|
| 7717 | }
|
| 7718 | var firstEle = libus.find(chartOptions.series[0].data, function (n) {
|
| 7719 | return n.name == libjq.i18n.prop("echarts_used");
|
| 7720 | });
|
| 7721 | var alarmEle = libus.find(chartOptions.series[0].data, function (n) {
|
| 7722 | return n.name == libjq.i18n.prop("echarts_alarm");
|
| 7723 | });
|
| 7724 | if (!alarmEle) {
|
| 7725 | alarmEle = {
|
| 7726 | value: 0
|
| 7727 | };
|
| 7728 | }
|
| 7729 | if (typeof firstEle == "undefined") {
|
| 7730 | homeUtil.setEcharts(chartOptions, startName);
|
| 7731 | } else if (homeUtil.oldUsedData != firstEle.value || homeUtil.oldAlarmData != alarmEle.value) {
|
| 7732 | homeUtil.oldUsedData = firstEle.value;
|
| 7733 | homeUtil.oldAlarmData = alarmEle.value;
|
| 7734 | homeUtil.setEcharts(chartOptions, startName);
|
| 7735 | }
|
| 7736 | },
|
| 7737 | getUnitValue: function (unit) {
|
| 7738 | unit = unit.toUpperCase();
|
| 7739 | if (unit == 'GB') {
|
| 7740 | return '1024';
|
| 7741 | } else if (unit == 'TB') {
|
| 7742 | return '1048576';
|
| 7743 | } else {
|
| 7744 | return '1';
|
| 7745 | }
|
| 7746 | },
|
| 7747 | setEcharts: function (options, startName) {
|
| 7748 | var startPart = homeUtil.data.start;
|
| 7749 | startPart.value = 0;
|
| 7750 | startPart.name = startName;
|
| 7751 | startPart.selected = false;
|
| 7752 | var arr = [startPart].concat(options.series[0].data);
|
| 7753 | options.series[0].data = arr;
|
| 7754 | traffic_graphic_chart.setOption(options, true);
|
| 7755 | addTimeout(function () {
|
| 7756 | traffic_graphic_chart.resize();
|
| 7757 | }, 1000);
|
| 7758 | },
|
| 7759 | refreshStationInfo: function (param) {
|
| 7760 | param.wirelessDeviceNum(fnc.getStatusInfo().wirelessDeviceNum);
|
| 7761 | if (num_refresh % 10 == 2) {
|
| 7762 | fnc.getAttachedCableDevices({}, function (data) {
|
| 7763 | param.wireDeviceNum(data.attachedDevices.length);
|
| 7764 | });
|
| 7765 | }
|
| 7766 | },
|
| 7767 | getUnit: function (val) {
|
| 7768 | if (val == '1024') {
|
| 7769 | return 'GB';
|
| 7770 | } else if (val == '1048576') {
|
| 7771 | return 'TB';
|
| 7772 | } else {
|
| 7773 | return 'MB';
|
| 7774 | }
|
| 7775 | },
|
| 7776 | refreshOpmodeInfo: function (param) {
|
| 7777 | var obj = fnc.getOpMode();
|
| 7778 | param.isLoggedIn(obj.loginfo == "ok");
|
| 7779 | var currentMode = checkCableMode(obj.blc_wan_mode);
|
| 7780 | if (param.opCurMode() && !currentMode) {
|
| 7781 | var data = fnc.getLoginData();
|
| 7782 | var state = data.modem_main_state;
|
| 7783 | if (state == "modem_sim_undetected" || state == "modem_undetected" || state == "modem_sim_destroy" || state == "modem_waitpin" || state == "modem_waitpuk" || state == "modem_imsi_waitnck") {
|
| 7784 | window.location.reload();
|
| 7785 | return;
|
| 7786 | }
|
| 7787 | }
|
| 7788 | param.opCurMode(currentMode);
|
| 7789 | if (currentMode && obj.ethwan_mode == "DHCP") {
|
| 7790 | param.enableFlag(false);
|
| 7791 | } else if ((!currentMode && obj.ppp_status != "ppp_disconnected") || (currentMode && obj.rj45_state != "idle" && obj.rj45_state != "dead")) {
|
| 7792 | param.enableFlag(true);
|
| 7793 | } else {
|
| 7794 | param.enableFlag(false);
|
| 7795 | }
|
| 7796 | var mode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;
|
| 7797 | var currentOpMode = "";
|
| 7798 | switch (mode) {
|
| 7799 | case "AUTO":
|
| 7800 | currentOpMode = "opmode_auto";
|
| 7801 | break;
|
| 7802 | case "PPPOE":
|
| 7803 | currentOpMode = "opmode_cable";
|
| 7804 | break;
|
| 7805 | case "PPP":
|
| 7806 | currentOpMode = "opmode_gateway";
|
| 7807 | break;
|
| 7808 | default:
|
| 7809 | break;
|
| 7810 | }
|
| 7811 | libjq("#opmode").attr("data-trans", currentOpMode).text(libjq.i18n.prop(currentOpMode));
|
| 7812 | param.isShowHomeConnect(!currentMode);
|
| 7813 | param.showTraffic(set.TRAFFIC_SUPPORT && !currentMode);
|
| 7814 | param.isSupportQuicksetting(set.HAS_QUICK_SETTING && !currentMode);
|
| 7815 | }
|
| 7816 | };
|
| 7817 | function VmHome() {
|
| 7818 | var target = this;
|
| 7819 | target.hasSms = set.HAS_SMS;
|
| 7820 | target.hasPhonebook = set.HAS_PHONEBOOK;
|
| 7821 | target.isSupportSD = set.SD_CARD_SUPPORT;
|
| 7822 | target.isCPE = set.PRODUCT_TYPE == 'CPE';
|
| 7823 | target.hasRj45 = set.RJ45_SUPPORT;
|
| 7824 | target.notDataCard = set.PRODUCT_TYPE != 'DATACARD';
|
| 7825 | target.hasParentalControl = set.HAS_PARENTAL_CONTROL;
|
| 7826 | target.hasUssd = set.HAS_USSD;
|
| 7827 | var wifiInfo = fnc.getWifiBasic();
|
| 7828 | if (set.WIFI_SUPPORT_QR_SWITCH) {
|
| 7829 | target.showQRCode = set.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;
|
| 7830 | } else {
|
| 7831 | target.showQRCode = set.WIFI_SUPPORT_QR_CODE;
|
| 7832 | }
|
| 7833 | if(set.WIFI_SUPPORT_QR_CODE){
|
| 7834 | target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + libjq.now();
|
| 7835 | } else {
|
| 7836 | target.qrcodeSrc = './pic/res_blacktrans.png';
|
| 7837 | }
|
| 7838 | if (target.hasRj45) {
|
| 7839 | var opModeObj = checkCableMode(fnc.getOpMode().blc_wan_mode);
|
| 7840 | target.opCurMode = libko.observable(opModeObj);
|
| 7841 | target.isShowHomeConnect = libko.observable(!opModeObj);
|
| 7842 | target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT && !opModeObj);
|
| 7843 | target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING && !opModeObj);
|
| 7844 | } else {
|
| 7845 | target.isShowHomeConnect = libko.observable(true);
|
| 7846 | target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT);
|
| 7847 | target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING);
|
| 7848 | }
|
| 7849 | if (set.PRODUCT_TYPE == 'DATACARD') {
|
| 7850 | libjq('#home_image').addClass('data-card');
|
| 7851 | }
|
| 7852 | var info = fnc.getConnectionInfo();
|
| 7853 | target.networkType = libko.observable(homeUtil.getNetworkType(info.networkType));
|
| 7854 | target.connectStatus = libko.observable(info.connectStatus);
|
| 7855 | target.canConnect = libko.observable(false);
|
| 7856 | target.cStatus = libko.computed(function () {
|
| 7857 | if (target.connectStatus().indexOf('_connected') != -1) {
|
| 7858 | return connStat.CONNECTED;
|
| 7859 | } else if (target.connectStatus().indexOf('_disconnecting') != -1) {
|
| 7860 | return connStat.DISCONNECTING;
|
| 7861 | } else if (target.connectStatus().indexOf('_connecting') != -1) {
|
| 7862 | return connStat.CONNECTING;
|
| 7863 | } else {
|
| 7864 | return connStat.DISCONNECTED;
|
| 7865 | }
|
| 7866 | });
|
| 7867 | target.current_Flux = libko.observable(transUnit(0, false));
|
| 7868 | target.connected_Time = libko.observable(transSecond2Time(0));
|
| 7869 | target.up_Speed = libko.observable(transUnit(0, true));
|
| 7870 | target.down_Speed = libko.observable(transUnit(0, true));
|
| 7871 | target.isLoggedIn = libko.observable(false);
|
| 7872 | target.enableFlag = libko.observable(true);
|
| 7873 | target.simSerialNumber = libko.observable('');
|
| 7874 | target.imei = libko.observable('');
|
| 7875 | target.imsi = libko.observable('');
|
| 7876 | target.iccid = libko.observable('');
|
| 7877 | target.cellid = libko.observable('');
|
| 7878 | target.ssid = libko.observable('');
|
| 7879 | target.hasWifi = set.HAS_WIFI;
|
| 7880 | target.showMultiSsid = libko.observable(set.HAS_MULTI_SSID && wifiInfo.multi_ssid_enable == "1");
|
| 7881 | target.trafficAlertEnable = libko.observable(false);
|
| 7882 | target.trafficUsed = libko.observable('');
|
| 7883 | target.trafficLimited = libko.observable('');
|
| 7884 | target.wireDeviceNum = libko.observable(fnc.getAttachedCableDevices().attachedDevices.length);
|
| 7885 | target.wirelessDeviceNum = libko.observable(fnc.getStatusInfo().wirelessDeviceNum);
|
| 7886 | target.showOpModeWindow = function () {
|
| 7887 | if (target.enableFlag()) {
|
| 7888 | return;
|
| 7889 | }
|
| 7890 | showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});
|
| 7891 | };
|
| 7892 | target.currentOpMode = libko.observable("0");
|
| 7893 | var popoverShown = false;
|
| 7894 | libjq('#showDetailInfo').popover({
|
| 7895 | html: true,
|
| 7896 | placement: 'top',
|
| 7897 | trigger: 'focus',
|
| 7898 | title: function () {
|
| 7899 | return libjq.i18n.prop('device_info')
|
| 7900 | },
|
| 7901 | content: function () {
|
| 7902 | return getDetailInfoContent();
|
| 7903 | }
|
| 7904 | }).on('shown.bs.popover', function () {
|
| 7905 | popoverShown = true;
|
| 7906 | }).on('hidden.bs.popover', function () {
|
| 7907 | popoverShown = false;
|
| 7908 | });
|
| 7909 | function fetchDeviceInfo() {
|
| 7910 | var data = fnc.getDeviceInfo();
|
| 7911 | target.simSerialNumber(verifyDeviceInfo(data.simSerialNumber));
|
| 7912 | target.imei(verifyDeviceInfo(data.imei));
|
| 7913 | target.imsi(verifyDeviceInfo(data.imsi));
|
| 7914 | target.iccid(verifyDeviceInfo(data.iccid));
|
| 7915 | target.cellid(verifyDeviceInfo(data.cellid));
|
| 7916 | target.ssid(verifyDeviceInfo(data.ssid));
|
| 7917 | target.showMultiSsid(set.HAS_MULTI_SSID && data.multi_ssid_enable == "1");
|
| 7918 | return data;
|
| 7919 | }
|
| 7920 | fetchDeviceInfo();
|
| 7921 | function getDetailInfoContent() {
|
| 7922 | var data = fetchDeviceInfo();
|
| 7923 | homeUtil.initShownStatus(data);
|
| 7924 | var addrInfo = homeUtil.wanIpGet(data);
|
| 7925 | var compiled = libus.template(libjq("#detailInfoTmpl").html());
|
| 7926 | var tmpl = compiled({
|
| 7927 | simSerialNumber: verifyDeviceInfo(data.simSerialNumber),
|
| 7928 | imei: verifyDeviceInfo(data.imei),
|
| 7929 | imsi: verifyDeviceInfo(data.imsi),
|
| 7930 | iccid : verifyDeviceInfo(data.iccid),
|
| 7931 | cellid: verifyDeviceInfo(data.cellid),
|
| 7932 | signal: signalFormat(data.signal),
|
| 7933 | hasWifi: set.HAS_WIFI,
|
| 7934 | isCPE: set.PRODUCT_TYPE == 'CPE',
|
| 7935 | hasRj45: set.RJ45_SUPPORT,
|
| 7936 | showMultiSsid: set.HAS_MULTI_SSID && data.multi_ssid_enable == "1",
|
| 7937 | ssid: verifyDeviceInfo(data.ssid),
|
| 7938 | max_access_num: verifyDeviceInfo(data.max_access_num),
|
| 7939 | m_ssid: verifyDeviceInfo(data.m_ssid),
|
| 7940 | m_max_access_num: verifyDeviceInfo(data.m_max_access_num),
|
| 7941 | wifi_long_mode: "wifi_des_" + data.wifiRange,
|
| 7942 | lanDomain: verifyDeviceInfo(data.lanDomain),
|
| 7943 | ipAddress: verifyDeviceInfo(data.ipAddress),
|
| 7944 | showMacAddress: set.SHOW_MAC_ADDRESS,
|
| 7945 | macAddress: verifyDeviceInfo(data.macAddress),
|
| 7946 | showIpv4WanIpAddr: homeUtil.initStatus.showIpv4WanIpAddr,
|
| 7947 | wanIpAddress: addrInfo.wanIpAddress,
|
| 7948 | showIpv6WanIpAddr: homeUtil.initStatus.showIpv6WanIpAddr,
|
| 7949 | ipv6WanIpAddress: addrInfo.ipv6WanIpAddress,
|
| 7950 | sw_version: verifyDeviceInfo(data.sw_version),
|
| 7951 | hw_version: verifyDeviceInfo(data.hw_version)
|
| 7952 | });
|
| 7953 | return libjq(tmpl).translate();
|
| 7954 | }
|
| 7955 | target.connectHandler = function () {
|
| 7956 | if (target.connectStatus() == "ppp_connected") {
|
| 7957 | showLoading('disconnecting');
|
| 7958 | fnc.disconnect({}, function (data) {
|
| 7959 | if (data.result) {
|
| 7960 | successOverlay();
|
| 7961 | } else {
|
| 7962 | errorOverlay();
|
| 7963 | }
|
| 7964 | });
|
| 7965 | } else {
|
| 7966 | if (fnc.getStatusInfo().roamingStatus) {
|
| 7967 | showConfirm('dial_roaming_connect', function () {
|
| 7968 | target.connect();
|
| 7969 | });
|
| 7970 | } else {
|
| 7971 | target.connect();
|
| 7972 | }
|
| 7973 | }
|
| 7974 | };
|
| 7975 | target.connect = function () {
|
| 7976 | var statusInfo = fnc.getStatusInfo();
|
| 7977 | var trafficResult = barStat.getTrafficResult(statusInfo);
|
| 7978 | if (statusInfo.limitVolumeEnable && trafficResult.showConfirm) {
|
| 7979 | var confirmMsg = null;
|
| 7980 | if (trafficResult.usedPercent > 100) {
|
| 7981 | confirmMsg = {
|
| 7982 | msg: 'traffic_beyond_connect_msg'
|
| 7983 | };
|
| 7984 | barStat.setTrafficAlertPopuped(true);
|
| 7985 | } else {
|
| 7986 | confirmMsg = {
|
| 7987 | msg: 'traffic_limit_connect_msg',
|
| 7988 | params: [trafficResult.limitPercent]
|
| 7989 | };
|
| 7990 | barStat.setTrafficAlert100Popuped(false);
|
| 7991 | }
|
| 7992 | showConfirm(confirmMsg, function () {
|
| 7993 | homeUtil.doConnect();
|
| 7994 | });
|
| 7995 | } else {
|
| 7996 | homeUtil.doConnect();
|
| 7997 | }
|
| 7998 | };
|
| 7999 | fnc.getSignalStrength({}, function (data) {
|
| 8000 | var signalTxt = signalFormat(convertSignal(data));
|
| 8001 | libjq("#fresh_signal_strength").text(signalTxt);
|
| 8002 | if (popoverShown) {
|
| 8003 | libjq("#popoverSignalTxt").text(signalTxt);
|
| 8004 | }
|
| 8005 | });
|
| 8006 | homeUtil.refreshHomeData(target);
|
| 8007 | addInterval(function () {
|
| 8008 | fnc.getSignalStrength({}, function (data) {
|
| 8009 | var signalTxt = signalFormat(convertSignal(data));
|
| 8010 | libjq("#fresh_signal_strength").text(signalTxt);
|
| 8011 | if (popoverShown) {
|
| 8012 | libjq("#popoverSignalTxt").text(signalTxt);
|
| 8013 | }
|
| 8014 | });
|
| 8015 | homeUtil.refreshHomeData(target);
|
| 8016 | }, 1000);
|
| 8017 | if (target.hasRj45) {
|
| 8018 | homeUtil.refreshOpmodeInfo(target);
|
| 8019 | addInterval(function () {
|
| 8020 | homeUtil.refreshOpmodeInfo(target);
|
| 8021 | }, 1000);
|
| 8022 | }
|
| 8023 | target.showNetworkSettingsWindow = function () {
|
| 8024 | if (target.hasRj45) {
|
| 8025 | fnc.getOpMode({}, function (data) {
|
| 8026 | var mode = checkCableMode(data.blc_wan_mode);
|
| 8027 | if (mode) {
|
| 8028 | window.location.hash = '#network_set';
|
| 8029 | } else {
|
| 8030 | window.location.hash = '#conn_set';
|
| 8031 | }
|
| 8032 | });
|
| 8033 | } else {
|
| 8034 | window.location.hash = '#conn_set';
|
| 8035 | }
|
| 8036 | }
|
| 8037 | };
|
| 8038 | return {
|
| 8039 | init: init
|
| 8040 | };
|
| 8041 | });
|
| 8042 |
|
| 8043 |
|
| 8044 | define("language","knockout service jquery set underscore".split(" "),
|
| 8045 | function(ko, service, $, config, _) {
|
| 8046 |
|
| 8047 | // ��ȡ��ǰ������
|
| 8048 | function getCurrentLanguage() {
|
| 8049 | return service.getLanguage();
|
| 8050 | }
|
| 8051 |
|
| 8052 | // ��������������������Դ������ҳ���ϵ�body����
|
| 8053 | // @param {String} current ������:zh-cn
|
| 8054 | function loadLanguageAndRefresh(current){
|
| 8055 | window.CURRENT_LANGUAGE = current;
|
| 8056 | $("body").attr('lang', current);
|
| 8057 | $.i18n.properties({
|
| 8058 | name:'Messages',
|
| 8059 | path:'i18n/',
|
| 8060 | mode:'map',
|
| 8061 | cache: true,
|
| 8062 | language:current,
|
| 8063 | callback: function() {
|
| 8064 | jQuery.validator.messages = $.i18n.map;
|
| 8065 | $('body').translate();
|
| 8066 | }
|
| 8067 | });
|
| 8068 | }
|
| 8069 |
|
| 8070 | window.language = null;
|
| 8071 |
|
| 8072 |
|
| 8073 | function LanguageViewModel() {
|
| 8074 | var target = this;
|
| 8075 | var currentLan = getCurrentLanguage();
|
| 8076 | var languages = _.map(config.LANGUAGES, function(item) {
|
| 8077 | return new Option(item.name, item.value);
|
| 8078 | });
|
| 8079 |
|
| 8080 | document.title = config.WEBUI_TITLE;
|
| 8081 | if($('#webui_title')[0]) {
|
| 8082 | $('#webui_title').html(config.WEBUI_TITLE);
|
| 8083 | }
|
| 8084 |
|
| 8085 | target.languages = ko.observableArray(languages);
|
| 8086 | target.currentLan = ko.observable(currentLan.Language);
|
| 8087 | window.language = target.currentLan();
|
| 8088 |
|
| 8089 | // �л������¼�����
|
| 8090 | // @event langChangeHandler
|
| 8091 | target.langChangeHandler = function(info, event) {
|
| 8092 | clearValidateMsg();
|
| 8093 |
|
| 8094 | service.setLanguage({Language: target.currentLan()}, function() {
|
| 8095 | loadLanguageAndRefresh(target.currentLan());
|
| 8096 | window.language = target.currentLan();
|
| 8097 | });
|
| 8098 | };
|
| 8099 |
|
| 8100 | // ���������б���ˢ�½���
|
| 8101 | loadLanguageAndRefresh(target.currentLan());
|
| 8102 | }
|
| 8103 |
|
| 8104 | // ��ʼ������VM������
|
| 8105 | function init() {
|
| 8106 | ko.applyBindings(new LanguageViewModel(), $('#language')[0]);
|
| 8107 | }
|
| 8108 |
|
| 8109 | return {
|
| 8110 | init: init
|
| 8111 | };
|
| 8112 | });
|
| 8113 |
|
| 8114 |
|
| 8115 | // ��½ ģ��
|
| 8116 | define("entry","jquery knockout set service underscore menu logout CryptoJS".split(" "),
|
| 8117 | function($, ko,config, service, _, menu, logout, CryptoJS) {
|
| 8118 |
|
| 8119 |
|
| 8120 | var pageState = {LOGIN:0, WAIT_PIN:1, WAIT_PUK:2, PUK_LOCKED:3, LOGGEDIN:4, LOADING:5};
|
| 8121 | var timer = loginStatusCheckingTimer();
|
| 8122 | var loginLockTimer = 0;
|
| 8123 | var lastLoginStatus = "0";
|
| 8124 |
|
| 8125 | function loginViewModel() {
|
| 8126 | var target = this;
|
| 8127 | var data = service.getLoginData();
|
| 8128 | var loginStatus = service.getLoginStatus();
|
| 8129 |
|
| 8130 | target.confirmPIN = ko.observable();
|
| 8131 | target.leftSeconds = ko.observable(0);
|
| 8132 | target.loginCount = ko.observable(0);
|
| 8133 | target.loginSecuritySupport = ko.observable(config.LOGIN_SECURITY_SUPPORT);
|
| 8134 | target.newPIN = ko.observable();
|
| 8135 | target.password = ko.observable();
|
w.deng | ccefa88 | 2025-04-10 20:17:16 -0700 | [diff] [blame^] | 8136 | target.username = ko.observable();
|
you.chen | 808f8ef | 2025-04-02 13:58:10 +0800 | [diff] [blame] | 8137 | target.PIN = ko.observable();
|
| 8138 | target.pinNumber = ko.observable(data.pinnumber);
|
| 8139 | target.PUK = ko.observable();
|
| 8140 | target.pukNumber = ko.observable(data.puknumber);
|
| 8141 | target.showEntrance = ko.observable(false);
|
| 8142 | target.sharePathInvalid = ko.observable(false);
|
| 8143 | target.uiLoginTimer = ko.observable(300);
|
| 8144 |
|
| 8145 | // ע��˳�򣬵���ǰ�����޷�ˢ�³�����
|
| 8146 | target.accountLocked = ko.computed(function () {
|
| 8147 | return target.loginCount() == config.MAX_LOGIN_COUNT && target.leftSeconds() != '-1';
|
| 8148 | });
|
| 8149 |
|
| 8150 | target.leftUnlockTime = ko.computed(function () {
|
| 8151 | target.leftSeconds();
|
| 8152 | var formatted = transSecond2Time(target.uiLoginTimer());
|
| 8153 | return formatted.substring(formatted.indexOf(':') + 1, formatted.length);
|
| 8154 | });
|
| 8155 |
|
| 8156 |
|
| 8157 | if(config.SD_CARD_SUPPORT){
|
| 8158 | service.getSDConfiguration({}, function (data) {
|
| 8159 | target.showEntrance(data.sd_status == "1" && data.share_status == "1" && data.sd_mode == "0");
|
| 8160 | if(target.showEntrance()){
|
| 8161 | service.checkFileExists({
|
| 8162 | path: data.share_file
|
| 8163 | }, function (data1) {
|
| 8164 | if (data1.status == 'exist' || data1.status == 'processing') {
|
| 8165 | target.sharePathInvalid(false);
|
| 8166 | } else {
|
| 8167 | target.sharePathInvalid(true);
|
| 8168 | }
|
| 8169 | });
|
| 8170 | }
|
| 8171 | });
|
| 8172 | }
|
| 8173 |
|
| 8174 | var state = computePageState(loginStatus, data);
|
| 8175 | target.pageState = ko.observable(state);
|
| 8176 | if (state == pageState.LOADING) {
|
| 8177 | addTimeout(refreshPage, 500);
|
| 8178 | }
|
| 8179 | setFocus();
|
| 8180 |
|
| 8181 |
|
| 8182 | // login �¼�����
|
| 8183 |
|
| 8184 | target.login = function () {
|
| 8185 | if(config.LOGIN_SECURITY_SUPPORT && target.accountLocked()){
|
| 8186 | showAlert("password_error_account_lock_time", function () {
|
| 8187 | setFocus();
|
| 8188 | });
|
| 8189 | return false;
|
| 8190 | }
|
| 8191 | target.pageState(pageState.LOADING);
|
| 8192 | window.clearInterval(timer);
|
| 8193 | var ciphertext = "";
|
| 8194 | if (config.PASSWORD_ENCODE) {
|
| 8195 | ciphertext = target.password();
|
w.deng | ccefa88 | 2025-04-10 20:17:16 -0700 | [diff] [blame^] | 8196 | var username = target.username();
|
you.chen | 808f8ef | 2025-04-02 13:58:10 +0800 | [diff] [blame] | 8197 | } else {
|
| 8198 | var kparam = service.getDeviceInfoLow();
|
| 8199 | var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
|
| 8200 | var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
|
| 8201 | ciphertext = CryptoJS.AES.encrypt(target.password(), tkey, {
|
| 8202 | iv: tiv,
|
| 8203 | mode: CryptoJS.mode.CBC,
|
| 8204 | padding: CryptoJS.pad.ZeroPadding
|
| 8205 | }).toString();
|
| 8206 | }
|
| 8207 | service.login({
|
w.deng | ccefa88 | 2025-04-10 20:17:16 -0700 | [diff] [blame^] | 8208 | password:ciphertext,
|
| 8209 | username: username
|
you.chen | 808f8ef | 2025-04-02 13:58:10 +0800 | [diff] [blame] | 8210 | }, function (info) {
|
| 8211 | setTimeout(function () {
|
| 8212 | timer = loginStatusCheckingTimer();
|
| 8213 | }, 1300);
|
| 8214 | if (info.result) {
|
| 8215 | target.pageState(pageState.LOGGEDIN);
|
| 8216 | if(config.LOGIN_SECURITY_SUPPORT){
|
| 8217 | target.loginCount(0);
|
| 8218 | target.uiLoginTimer(300);
|
| 8219 | clearInterval(loginLockTimer);
|
| 8220 | }
|
| 8221 | $("#container").empty();
|
| 8222 | window.location.hash = "#main";
|
| 8223 | logout.init();
|
| 8224 | } else {
|
| 8225 | target.password("");
|
w.deng | ccefa88 | 2025-04-10 20:17:16 -0700 | [diff] [blame^] | 8226 | target.username("");
|
you.chen | 808f8ef | 2025-04-02 13:58:10 +0800 | [diff] [blame] | 8227 | if(config.LOGIN_SECURITY_SUPPORT){
|
| 8228 | target.checkLoginData(function(){
|
| 8229 | if (target.loginCount() == config.MAX_LOGIN_COUNT) {
|
| 8230 | showAlert("password_error_five_times", function () {
|
| 8231 | setFocus();
|
| 8232 | });
|
| 8233 | target.startLoginLockInterval();
|
| 8234 | } else {
|
| 8235 | showAlert({msg: 'password_error_left', params: [config.MAX_LOGIN_COUNT - target.loginCount()]}, function () {
|
| 8236 | setFocus();
|
| 8237 | });
|
| 8238 | }
|
| 8239 | });
|
| 8240 | }else {
|
| 8241 | showAlert("password_error", function () {
|
| 8242 | setFocus();
|
| 8243 | });
|
| 8244 | }
|
| 8245 | target.pageState(pageState.LOGIN);
|
| 8246 | }
|
| 8247 | });
|
| 8248 | };
|
| 8249 |
|
| 8250 |
|
| 8251 |
|
| 8252 |
|
| 8253 | // ��ȡ��¼������Ϣ
|
| 8254 | target.checkLoginData = function(cb){
|
| 8255 | service.getLoginData({}, function(r){
|
| 8256 | var failTimes = parseInt(r.psw_fail_num_str, 10);
|
| 8257 | target.loginCount(config.MAX_LOGIN_COUNT - failTimes);
|
| 8258 | target.leftSeconds(r.login_lock_time);
|
| 8259 | target.uiLoginTimer(r.login_lock_time);
|
| 8260 | if($.isFunction(cb)){
|
| 8261 | cb();
|
| 8262 | } else if (target.loginCount() == config.MAX_LOGIN_COUNT) {
|
| 8263 | target.startLoginLockInterval();
|
| 8264 | }
|
| 8265 | });
|
| 8266 | };
|
| 8267 |
|
| 8268 | // ��������ʱ��ʱ����
|
| 8269 | target.startLoginLockInterval = function () {
|
| 8270 | loginLockTimer = setInterval(function () {
|
| 8271 | service.getLoginData({}, function (data) {
|
| 8272 | if (data.login_lock_time <= 0 || data.psw_fail_num_str == 5) {
|
| 8273 | target.loginCount(0);
|
| 8274 | clearInterval(loginLockTimer);
|
| 8275 | }
|
| 8276 | if(target.leftSeconds() != data.login_lock_time){
|
| 8277 | target.leftSeconds(data.login_lock_time);
|
| 8278 | target.uiLoginTimer(data.login_lock_time);
|
| 8279 | } else {
|
| 8280 | target.uiLoginTimer(target.uiLoginTimer() > 0 ? target.uiLoginTimer() - 1 : 0);
|
| 8281 | }
|
| 8282 | });
|
| 8283 | }, 1000);
|
| 8284 | };
|
| 8285 |
|
| 8286 | target.checkLoginData();
|
| 8287 |
|
| 8288 |
|
| 8289 |
|
| 8290 | // ��֤����PIN�¼�����
|
| 8291 | target.enterPIN = function () {
|
| 8292 | target.pageState(pageState.LOADING);
|
| 8293 | var pin = target.PIN();
|
| 8294 | service.enterPIN({
|
| 8295 | PinNumber:pin
|
| 8296 | }, function (data) {
|
| 8297 | if (!data.result) {
|
| 8298 | showAlert("pin_error", function () {
|
| 8299 | refreshPage();
|
| 8300 | });
|
| 8301 | target.PIN('');
|
| 8302 | } else {
|
| 8303 | refreshPage();
|
| 8304 | }
|
| 8305 | });
|
| 8306 | };
|
| 8307 |
|
| 8308 | function setFocus(){
|
| 8309 | setTimeout(function () {
|
| 8310 | var txtAdmin = $('#txtAdmin:visible');
|
w.deng | ccefa88 | 2025-04-10 20:17:16 -0700 | [diff] [blame^] | 8311 | var txtUser = $('#txtUser:visible');
|
you.chen | 808f8ef | 2025-04-02 13:58:10 +0800 | [diff] [blame] | 8312 | var txtPIN = $('#txtPIN:visible');
|
| 8313 | var txtPUK = $('#txtPUK:visible');
|
w.deng | ccefa88 | 2025-04-10 20:17:16 -0700 | [diff] [blame^] | 8314 | if(txtUser.length > 0) {
|
| 8315 | txtUser.focus();
|
| 8316 | } else if (txtAdmin.length > 0) {
|
you.chen | 808f8ef | 2025-04-02 13:58:10 +0800 | [diff] [blame] | 8317 | txtAdmin.focus();
|
| 8318 | } else if (txtPIN.length > 0) {
|
| 8319 | txtPIN.focus();
|
| 8320 | } else if (txtPUK.length > 0) {
|
| 8321 | txtPUK.focus();
|
| 8322 | }
|
| 8323 | }, 100);
|
| 8324 | }
|
| 8325 |
|
| 8326 |
|
| 8327 | // ˢ��ҳ��״̬
|
| 8328 | function refreshPage() {
|
| 8329 | var data = service.getLoginData();
|
| 8330 | var loginStatus = service.getLoginStatus();
|
| 8331 | var state = computePageState(loginStatus, data);
|
| 8332 | if (state == pageState.LOADING) {
|
| 8333 | addTimeout(refreshPage, 500);
|
| 8334 | } else {
|
| 8335 | target.pageState(state);
|
| 8336 | target.pinNumber(data.pinnumber);
|
| 8337 | target.pukNumber(data.puknumber);
|
| 8338 | }
|
| 8339 | setFocus();
|
| 8340 | }
|
| 8341 |
|
| 8342 | // ����PUK������PIN�¼�����
|
| 8343 | target.enterPUK = function () {
|
| 8344 | target.pageState(pageState.LOADING);
|
| 8345 | var newPIN = target.newPIN();
|
| 8346 | var confirmPIN = target.confirmPIN();
|
| 8347 | var params = {};
|
| 8348 | params.PinNumber = newPIN;
|
| 8349 | params.PUKNumber = target.PUK();
|
| 8350 | service.enterPUK(params, function (data) {
|
| 8351 | if (!data.result) {
|
| 8352 | showAlert("puk_error", function () {
|
| 8353 | refreshPage();
|
| 8354 | });
|
| 8355 | target.PUK('');
|
| 8356 | target.newPIN('');
|
| 8357 | target.confirmPIN('');
|
| 8358 | } else {
|
| 8359 | refreshPage();
|
| 8360 | }
|
| 8361 | });
|
| 8362 | };
|
| 8363 |
|
| 8364 |
|
| 8365 |
|
| 8366 | // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
|
| 8367 | function checkPinAfterLogin(loginStatus, data) {
|
| 8368 | if (loginStatus.status == "loggedIn") {
|
| 8369 | var currentState = data.modem_main_state; // cov_2
|
| 8370 | if (currentState == "modem_waitpin") {
|
| 8371 | return pageState.WAIT_PIN;
|
| 8372 | } else if ((currentState == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {
|
| 8373 | return pageState.WAIT_PUK;
|
| 8374 | } else if ((data.puknumber == 0 || currentState == "modem_sim_destroy")
|
| 8375 | && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
|
| 8376 | return pageState.PUK_LOCKED;
|
| 8377 | } else {
|
| 8378 | return pageState.LOGGEDIN;
|
| 8379 | }
|
| 8380 | } else {
|
| 8381 | var currentState = data.modem_main_state;
|
| 8382 | if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
|
| 8383 | return pageState.LOADING;
|
| 8384 | } else {
|
| 8385 | return pageState.LOGIN;
|
| 8386 | }
|
| 8387 | }
|
| 8388 | }
|
| 8389 |
|
| 8390 | // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
|
| 8391 | function computePageState(loginStatus, data) {
|
| 8392 | //PX-880 �ȵ�¼�ٽ���PIN��֤������router����Ô�ò£¬µï¿½Â¼ï¿½ï¿½ï¿½ï¿½PIN��֤���ڵ�¼ҳ�����У������ݿ�����֤����һ�¡�
|
| 8393 | if (config.LOGIN_THEN_CHECK_PIN) {
|
| 8394 | return checkPinAfterLogin(loginStatus, data);
|
| 8395 | } else {
|
| 8396 | return loginAfterCheckPin(loginStatus, data);
|
| 8397 | }
|
| 8398 | }
|
| 8399 |
|
| 8400 | // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
|
| 8401 | function loginAfterCheckPin(loginStatus, data) {
|
| 8402 | if (loginStatus.status == "loggedIn") {
|
| 8403 | return pageState.LOGGEDIN;
|
| 8404 | } else {
|
| 8405 | var currentState = data.modem_main_state;
|
| 8406 | if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
|
| 8407 | return pageState.LOADING;
|
| 8408 | } else if (currentState == "modem_waitpin") {
|
| 8409 | return pageState.WAIT_PIN;
|
| 8410 | } else if ((currentState == "modem_waitpuk" || parseInt(data.pinnumber) === 0) && (parseInt(data.puknumber) != 0)) {
|
| 8411 | return pageState.WAIT_PUK;
|
| 8412 | } else if ((parseInt(data.puknumber) === 0 || currentState == "modem_sim_destroy") && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
|
| 8413 | return pageState.PUK_LOCKED;
|
| 8414 | } else {
|
| 8415 | return pageState.LOGIN;
|
| 8416 | }
|
| 8417 | }
|
| 8418 | }
|
| 8419 | }
|
| 8420 |
|
| 8421 |
|
| 8422 | // ���鵱ǰwindow.location.hash���쳣����ת��index.html
|
| 8423 | function gotoLogin() {
|
| 8424 | if (window.location.hash != config.defaultRoute && _.indexOf(config.GUEST_HASH, window.location.hash) == -1) {
|
| 8425 | if (!manualLogout && lastLoginStatus == "1") {
|
| 8426 | manualLogout = false;
|
| 8427 | lastLoginStatus = 'UNREAL';
|
| 8428 | showAlert('need_login_again', function () {
|
| 8429 | window.location = "index.html";
|
| 8430 | });
|
| 8431 | } else if (lastLoginStatus == 'UNREAL') {
|
| 8432 | //do nothing, only popup need_login_again alert one time
|
| 8433 | return;
|
| 8434 | } else {
|
| 8435 | window.location = "index.html";
|
| 8436 | }
|
| 8437 | }
|
| 8438 | }
|
| 8439 |
|
| 8440 | // ��ʱ������¼״̬
|
| 8441 | function loginStatusCheckingTimer() {
|
| 8442 | return setInterval(function () {
|
| 8443 | var info = service.getStatusInfo();
|
| 8444 | if (!info.isLoggedIn) {
|
| 8445 | gotoLogin();
|
| 8446 | return;
|
| 8447 | }
|
| 8448 | lastLoginStatus = service.getStatusInfo().isLoggedIn ? "1" : "0";
|
| 8449 | }, 1000);
|
| 8450 | }
|
| 8451 |
|
| 8452 | function init() {
|
| 8453 | var info = service.getStatusInfo();
|
| 8454 | if (info.isLoggedIn) {
|
| 8455 | window.location.hash = '#main';
|
| 8456 | return;
|
| 8457 | }
|
| 8458 |
|
| 8459 | var container = $('#container')[0];
|
| 8460 | ko.cleanNode(container);
|
| 8461 | var fwVm = new loginViewModel();
|
| 8462 | ko.applyBindings(fwVm, container);
|
| 8463 |
|
| 8464 | $('#frmLogin').validate({
|
| 8465 | submitHandler:function () {
|
| 8466 | fwVm.login();
|
| 8467 | },
|
| 8468 | rules: {
|
| 8469 | txtAdmin: 'login_password_length_check'
|
| 8470 | }
|
| 8471 | });
|
| 8472 | $('#frmPIN').validate({
|
| 8473 | submitHandler:function () {
|
| 8474 | fwVm.enterPIN();
|
| 8475 | },
|
| 8476 | rules:{
|
| 8477 | txtPIN:"pin_check"
|
| 8478 | }
|
| 8479 | });
|
| 8480 | $('#frmPUK').validate({
|
| 8481 | submitHandler:function () {
|
| 8482 | fwVm.enterPUK();
|
| 8483 | },
|
| 8484 | rules:{
|
| 8485 | txtNewPIN:"pin_check",
|
| 8486 | txtConfirmPIN:{equalToPin:"#txtNewPIN"},
|
| 8487 | txtPUK:"puk_check"
|
| 8488 | }
|
| 8489 | });
|
| 8490 | }
|
| 8491 |
|
| 8492 |
|
| 8493 | return {
|
| 8494 | init:init,
|
| 8495 | gotoLogin:gotoLogin
|
| 8496 | };
|
| 8497 | });
|
| 8498 |
|
| 8499 |
|
| 8500 | // Logout �
|
| 8501 | define("logout","set service knockout underscore jquery".split(" "),
|
| 8502 | function (config, service, ko, _, $) {
|
| 8503 |
|
| 8504 | function logoutViewModel() {
|
| 8505 | var target = this;
|
| 8506 | // ��ȡ�Ƿ���¼
|
| 8507 | var loginFlag = function () {
|
| 8508 | var loginInfo = service.getLoginStatus();
|
| 8509 | return (loginInfo.status == "loggedIn");
|
| 8510 | }
|
| 8511 | ();
|
| 8512 | target.loggedIn = ko.observable(loginFlag);
|
| 8513 |
|
| 8514 | // �˳�ϵͳ
|
| 8515 | target.logout = function () {
|
| 8516 | showConfirm("confirm_logout", function () {
|
| 8517 | manualLogout = true;
|
| 8518 | service.logout({}, setLocation());
|
| 8519 | });
|
| 8520 | };
|
| 8521 |
|
| 8522 | // �Ƿ���ʾ�˳���ť
|
| 8523 | target.showLogout = function () {
|
| 8524 | if (config.HAS_LOGIN) {
|
| 8525 | return target.loggedIn();
|
| 8526 | } else {
|
| 8527 | return false;
|
| 8528 | }
|
| 8529 | };
|
| 8530 | }
|
| 8531 | function setLocation() {
|
| 8532 | window.location = 'index.html';
|
| 8533 | }
|
| 8534 | function initialize() {
|
| 8535 | var fwVm = new logoutViewModel();
|
| 8536 | bindContainer(fwVm);
|
| 8537 | }
|
| 8538 | function bindContainer(fwVm) {
|
| 8539 | var con = $('#logout')[0];
|
| 8540 | ko.cleanNode(con);
|
| 8541 | ko.applyBindings(fwVm, con);
|
| 8542 | }
|
| 8543 | return {
|
| 8544 | init: initialize
|
| 8545 | };
|
| 8546 | });
|
| 8547 |
|
| 8548 | // operation mode �
|
| 8549 | define("opmode","knockout service jquery set underscore".split(" "),
|
| 8550 |
|
| 8551 | function (ko, service, $, config, _) {
|
| 8552 |
|
| 8553 | function currentOperationModeViewMode(){
|
| 8554 | var target = this;
|
| 8555 | target.isLoggedIn = ko.observable(false);
|
| 8556 | target.enableFlag = ko.observable(false);
|
| 8557 |
|
| 8558 | target.showOpModeWindow = function () {
|
| 8559 | showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {
|
| 8560 | });
|
| 8561 | };
|
| 8562 | target.currentOpMode = ko.observable("0");
|
| 8563 |
|
| 8564 | service.getOpMode({}, function(info){
|
| 8565 | target.isLoggedIn(info.loginfo == "ok");
|
| 8566 | if (info.opms_wan_mode != "PPP" && info.rj45_state != "idle" && info.rj45_state != "dead") {
|
| 8567 | target.enableFlag(false);
|
| 8568 | } else if (info.opms_wan_mode == "PPP" && info.ppp_status != "ppp_disconnected") {
|
| 8569 | target.enableFlag(false);
|
| 8570 | } else if(info.opms_wan_mode == "DHCP"){
|
| 8571 | target.enableFlag(true);
|
| 8572 | } else {
|
| 8573 | target.enableFlag(true);
|
| 8574 | }
|
| 8575 |
|
| 8576 | var opmsWanMode = (info.opms_wan_mode == "DHCP" || info.opms_wan_mode == "STATIC") ? "PPPOE" : info.opms_wan_mode;
|
| 8577 |
|
| 8578 | var currentOperationMode = "";
|
| 8579 | switch(opmsWanMode){
|
| 8580 | case "BRIDGE":
|
| 8581 | currentOperationMode = "opmode_bridge";
|
| 8582 | break;
|
| 8583 | case "PPP":
|
| 8584 | currentOperationMode = "opmode_gateway";
|
| 8585 | break;
|
| 8586 | case "PPPOE":
|
| 8587 | currentOperationMode = "opmode_cable";
|
| 8588 | break;
|
| 8589 | default:
|
| 8590 | break;
|
| 8591 | }
|
| 8592 | $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
|
| 8593 | });
|
| 8594 | // ��ʱ��ѯ����ģʽ����״̬�����ý���״̬
|
| 8595 | setInterval(function(){
|
| 8596 | var object = service.getConnectionInfo();
|
| 8597 | if(object.opms_wan_mode == "DHCP") {
|
| 8598 | target.enableFlag(true);
|
| 8599 | } else if((object.opms_wan_mode == "PPP" && object.ppp_status != "ppp_disconnected") || (object.opms_wan_mode != "PPP" && object.rj45_state != "idle" && object.rj45_state != "dead")) {
|
| 8600 | target.enableFlag(false);
|
| 8601 | } else {
|
| 8602 | target.enableFlag(true);
|
| 8603 | }
|
| 8604 | }, 1000);
|
| 8605 | }
|
| 8606 |
|
| 8607 | function init() {
|
| 8608 | var container = $('#currentOpMode')[0];
|
| 8609 | ko.cleanNode(container);
|
| 8610 | var fwVm = new currentOperationModeViewMode();
|
| 8611 | ko.applyBindings(fwVm, container);
|
| 8612 | }
|
| 8613 |
|
| 8614 | return {
|
| 8615 | init:init
|
| 8616 | };
|
| 8617 | });
|
| 8618 |
|
| 8619 | // operation mode popup�
|
| 8620 |
|
| 8621 | define("opmode_popup","knockout service jquery set underscore".split(" "),
|
| 8622 |
|
| 8623 | function (ko, service, $, config, _) {
|
| 8624 |
|
| 8625 | function operationModeViewMode() {
|
| 8626 | var target = this;
|
| 8627 | var currentSelectedOperationMode = "";
|
| 8628 | target.selectedMode = ko.observable("0");
|
| 8629 |
|
| 8630 | // ��ʼ������ģʽ��ʾ
|
| 8631 | service.getOpMode({}, function(info){
|
| 8632 | if(info.blc_wan_mode == "AUTO_PPP"){
|
| 8633 | currentSelectedOperationMode = "AUTO";
|
| 8634 | }else if(info.blc_wan_mode == "AUTO_PPPOE"){
|
| 8635 | currentSelectedOperationMode = "AUTO";
|
| 8636 | }else if(info.blc_wan_mode == "PPPOE"){
|
| 8637 | currentSelectedOperationMode = "PPPOE";
|
| 8638 | }else{
|
| 8639 | currentSelectedOperationMode = info.blc_wan_mode;
|
| 8640 | }
|
| 8641 | target.selectedMode(currentSelectedOperationMode);
|
| 8642 | });
|
| 8643 |
|
| 8644 | // ģʽ����/�л�
|
| 8645 | target.changeOpMode = function(){
|
| 8646 | var userSelectedOperationMode = $('input:radio[name="opMode"]:checked').val();
|
| 8647 | var messageText = "";
|
| 8648 | if(userSelectedOperationMode == currentSelectedOperationMode) {
|
| 8649 | hidePopupSettingWindow();
|
| 8650 | return;
|
| 8651 | }
|
| 8652 | if(userSelectedOperationMode == "LTE_BRIDGE"){
|
| 8653 | messageText = "opmode_msg3";
|
| 8654 | }else{
|
| 8655 | messageText = "opmode_msg2";
|
| 8656 | }
|
| 8657 | showConfirm(messageText, function(){
|
| 8658 | showLoading();
|
| 8659 | service.SetOperationMode({
|
| 8660 | opMode: userSelectedOperationMode
|
| 8661 | },function(info){
|
| 8662 | if (info && info.result == "success") {
|
| 8663 | var currentOperationMode = "";
|
| 8664 | switch(userSelectedOperationMode){
|
| 8665 | case "AUTO":
|
| 8666 | currentOperationMode = "opmode_auto"
|
| 8667 | break;
|
| 8668 | case "PPP":
|
| 8669 | currentOperationMode = "opmode_gateway";
|
| 8670 | break;
|
| 8671 | case "PPPOE":
|
| 8672 | currentOperationMode = "opmode_cable";
|
| 8673 | break;
|
| 8674 | default:
|
| 8675 | break;
|
| 8676 | }
|
| 8677 | $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
|
| 8678 | successOverlay();
|
| 8679 | } else {
|
| 8680 | errorOverlay();
|
| 8681 | }
|
| 8682 | });
|
| 8683 | });
|
| 8684 |
|
| 8685 | }
|
| 8686 |
|
| 8687 | }
|
| 8688 |
|
| 8689 | function init() {
|
| 8690 | var fwVm = new operationModeViewMode();
|
| 8691 | ko.applyBindings(fwVm, $('#popupSettingWindow')[0]);
|
| 8692 |
|
| 8693 | $("#opmode_form").validate({
|
| 8694 | submitHandler: function(){
|
| 8695 | fwVm.changeOpMode();
|
| 8696 | }
|
| 8697 | });
|
| 8698 | }
|
| 8699 |
|
| 8700 | return {
|
| 8701 | init:init
|
| 8702 | };
|
| 8703 | });
|
| 8704 |
|
| 8705 | define("router","underscore jquery menu set service".split(" "),
|
| 8706 | function (_, $, menu, config, service) {
|
| 8707 | var currentHash = '';
|
| 8708 | var container = $('#container');
|
| 8709 |
|
| 8710 | //�뿪����ʱ�����Ƿ��������޸ģ�����������ʾ
|
| 8711 | checkFormContentModify = function (href) {
|
| 8712 | if (config.CONTENT_MODIFIED.modified && window.location.hash != href) {
|
| 8713 | if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {
|
| 8714 | config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
|
| 8715 | config.resetContentModifyValue();
|
| 8716 | window.location.hash = href;
|
| 8717 | } else {
|
| 8718 | showConfirm(config.CONTENT_MODIFIED.message, {
|
| 8719 | ok: function () {
|
| 8720 | config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
|
| 8721 | config.resetContentModifyValue();
|
| 8722 | window.location.hash = href;
|
| 8723 | },
|
| 8724 | no: function () {
|
| 8725 | var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);
|
| 8726 | if (!result) {
|
| 8727 | window.location.hash = href;
|
| 8728 | config.resetContentModifyValue();
|
| 8729 | }
|
| 8730 | }
|
| 8731 | });
|
| 8732 | }
|
| 8733 | return false;
|
| 8734 | } else {
|
| 8735 | return true;
|
| 8736 | }
|
| 8737 | };
|
| 8738 |
|
| 8739 | //��ʱ�鿴SIM����״̬������ǰSIM��״̬��Ϊ����״̬��δ��ʾnosimcardҳ�棬����ʾnosimcardҳ��,�Ա��ⲻ�ر�webui�����²����豸�󣬲����ж�SIM��״̬������
|
| 8740 | function checkSimCardStatus() {
|
| 8741 | setInterval(function () {
|
| 8742 | var data = service.getStatusInfo();
|
| 8743 | var match = menu.findMenu();
|
| 8744 | if (match.length == 0) {
|
| 8745 | return false;
|
| 8746 | }
|
| 8747 | var requirePinHash = ["phonebook", "sms_list"];
|
| 8748 | var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
|
| 8749 | if (match[0].checkSIMStatus === true) {
|
| 8750 | var simstatus = data.simStatus == "modem_sim_undetected"
|
| 8751 | || data.simStatus == "modem_sim_destroy" || data.simStatus == "modem_waitpin"
|
| 8752 | || data.simStatus == "modem_waitpuk";
|
| 8753 | var netlockstatus = data.simStatus == "modem_imsi_waitnck";
|
| 8754 | if (data.isLoggedIn && (
|
| 8755 | ($('#div-nosimcard')[0] == undefined && simstatus)
|
| 8756 | || ($('#div-network-lock')[0] == undefined && netlockstatus)
|
| 8757 | || (($('#div-nosimcard')[0] != undefined || $('#div-network-lock')[0] != undefined) && data.simStatus == "modem_init_complete"))) {
|
| 8758 | fixedLoadResources(match[0], data.simStatus, isRequirePin);
|
| 8759 | }
|
| 8760 | }
|
| 8761 | }, 1000);
|
| 8762 | }
|
| 8763 |
|
| 8764 | //������¼ҳ�汳��
|
| 8765 | function checkLoginPageBg() {
|
| 8766 | var h = window.location.hash;
|
| 8767 | if (h == '#entry' || _.indexOf(config.GUEST_HASH, h) != -1) {
|
| 8768 | $("#manageContainer").attr("style", "margin-top:-36px;");
|
| 8769 | } else {
|
| 8770 | $("#manageContainer").attr("style", "margin-top:0px;");
|
| 8771 | }
|
| 8772 |
|
| 8773 | if (window.location.hash == '#entry') {
|
| 8774 | $("#mainContainer").addClass('loginBackgroundBlue');
|
| 8775 | } else {
|
| 8776 | var mainContainer = $("#mainContainer");
|
| 8777 | if (mainContainer.hasClass('loginBackgroundBlue')) {
|
| 8778 | $("#container").css({
|
| 8779 | margin: 0
|
| 8780 | });
|
| 8781 | mainContainer.removeClass('loginBackgroundBlue').height('auto');
|
| 8782 | }
|
| 8783 | }
|
| 8784 | }
|
| 8785 |
|
| 8786 | function fixedLoadResources(menuItem, simStatus, isRequirePin) {
|
| 8787 | var item = {};
|
| 8788 | $.extend(item, menuItem);
|
| 8789 | //û��SIM��ʱ������homeҳ�治��������
|
| 8790 | //���类��ʱ��homeҳ����ʾ����ҳ��
|
| 8791 | if (simStatus == "modem_sim_undetected" || simStatus == "modem_sim_destroy") {
|
| 8792 | if (!isRequirePin) {
|
| 8793 | item.path = "sim_abnormal";
|
| 8794 | }
|
| 8795 | } else if (simStatus == "modem_waitpin" || simStatus == "modem_waitpuk") {
|
| 8796 | item.path = "sim_abnormal";
|
| 8797 | } else if (simStatus == "modem_imsi_waitnck") {
|
| 8798 | item.path = "locknet";
|
| 8799 | }
|
| 8800 | //load tmpl and controller js
|
| 8801 | loadResources(item);
|
| 8802 | }
|
| 8803 |
|
| 8804 | //���ݲ˵�����item���ض�Ӧ����Դ
|
| 8805 | function loadResources(item) {
|
| 8806 | var pId = item.path.replace(/\//g, '_');
|
| 8807 | var $body = $('body').removeClass();
|
| 8808 | if (pId != 'entry' && pId != 'main') {
|
| 8809 | $body.addClass('beautiful_bg page_' + pId);
|
| 8810 | } else {
|
| 8811 | $body.addClass('page_' + pId);
|
| 8812 | }
|
| 8813 | clearTimer();
|
| 8814 | hideLoading();
|
| 8815 | var tmplPath = 'text!tmpl/' + item.path + '.html';
|
| 8816 | //TODO: prevent first menu click cover the second menu content, need test with device
|
| 8817 | require([tmplPath, item.path], function (tmpl, viewModel) {
|
| 8818 | container.stop(true, true);
|
| 8819 | container.hide();
|
| 8820 | container.html(tmpl);
|
| 8821 | viewModel.init();
|
| 8822 | //support backward/forward
|
| 8823 | menu.refreshMenu();
|
| 8824 | $('#container').translate();
|
| 8825 | menu.activeSubMenu();
|
| 8826 |
|
| 8827 | $("form").attr("autocomplete", "off");
|
| 8828 | container.fadeIn();
|
| 8829 | });
|
| 8830 | }
|
| 8831 | //�ȶ�hash״̬, �����仯�������µ�hashƥ���˵�����,ƥ�䲻��ʱ��ת��homeҳ��, ƥ����ʱ��¼hashֵ����̬���ض�Ӧ����Դ�ļ�
|
| 8832 | function hashCheck() {
|
| 8833 | if (window.location.hash != currentHash) {
|
| 8834 | //������½����������, ��½�û����ʷǵ�¼�û�ʱҳ�治��ת
|
| 8835 | var info = service.getStatusInfo();
|
| 8836 | if (window.location.hash == config.defaultRoute || _.indexOf(config.GUEST_HASH, window.location.hash) != -1) {
|
| 8837 | if (info.isLoggedIn) {
|
| 8838 | window.location.hash = currentHash == "" ? "#main" : currentHash;
|
| 8839 | return;
|
| 8840 | }
|
| 8841 | }
|
| 8842 |
|
| 8843 | var match = menu.findMenu();
|
| 8844 |
|
| 8845 | if (match.length == 0) {
|
| 8846 | window.location.hash = config.defaultRoute;
|
| 8847 | } else {
|
| 8848 | //��¼ʱ���鹤��ģʽ������ģʽ������������Ҫ����SIM��״̬�����¼���,����ģʽ�������治��Ҫ����SIM��״̬�����¼���
|
| 8849 | if (config.RJ45_SUPPORT && window.location.hash == "#main") {
|
| 8850 | if ((match[0].checkSIMStatus && checkCableMode(info.blc_wan_mode)) || (!match[0].checkSIMStatus && !checkCableMode(info.blc_wan_mode))) {
|
| 8851 | window.location.reload();
|
| 8852 | return;
|
| 8853 | }
|
| 8854 | }
|
| 8855 | //TODO: �����˵�����Ӧ�����˵���һ����л�ʱ�����¼�������, ��TODO: click the same menu ʵ�ַ�ʽ����
|
| 8856 | var oldMenu = menu.findMenu(currentHash);
|
| 8857 | currentHash = match[0].hash;
|
| 8858 | if (currentHash == "#entry") {
|
| 8859 | $('#indexContainer').addClass('login-page-bg');
|
| 8860 | menu.rebuild();
|
| 8861 | } else {
|
| 8862 | $('#indexContainer').removeClass('login-page-bg');
|
| 8863 | }
|
| 8864 |
|
| 8865 | if (oldMenu.length != 0 && match[0].path == oldMenu[0].path && match[0].level != oldMenu[0].level && match[0].level != '1' && oldMenu[0].level != '1') {
|
| 8866 | return;
|
| 8867 | }
|
| 8868 |
|
| 8869 | checkLoginPageBg();
|
| 8870 | var requirePinHash = ["phonebook", "sms_list"];
|
| 8871 | var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
|
| 8872 | if (match[0].checkSIMStatus === true || isRequirePin) {
|
| 8873 | //simStatus is undefined when refreshing page
|
| 8874 | if (info.simStatus == undefined) {
|
| 8875 | showLoading('waiting');
|
| 8876 | function checkSIM() {
|
| 8877 | var data = service.getStatusInfo();
|
| 8878 | if (data.simStatus == undefined || $.inArray(data.simStatus, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
|
| 8879 | addTimeout(checkSIM, 500);
|
| 8880 | } else {
|
| 8881 | fixedLoadResources(match[0], data.simStatus, isRequirePin);
|
| 8882 | hideLoading();
|
| 8883 | }
|
| 8884 | }
|
| 8885 | checkSIM();
|
| 8886 | } else {
|
| 8887 | fixedLoadResources(match[0], info.simStatus, isRequirePin);
|
| 8888 | }
|
| 8889 | } else {
|
| 8890 | loadResources(match[0]);
|
| 8891 | }
|
| 8892 | }
|
| 8893 | }
|
| 8894 | }
|
| 8895 |
|
| 8896 | //Ĭ������ҳ��Ϊ#main, ��ʱ����hash״̬
|
| 8897 | function init() {
|
| 8898 | checkSimCardStatus();
|
| 8899 | window.location.hash = window.location.hash || "#main";
|
| 8900 | //if support onhashchange then use. If ie8 in ie7 mode, it doesn't trigger onhashchange.
|
| 8901 | if (('onhashchange' in window) && ((typeof document.documentMode === 'undefined') || document.documentMode == 8)) {
|
| 8902 | window.onhashchange = hashCheck;
|
| 8903 | hashCheck();
|
| 8904 | } else {
|
| 8905 | setInterval(hashCheck, 200);
|
| 8906 | }
|
| 8907 |
|
| 8908 | //�����޸���ҳ������, �뿪ʱ������ʾ
|
| 8909 | $("a[href^='#']").die('click').live('click', function () {
|
| 8910 | var $this = $(this);
|
| 8911 | config.CONTENT_MODIFIED.checkChangMethod();
|
| 8912 | return checkFormContentModify($this.attr('href'));
|
| 8913 | });
|
| 8914 | }
|
| 8915 |
|
| 8916 | return {
|
| 8917 | init: init
|
| 8918 | };
|
| 8919 | });
|
| 8920 |
|
| 8921 | // statusBar �
|
| 8922 |
|
| 8923 | define("statusBar", "knockout jquery underscore service set menu tooltip".split(" "),
|
| 8924 |
|
| 8925 | function (ko, $, _, service, config, menu, tooltip) {
|
| 8926 |
|
| 8927 | var sv__hasCheckedSMSCapacity = false;
|
| 8928 | var sv__initSMSCompleted = false;
|
| 8929 | var sv_newSMSMessageInDealing = false;
|
| 8930 | var sv_fotaUpdateCancel = null;
|
| 8931 | var sv_batteryCheckTimer = 0;
|
| 8932 | var sv_dbMessageIds = [];
|
| 8933 | var sv_fotaResultAlertPopuped = false;
|
| 8934 | var sv_isFirstLoadNewMessage = true;
|
| 8935 | var isLoggedIn = true;
|
| 8936 | var sv_messagePopStack = {};
|
| 8937 | var sv_newMessagePopTemplate = null;
|
| 8938 | var sv_resetTrafficAlertPopuped = false;
|
| 8939 | var sv_simMessageListTemplate = null;
|
| 8940 | var sv_smsListTemplate = null;
|
| 8941 | var sv_trafficAlertPopuped_100 = false;
|
| 8942 | var sv_trafficAlertPopuped = false;
|
| 8943 | var sv_timer = 0;
|
| 8944 |
|
| 8945 | // ��ȡ״̬��Ϣ�������硢SIM��WIFI��
|
| 8946 | var getCurrentStatusInfo = function () {
|
| 8947 | return service.getStatusInfo();
|
| 8948 | };
|
| 8949 |
|
| 8950 | function statusViewModel() {
|
| 8951 | var target = this;
|
| 8952 | var info = getCurrentStatusInfo();
|
| 8953 | var roamStatus = info.roamingStatus ? true : false;
|
| 8954 | var $langLogoBar = $("#langLogoBar");
|
| 8955 |
|
| 8956 |
|
| 8957 | // �������������¼�����
|
| 8958 | function sf_connect() {
|
| 8959 | showLoading("connecting");
|
| 8960 | service.connect({}, function (data) {
|
| 8961 | if (data.result) {
|
| 8962 | refreshWifiConnectStatus(target, data.status);
|
| 8963 | }
|
| 8964 | successOverlay();
|
| 8965 | }, function (data) {
|
| 8966 | errorOverlay();
|
| 8967 | });
|
| 8968 | }
|
| 8969 | // �Ͽ������¼�����
|
| 8970 | function sf_disconnect() {
|
| 8971 | showLoading("disconnecting");
|
| 8972 | service.disconnect({}, function (data) {
|
| 8973 | if (data.result) {
|
| 8974 | refreshWifiConnectStatus(target, data.status);
|
| 8975 | }
|
| 8976 | successOverlay();
|
| 8977 | }, function (data) {
|
| 8978 | errorOverlay();
|
| 8979 | });
|
| 8980 | }
|
| 8981 |
|
| 8982 | if(info.isLoggedIn){
|
| 8983 | if(!$langLogoBar.hasClass("langborderBg")){
|
| 8984 | $langLogoBar.addClass("langborderBg");
|
| 8985 | }
|
| 8986 | $("#statusBar:hidden").show();
|
| 8987 | } else {
|
| 8988 | if($langLogoBar.hasClass("langborderBg")){
|
| 8989 | $langLogoBar.removeClass("langborderBg");
|
| 8990 | }
|
| 8991 | $("#statusBar:visible").hide();
|
| 8992 | }
|
| 8993 |
|
| 8994 |
|
| 8995 | //target.attachedDevices = ko.observable(info.attachedDevices);
|
| 8996 | target.batteryLevel = ko.observable(info.batteryLevel + '%');
|
| 8997 | target.batteryPers = ko.observable(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
|
| 8998 | target.batteryStatus = ko.observable(info.batteryStatus);
|
| 8999 | target.connectionCssClass = ko.observable("");
|
| 9000 | target.connectStatus = ko.observable(info.connectStatus);
|
| 9001 | target.connectStatusText = ko.observable();
|
| 9002 | target.connectStatusTrans = ko.observable();
|
| 9003 | target.hasWifi = ko.observable(config.HAS_WIFI);
|
| 9004 | target.hasBattery = ko.observable(config.HAS_BATTERY);
|
| 9005 | target.isLoggedIn = ko.observable(info.isLoggedIn);
|
| 9006 | target.isShowConnectionIcon = ko.observable(false);
|
| 9007 | target.isShowFotaNewversionIcon = ko.observable(info.new_version_state && info.fota_package_already_download != "yes" && !config.isShowFotaIcon);
|
| 9008 | target.isShowRj45ConnectionIcon = ko.observable(false);
|
| 9009 | target.networkOperator = ko.observable(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,roamStatus));
|
| 9010 | target.networkType = ko.observable(getNetworkType(info.networkType));
|
| 9011 | target.pinStatus = ko.observable(info.pinStatus);
|
| 9012 | target.pinStatusText = ko.observable();
|
| 9013 | target.rj45ConnectionCssClass = ko.observable("");
|
| 9014 | target.roamingStatus = ko.observable(info.roamingStatus ? "R" : "");
|
| 9015 | target.showAttachedDevices = ko.observable(info.wifiStatus);
|
| 9016 | target.showSmsDeleteConfirm = ko.observable(false);
|
| 9017 | target.smsUnreadCount = ko.observable(0);
|
| 9018 | target.simStatus = ko.observable(sf_convertSimStatusToImage(info.simStatus));
|
| 9019 | target.signalCssClass = ko.observable(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
|
| 9020 | target.updateType = ko.observable(service.getUpdateType().update_type);
|
| 9021 | target.wifiStatusCssClass = ko.observable(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
|
| 9022 | target.wifiStatusImg = ko.observable(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
|
| 9023 |
|
| 9024 | sf_getConnectionCssClass(target, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
|
| 9025 |
|
| 9026 | target.connect = sf_connect;
|
| 9027 | target.disconnect = sf_disconnect;
|
| 9028 | }
|
| 9029 |
|
| 9030 | function sf_gotoSmsList(){
|
| 9031 | var s_href = '#msg_main';
|
| 9032 | if(window.location.hash == '#msg_main'){
|
| 9033 | s_href = '#msg_list';
|
| 9034 | }
|
| 9035 | config.CONTENT_MODIFIED.checkChangMethod();
|
| 9036 | if(checkFormContentModify(s_href)){
|
| 9037 | window.location.hash = s_href;
|
| 9038 | }
|
| 9039 | }
|
| 9040 |
|
| 9041 | gotoSmsList = sf_gotoSmsList;
|
| 9042 |
|
| 9043 | function sf_getNetWorkProvider(i_spnB1Flag, i_spnNameData, i_spnB2Flag, i_networkProvider, i_roamStatus) {
|
| 9044 | if (i_spnNameData == "") {
|
| 9045 | return i_networkProvider;
|
| 9046 | } else {
|
| 9047 | i_spnNameData = decodeMessage(i_spnNameData);
|
| 9048 | if (i_spnB1Flag == "0" && i_spnB2Flag == "0") {
|
| 9049 | if (i_roamStatus) {//����
|
| 9050 | return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
|
| 9051 | } else {//������
|
| 9052 | return i_spnNameData;
|
| 9053 | }
|
| 9054 | }else if (i_spnB1Flag == "1" && i_spnB2Flag == "1") {
|
| 9055 | if (i_roamStatus) {//����
|
| 9056 | return i_networkProvider;
|
| 9057 | } else {//������
|
| 9058 | return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
|
| 9059 | }
|
| 9060 | } else if (i_spnB1Flag == "1") {
|
| 9061 | return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
|
| 9062 | } else if (i_spnB2Flag == "1") {
|
| 9063 | if (i_roamStatus) {//����
|
| 9064 | return i_networkProvider;
|
| 9065 | } else {//������
|
| 9066 | return i_spnNameData;
|
| 9067 | }
|
| 9068 | }
|
| 9069 | return "";
|
| 9070 | }
|
| 9071 | }
|
| 9072 |
|
| 9073 | // �����¶���Ϣ��ʾ����������������
|
| 9074 | function sf_addNewMessage(i_message, i_isUpdate, i_type){
|
| 9075 | config.smsMaxId = i_message.id;
|
| 9076 | var now = $.now();
|
| 9077 | sv_messagePopStack["m" + now] = now;
|
| 9078 | var name = i_message.number;
|
| 9079 | if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
|
| 9080 | sv_isFirstLoadNewMessage = false;
|
| 9081 | if(config.HAS_PHONEBOOK){
|
| 9082 | sf_getPhoneBooks();
|
| 9083 | }else{
|
| 9084 | config.phonebook = [];
|
| 9085 | }
|
| 9086 | }
|
| 9087 | for(i in config.phonebook){
|
| 9088 | if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
|
| 9089 | name = config.phonebook[i].pbm_name;
|
| 9090 | break;
|
| 9091 | }
|
| 9092 | }
|
| 9093 | var s_newMsg = {
|
| 9094 | mark : "m" + now,
|
| 9095 | name: name,
|
| 9096 | title: $.i18n.prop("sms"),
|
| 9097 | titleTrans: "sms",
|
| 9098 | tag: i_message.tag,
|
| 9099 | content : i_message.content,
|
| 9100 | datetime : i_message.time
|
| 9101 | };
|
| 9102 | if(sv_newMessagePopTemplate == null){
|
| 9103 | sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
|
| 9104 | }
|
| 9105 | $(".bubbleItem:not(.report)", "#buttom-bubble").remove();
|
| 9106 | $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
|
| 9107 | if((window.location.hash == "#msg_main" || window.location.hash == "#msg_list") && i_type == "1"){
|
| 9108 | //sf_dealChosenNumber(s_newMsg.name, i_message.number);
|
| 9109 | var s_inChating = config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
|
| 9110 | var s_itemId = getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
|
| 9111 | var item = $("#smslist-item-" + s_itemId);
|
| 9112 | if(item && item.length > 0){
|
| 9113 | // �Ѵ������ݣ��������ݵ���˳��
|
| 9114 | for(var i = 0; config.listMsgs && i < config.listMsgs.length; i++){
|
| 9115 | if(getLastNumber(config.listMsgs[i].number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
|
| 9116 | config.listMsgs[i].id = i_message.id;
|
| 9117 | config.listMsgs[i].latestId = i_message.id;
|
| 9118 | config.listMsgs[i].latestSms = i_message.content;
|
| 9119 | config.listMsgs[i].latestTime = i_message.time;
|
| 9120 | if(!i_isUpdate){
|
| 9121 | config.listMsgs[i].newCount++;
|
| 9122 | config.listMsgs[i].totalCount++;
|
| 9123 | }
|
| 9124 | break;
|
| 9125 | }
|
| 9126 | }
|
| 9127 | item.find(".smslist-item-checkbox p.checkbox").attr("id", i_message.id);
|
| 9128 | item.find(".smslist-item-checkbox input:checkbox").val(i_message.id).attr("id", "checkbox" + i_message.id);
|
| 9129 | if(!i_isUpdate){
|
| 9130 | var s_itemCount = item.find(".smslist-item-total-count").text();
|
| 9131 | s_itemCount = Number(s_itemCount.substring(1, s_itemCount.length - 1));
|
| 9132 | item.find(".smslist-item-total-count").text("(" + (s_itemCount + 1) + ")");
|
| 9133 | if(!config.currentChatObject || config.currentChatObject != getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
|
| 9134 | var s_newNum = item.find(".smslist-item-new-count").removeClass("hide");
|
| 9135 | if(s_newNum && s_newNum.text().length > 0){
|
| 9136 | s_newNum.text(Number(s_newNum.text()) + 1);
|
| 9137 | }else{
|
| 9138 | s_newNum.text(1);
|
| 9139 | }
|
| 9140 | }
|
| 9141 | }
|
| 9142 | if(item.find(".smslist-item-draft-flag").length > 0){
|
| 9143 | if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
|
| 9144 | item.find(" td:nth-child(2)").removeClass("font-weight-bold");
|
| 9145 | } else {
|
| 9146 | item.find(" td:nth-child(2)").addClass("font-weight-bold");
|
| 9147 | }
|
| 9148 | }else{
|
| 9149 | var msgContent = item.find(".smslist-item-msg").text(i_message.content);
|
| 9150 | msgContent.closest('td').prop('title', i_message.content);
|
| 9151 | item.find("span.clock-time").text(i_message.time);
|
| 9152 | if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
|
| 9153 | msgContent.closest('tr').removeClass("font-weight-bold");
|
| 9154 | } else {
|
| 9155 | msgContent.closest('tr').addClass("font-weight-bold");
|
| 9156 | }
|
| 9157 | }
|
| 9158 | item.find(".smslist-item-repeat span").die().click(function() {
|
| 9159 | forwardClickHandler(i_message.id);
|
| 9160 | });
|
| 9161 |
|
| 9162 | var s_tmpItem = item;
|
| 9163 | item.hide().remove();
|
| 9164 | $("#smslist-table").prepend(s_tmpItem.show());
|
| 9165 | } else {
|
| 9166 | // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
|
| 9167 | var s_theName = "";
|
| 9168 | if(config.phonebook && config.phonebook.length > 0) {
|
| 9169 | for(i in config.phonebook){
|
| 9170 | if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
|
| 9171 | s_theName = config.phonebook[i].pbm_name;
|
| 9172 | break;
|
| 9173 | }
|
| 9174 | }
|
| 9175 | }
|
| 9176 | var s_theNewMessage = {
|
| 9177 | id : i_message.id,
|
| 9178 | name : s_theName,
|
| 9179 | number : i_message.number,
|
| 9180 | latestId :i_message.id,
|
| 9181 | totalCount : 1,
|
| 9182 | newCount : s_inChating ? 0 : 1,
|
| 9183 | latestSms : i_message.content,
|
| 9184 | latestTime : i_message.time,
|
| 9185 | checked : false,
|
| 9186 | hasDraft : false,
|
| 9187 | itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
|
| 9188 | };
|
| 9189 | if(sv_smsListTemplate == null){
|
| 9190 | sv_smsListTemplate = $.template("smsTableTmpl", $("#smsTableTmpl"));
|
| 9191 | }
|
| 9192 | $.tmpl("smsTableTmpl", {data: [s_theNewMessage]}).prependTo("#smslist-table");
|
| 9193 | }
|
| 9194 | if(config.HAS_PHONEBOOK){
|
| 9195 | $(".sms-add-contact-icon").removeClass("hide");
|
| 9196 | }else{
|
| 9197 | $(".sms-add-contact-icon").addClass("hide");
|
| 9198 | }
|
| 9199 | if(s_inChating){
|
| 9200 | var talkItem = $("#talk-item-" + i_message.id, "#chatlist");
|
| 9201 | if (talkItem && talkItem.length > 0) {// ���¼�����������
|
| 9202 | $(".J_content pre", talkItem).html(dealContent(i_message.content));
|
| 9203 | $(".time .smslist-item-time", talkItem).text(i_message.time);
|
| 9204 | $(".smslist-item-repeat", talkItem).die().click(
|
| 9205 | function() {
|
| 9206 | forwardClickHandler(i_message.id);
|
| 9207 | });
|
| 9208 | $(".smslist-item-delete", talkItem).die().click(
|
| 9209 | function() {
|
| 9210 | deleteSingleItemClickHandler(i_message.id);
|
| 9211 | });
|
| 9212 | } else {// �����µĻظ�����
|
| 9213 | $("#smsOtherTmpl").tmpl(i_message).appendTo("#chatlist");
|
| 9214 | $(".clear-container", "#chatpanel").animate({
|
| 9215 | scrollTop : $("#chatlist").height()
|
| 9216 | });
|
| 9217 | }
|
| 9218 | if (!config.SMS_SET_READ_WHEN_COMPLETE) {
|
| 9219 | service.setSmsRead({ids: [i_message.id]}, $.noop);
|
| 9220 | } else if (config.SMS_SET_READ_WHEN_COMPLETE && i_message.receivedAll) {
|
| 9221 | service.setSmsRead({ids: [i_message.id]}, $.noop);
|
| 9222 | }
|
| 9223 | }
|
| 9224 | enableCheckbox($("#smslist-checkAll"));
|
| 9225 | }
|
| 9226 | if(window.location.hash == "#msg_sim" && i_type == "0"){
|
| 9227 | // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
|
| 9228 | var s_theName = "";
|
| 9229 | if(config.phonebook && config.phonebook.length > 0) {
|
| 9230 | for(i in config.phonebook){
|
| 9231 | if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
|
| 9232 | s_theName = config.phonebook[i].pbm_name;
|
| 9233 | break;
|
| 9234 | }
|
| 9235 | }
|
| 9236 | }
|
| 9237 | var s_theNewMessage = {
|
| 9238 | id : i_message.id,
|
| 9239 | name : s_theName,
|
| 9240 | number : i_message.number,
|
| 9241 | content : i_message.content,
|
| 9242 | time : i_message.time,
|
| 9243 | tag: i_message.tag,
|
| 9244 | checked : false,
|
| 9245 | itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
|
| 9246 | };
|
| 9247 | if(i_isUpdate){
|
| 9248 | var s_item = $(".simMsgList-item-class-" + s_theNewMessage.id);
|
| 9249 | s_item.hide().remove();
|
| 9250 | }
|
| 9251 | if(sv_simMessageListTemplate == null){
|
| 9252 | sv_simMessageListTemplate = $.template("ssimMessageListTemplate", $("#simMessageListTemplate"));
|
| 9253 | }
|
| 9254 | $.tmpl("simMessageListTemplate", {data: [s_theNewMessage]}).prependTo("#simMsgList_container");
|
| 9255 | }
|
| 9256 | }
|
| 9257 |
|
| 9258 | function sf_checkBatteryStatusForFota(){
|
| 9259 | var s_state = service.getCurrentUpgradeState();
|
| 9260 | if(s_state.current_upgrade_state == 'low_battery'){
|
| 9261 | showInfo('ota_low_battery');
|
| 9262 | clearInterval(sv_batteryCheckTimer);
|
| 9263 | }
|
| 9264 | }
|
| 9265 |
|
| 9266 | // ��SIM��״̬ת��Ϊ��Ӧ����������
|
| 9267 | function sf_convertSimStatusToImage(i_status) {
|
| 9268 | var s_image;
|
| 9269 | switch (i_status) {
|
| 9270 | case "modem_destroy":
|
| 9271 | s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
|
| 9272 | break;
|
| 9273 | case "modem_imsi_waitnck":
|
| 9274 | s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitnck");
|
| 9275 | break;
|
| 9276 | case "modem_init_complete":
|
| 9277 | s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
|
| 9278 | break;
|
| 9279 | case "modem_sim_destroy":
|
| 9280 | s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
|
| 9281 | break;
|
| 9282 | case "modem_sim_undetected":
|
| 9283 | s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_undetected");
|
| 9284 | break;
|
| 9285 | case "modem_undetected":
|
| 9286 | s_image = "./pic/simcard_undetected.png";
|
| 9287 | break;
|
| 9288 | case "modem_waitpin":
|
| 9289 | s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpin");
|
| 9290 | break;
|
| 9291 | case "modem_waitpuk":
|
| 9292 | s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpuk");
|
| 9293 | break;
|
| 9294 |
|
| 9295 | default:
|
| 9296 | s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
|
| 9297 | break;
|
| 9298 | }
|
| 9299 | return s_image;
|
| 9300 | }
|
| 9301 |
|
| 9302 | function sf_dealChosenNumber(i_choosenName, i_choosenNum) {
|
| 9303 | setTimeout(function () {
|
| 9304 | var s_choosen = $("#chosenUserSelect");
|
| 9305 | var s_options = $("option", s_choosen);
|
| 9306 | for (var index = 0; index < s_options.length; index++) {
|
| 9307 | if (getLastNumber(i_choosenNum, config.SMS_MATCH_LENGTH) == s_options[index].value) {
|
| 9308 |
|
| 9309 | s_options[index].text = i_choosenName + '/' + i_choosenNum;
|
| 9310 | s_options[index].value = i_choosenNum;
|
| 9311 |
|
| 9312 | break;
|
| 9313 | }
|
| 9314 | }
|
| 9315 | s_choosen.trigger("liszt:updated");
|
| 9316 | }, 0);
|
| 9317 | }
|
| 9318 |
|
| 9319 | // ˫�첽��ȡ�豸����sim�����ö���Ϣ���������ϲ�
|
| 9320 | function sf_dealPhoneBooksResult(i_books){
|
| 9321 | if($.isArray(i_books.pbm_data) && i_books.pbm_data.length > 0){
|
| 9322 | config.phonebook = i_books.pbm_data;
|
| 9323 | }
|
| 9324 | }
|
| 9325 |
|
| 9326 | // �������µ�5������Ϣ����δ���ӵ������б��еĵ�����ʾ
|
| 9327 | function sf_filterNewMessage(i_messages, i_type){
|
| 9328 | if(!config.dbMsgs){
|
| 9329 | config.dbMsgs = [];
|
| 9330 | }
|
| 9331 | if(sv_dbMessageIds.length == 0){
|
| 9332 | $.each(config.dbMsgs, function(index_1, i_element){
|
| 9333 | sv_dbMessageIds.push(i_element.id);
|
| 9334 | });
|
| 9335 | }
|
| 9336 | $.each(i_messages, function(index_2, i_element){
|
| 9337 | if($.inArray(i_element.id, sv_dbMessageIds) == -1){//�����¶���
|
| 9338 | sv_dbMessageIds.push(i_element.id);
|
| 9339 | config.dbMsgs.push(i_element);
|
| 9340 | if(i_element.tag == '1'){
|
| 9341 | sf_addNewMessage(i_element, false, i_type);
|
| 9342 | }
|
| 9343 | }else{
|
| 9344 | for(var index = 0; index < config.dbMsgs.length; index++){//���¼�������
|
| 9345 | if(config.dbMsgs[index].id == i_element.id && config.dbMsgs[index].content != i_element.content && i_element.tag == '1'){
|
| 9346 | config.dbMsgs[index].content = i_element.content;
|
| 9347 | sf_addNewMessage(i_element, true, i_type);
|
| 9348 | break;
|
| 9349 | }
|
| 9350 | }
|
| 9351 | }
|
| 9352 | });
|
| 9353 | }
|
| 9354 |
|
| 9355 | // ������ת��Ϊ��ӦͼƬ
|
| 9356 | function sf_getBatteryLevelImage(pers, i_status) {
|
| 9357 | var s_Image = null;
|
| 9358 | if ("0" == i_status) {
|
| 9359 | if ("1" == pers) {
|
| 9360 | s_Image = "pic/power_one.png";
|
| 9361 | } else if ("2" == pers) {
|
| 9362 | s_Image = "pic/power_two.png";
|
| 9363 | } else if ("3" == pers) {
|
| 9364 | s_Image = "pic/power_three.png";
|
| 9365 | } else if ("4" == pers) {
|
| 9366 | s_Image = "pic/power_full.png";
|
| 9367 | } else { //"5" == pers || "0" == pers
|
| 9368 | s_Image = "pic/power_out.png";
|
| 9369 | }
|
| 9370 | } else {
|
| 9371 | s_Image = "pic/power_charging.gif";
|
| 9372 | }
|
| 9373 | return s_Image;
|
| 9374 | }
|
| 9375 |
|
| 9376 | // ��ȡ����״̬��CSS��ʽ
|
| 9377 | function sf_getConnectionCssClass(i_fwVm, i_status, i_data_counter, i_wifiSSID, i_wifiStatus, i_rj45Status) {
|
| 9378 |
|
| 9379 | var s_rj45ConnectionStatus = "icon_connection ";
|
| 9380 | var s_connectionStatus = "icon_connection ";
|
| 9381 |
|
| 9382 | if(i_rj45Status == "connect"){
|
| 9383 | s_rj45ConnectionStatus += "connecting";
|
| 9384 | }else if(i_rj45Status == "working"){
|
| 9385 | s_rj45ConnectionStatus += "rj45_connected";
|
| 9386 | }else{
|
| 9387 | s_rj45ConnectionStatus += "disconnect";
|
| 9388 | }
|
| 9389 |
|
| 9390 | if (i_status == "ppp_connecting" || i_status == "wifi_connecting") {
|
| 9391 | s_connectionStatus += "connecting";
|
| 9392 | } else if(i_status == "ppp_connected") {//CPE ppp_statusΪnone ready��ֵ
|
| 9393 | if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate != '0') {
|
| 9394 | s_connectionStatus += "connectionBoth";
|
| 9395 | } else if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate == '0') {
|
| 9396 | s_connectionStatus += "connectionUp";
|
| 9397 | } else if (i_data_counter.uploadRate == '0' && i_data_counter.downloadRate != '0') {
|
| 9398 | s_connectionStatus += "connectionDown";
|
| 9399 | } else {
|
| 9400 | s_connectionStatus += "connectionNone";
|
| 9401 | }
|
| 9402 | } else if (i_status == "ppp_disconnected") {
|
| 9403 | if (i_wifiSSID && i_wifiStatus == "connect") {
|
| 9404 | service.getHotspotList({}, function (data) {
|
| 9405 | var s_cssName = "icon_connection ";
|
| 9406 | var s_css = "connecting ";
|
| 9407 | for (var i = 0, len = data.hotspotList.length; i < len; i++) {
|
| 9408 | if (data.hotspotList[i].connectStatus == "1") {
|
| 9409 | s_css = "wifi_connected";
|
| 9410 | break;
|
| 9411 | }
|
| 9412 | }
|
| 9413 | s_cssName += s_css;
|
| 9414 | i_fwVm.connectionCssClass(s_cssName);
|
| 9415 | });
|
| 9416 | i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
|
| 9417 | return;
|
| 9418 | } else if (i_wifiSSID && (i_wifiStatus == "connecting" || i_wifiStatus =="dhcping")) {
|
| 9419 | s_connectionStatus += "connecting";
|
| 9420 | } else {
|
| 9421 | s_connectionStatus += "disconnect";
|
| 9422 | }
|
| 9423 | } else {
|
| 9424 | s_connectionStatus += "disconnect";
|
| 9425 | }
|
| 9426 |
|
| 9427 | i_fwVm.connectionCssClass(s_connectionStatus);
|
| 9428 | i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
|
| 9429 | }
|
| 9430 |
|
| 9431 | // ��ȡ�绰����Ϣ
|
| 9432 | function sf_getPhoneBooks() {
|
| 9433 | var s_books = service.getPhoneBooks({
|
| 9434 | page : 0,
|
| 9435 | data_per_page : 2000,
|
| 9436 | orderBy : "id",
|
| 9437 | isAsc : false
|
| 9438 | });
|
| 9439 | sf_dealPhoneBooksResult(s_books);
|
| 9440 | }
|
| 9441 |
|
| 9442 | // ��ȡ�ź�����CSS��ʽ
|
| 9443 | function sf_getSignalCssClass(siganl, networkType, simStatus) {
|
| 9444 | networkType = networkType.toLowerCase();
|
| 9445 | simStatus = simStatus ? simStatus.toLowerCase() : '';
|
| 9446 | if(networkType == '' || networkType == 'limited_service' || networkType == 'no_service' || networkType == 'limited service' || networkType == 'no service'
|
| 9447 | || simStatus != 'modem_init_complete'){
|
| 9448 | siganl = '_none';
|
| 9449 | }
|
| 9450 | return "signal signal" + siganl;
|
| 9451 | }
|
| 9452 |
|
| 9453 | function sf_getWifiStatusCssClass(i_status, i_deviceSize) {
|
| 9454 | if (i_status) {
|
| 9455 | if (i_deviceSize == 0) {
|
| 9456 | return "wifi_status0";
|
| 9457 | } else {
|
| 9458 | return "wifi_status" + i_deviceSize;
|
| 9459 | }
|
| 9460 | } else {
|
| 9461 | return "wifi_status_off";
|
| 9462 | }
|
| 9463 | }
|
| 9464 |
|
| 9465 | // ����wifi״̬��ȡwifi��ͼƬ��Դ
|
| 9466 | function sf_getWifiStatusImage(i_status, i_deviceSize) {
|
| 9467 | if (i_status) {
|
| 9468 | if (i_deviceSize == 0) {
|
| 9469 | return "./pic/wlan0.png";
|
| 9470 | } else {
|
| 9471 | return "./pic/wlan" + i_deviceSize + ".png";
|
| 9472 | }
|
| 9473 | } else {
|
| 9474 | return "./pic/wlan_off.png";
|
| 9475 | }
|
| 9476 | }
|
| 9477 |
|
| 9478 | // ��ȡ��������������С���������ؽ���
|
| 9479 | function sf_refreshFotaDownloadProgress(){
|
| 9480 | service.getPackSizeInfo({}, function (data) {
|
| 9481 | var percents;
|
| 9482 | if (parseInt(data.fota_pkg_total_size) == 0) {
|
| 9483 | percents = 0;
|
| 9484 | } else {
|
| 9485 | percents = parseInt(parseInt(data.fota_dl_pkg_size) * 100 / parseInt(data.fota_pkg_total_size));
|
| 9486 | }
|
| 9487 | if (percents > 100) {
|
| 9488 | percents = 100;
|
| 9489 | }
|
| 9490 | if (percents >= 0) {
|
| 9491 | if (percents > 95) {
|
| 9492 | showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
|
| 9493 | }
|
| 9494 | setProgressBar(percents);
|
| 9495 | }
|
| 9496 | });
|
| 9497 | }
|
| 9498 |
|
| 9499 | // �������ŷ��ͱ���
|
| 9500 | function sf_responseSmsReport(){
|
| 9501 | if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
|
| 9502 |
|
| 9503 | sv_isFirstLoadNewMessage = false;
|
| 9504 |
|
| 9505 | if(config.HAS_PHONEBOOK){
|
| 9506 | sf_getPhoneBooks();
|
| 9507 | }else{
|
| 9508 | config.phonebook = [];
|
| 9509 | }
|
| 9510 | }
|
| 9511 | service.getSMSDeliveryReport({
|
| 9512 | page: 0,
|
| 9513 | smsCount: 10
|
| 9514 | }, function(data){
|
| 9515 | var s_messages = data.messages;
|
| 9516 | var s_nums = [];
|
| 9517 | $.each(s_messages, function(i, i_message){
|
| 9518 | if($.inArray(i_message.number, s_nums) == -1){
|
| 9519 | s_nums.push(i_message.number);
|
| 9520 | window.setTimeout(function(){
|
| 9521 | var s_now = $.now();
|
| 9522 | sv_messagePopStack["m" + s_now] = s_now;
|
| 9523 | i_message.name = i_message.number;
|
| 9524 | for(i in config.phonebook){
|
| 9525 | if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
|
| 9526 | i_message.name = config.phonebook[i].pbm_name;
|
| 9527 | break;
|
| 9528 | }
|
| 9529 | }
|
| 9530 | var s_msgContent = $.i18n.prop("sms_delivery_report_" + i_message.content);
|
| 9531 |
|
| 9532 | var s_newMsg = {
|
| 9533 | mark : "m" + s_now,
|
| 9534 | name: i_message.name,
|
| 9535 | title: $.i18n.prop("sms_report"),
|
| 9536 | titleTrans: "sms_report",
|
| 9537 | content : s_msgContent,
|
| 9538 | datetime : i_message.time,
|
| 9539 | report : 'report'
|
| 9540 | };
|
| 9541 |
|
| 9542 | if(sv_newMessagePopTemplate == null){
|
| 9543 | sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
|
| 9544 | }
|
| 9545 |
|
| 9546 | $(".report", "#buttom-bubble").remove();
|
| 9547 | $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
|
| 9548 | }, 100);
|
| 9549 | }
|
| 9550 | });
|
| 9551 | }, function(){
|
| 9552 | //No Deal
|
| 9553 | });
|
| 9554 | }
|
| 9555 |
|
| 9556 | function sf_simStatusInvalid(simStatus){
|
| 9557 | return simStatus == 'modem_sim_undetected' || simStatus == 'modem_undetected' || simStatus == 'modem_sim_destroy'
|
| 9558 | || simStatus == 'modem_waitpin' || simStatus == 'modem_waitpuk' || simStatus == 'modem_imsi_waitnck';
|
| 9559 | }
|
| 9560 |
|
| 9561 | // ��ʾFOTA������ǰ״̬
|
| 9562 | function sf_showFotaCurrentStatus() {
|
| 9563 | sv_fotaUpdateCancel = true;
|
| 9564 | var r = service.getNewVersionState();
|
| 9565 |
|
| 9566 | function showProgress() {
|
| 9567 | var upgradingState = ["downloading"];
|
| 9568 | var info = service.getCurrentUpgradeState();
|
| 9569 | if(info.current_upgrade_state.toLowerCase() == "idle") {
|
| 9570 | addTimeout(showProgress, 1000);
|
| 9571 | } else if(($.inArray(info.current_upgrade_state, upgradingState) != -1)&&(r.fota_new_version_state != "already_has_pkg")) {
|
| 9572 | hideLoading();
|
| 9573 | sf_showFotaUpgradeStatus();
|
| 9574 | }
|
| 9575 | }
|
| 9576 | if (!($("#progress").is(":visible"))) {
|
| 9577 | showProgress();
|
| 9578 | }
|
| 9579 | var times = 0;
|
| 9580 | var getOTAUpgradeState = function () {
|
| 9581 | var data = null;
|
| 9582 | if (times <= 3) {
|
| 9583 | times = times + 1;
|
| 9584 | data = service.getCurrentUpgradeState();
|
| 9585 | } else {
|
| 9586 | data = getCurrentStatusInfo();
|
| 9587 | }
|
| 9588 | var state = data.current_upgrade_state;
|
| 9589 | if(sv_fotaUpdateCancel && isLoggedIn == true){
|
| 9590 |
|
| 9591 | if(r.fota_new_version_state == "already_has_pkg"){
|
| 9592 | if(state == 'low_battery'){
|
| 9593 | hideProgressBar();
|
| 9594 | sv_fotaUpdateCancel = false;
|
| 9595 | service.removeTimerThings('fota_current_upgrade_state',function(){});
|
| 9596 | showInfo('ota_pkg_low_battery');
|
| 9597 | window.clearTimeout(sv_timer);
|
| 9598 | return;
|
| 9599 | }else if(state == 'prepare_install'){
|
| 9600 | hideProgressBar();
|
| 9601 | sv_fotaUpdateCancel = false;
|
| 9602 | service.removeTimerThings('fota_current_upgrade_state',function(){});
|
| 9603 | showInfo('ota_pkg_download_success');
|
| 9604 | window.clearTimeout(sv_timer);
|
| 9605 | sv_batteryCheckTimer = setInterval(function () {
|
| 9606 | sf_checkBatteryStatusForFota();
|
| 9607 | }, 1000);
|
| 9608 | return;
|
| 9609 | }
|
| 9610 | }else if(state == 'downloading') {
|
| 9611 | sf_refreshFotaDownloadProgress();
|
| 9612 | }else if(state == 'download_failed') {
|
| 9613 | hideProgressBar();
|
| 9614 | sv_fotaUpdateCancel = false;
|
| 9615 | showAlert('ota_download_failed');
|
| 9616 | window.clearTimeout(sv_timer);
|
| 9617 | return;
|
| 9618 | }else if(state == 'low_battery'){
|
| 9619 | hideProgressBar();
|
| 9620 | sv_fotaUpdateCancel = false;
|
| 9621 | service.removeTimerThings('fota_current_upgrade_state',function(){});
|
| 9622 | showInfo('ota_low_battery');
|
| 9623 | window.clearTimeout(sv_timer);
|
| 9624 | return;
|
| 9625 | }else if(state == 'prepare_install'){
|
| 9626 | hideProgressBar();
|
| 9627 | sv_fotaUpdateCancel = false;
|
| 9628 | service.removeTimerThings('fota_current_upgrade_state',function(){});
|
| 9629 | showInfo('ota_download_success');
|
| 9630 | window.clearTimeout(sv_timer);
|
| 9631 | sv_batteryCheckTimer = setInterval(function () {
|
| 9632 | sf_checkBatteryStatusForFota();
|
| 9633 | }, 1000);
|
| 9634 | return;
|
| 9635 | }else{
|
| 9636 | sv_fotaUpdateCancel = false;
|
| 9637 | hideProgressBar();
|
| 9638 | window.clearTimeout(sv_timer);
|
| 9639 | return;
|
| 9640 | }
|
| 9641 | sv_timer = window.setTimeout(getOTAUpgradeState , 1000);
|
| 9642 | }
|
| 9643 | };
|
| 9644 |
|
| 9645 | if(sv_fotaUpdateCancel && isLoggedIn == true){
|
| 9646 | sv_timer = window.setTimeout(getOTAUpgradeState , 100);
|
| 9647 | }else{
|
| 9648 | window.clearTimeout(sv_timer);
|
| 9649 | }
|
| 9650 | }
|
| 9651 |
|
| 9652 | // ��ʾFota��������
|
| 9653 | function sf_showFotaUpdateResult(i_otaResult) {
|
| 9654 | if ((!($("#loading").is(":visible"))) && (!($("#confirm").is(":visible")))) {
|
| 9655 | var s_message = i_otaResult ? "ota_update_success" : "ota_update_failed";
|
| 9656 | sv_fotaResultAlertPopuped = true;
|
| 9657 | showAlert(s_message, function () {
|
| 9658 | sv_fotaResultAlertPopuped = false;
|
| 9659 | if (config.UPGRADE_TYPE == "OTA") {
|
| 9660 | service.clearUpdateResult({}, $.noop());
|
| 9661 | }
|
| 9662 | });
|
| 9663 | } else {
|
| 9664 | window.setTimeout(function () {
|
| 9665 | sf_showFotaUpdateResult(i_otaResult)
|
| 9666 | }, 1000);
|
| 9667 | }
|
| 9668 | }
|
| 9669 |
|
| 9670 | // ��ʾ��ǰ����״̬
|
| 9671 | function sf_showFotaUpgradeStatus() {
|
| 9672 | var s_data = service.getMandatory();
|
| 9673 | var s_isMandatory = s_data.is_mandatory;
|
| 9674 | var s_sizeInfo =service.getPackSizeInfo();
|
| 9675 | var s_percents;
|
| 9676 |
|
| 9677 | if (parseInt(s_sizeInfo.fota_pkg_total_size) == 0) {
|
| 9678 | s_percents = 0;
|
| 9679 | } else {
|
| 9680 | s_percents = parseInt(parseInt(s_sizeInfo.fota_dl_pkg_size) * 100 / parseInt(s_sizeInfo.fota_pkg_total_size));
|
| 9681 | }
|
| 9682 | if (s_percents > 100) {
|
| 9683 | s_percents = 100;
|
| 9684 | }
|
| 9685 |
|
| 9686 | if (s_isMandatory) {
|
| 9687 | showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
|
| 9688 | } else {
|
| 9689 | var cancelHtml = "";
|
| 9690 | if (config.UPGRADE_TYPE == "OTA") {
|
| 9691 | cancelHtml = "<br/><br/><button id='btnStopUpgrade' onclick='stopOTAUpgrade();' class='btn-1 btn-primary'>" + $.i18n.prop("cancel") + "</button>";
|
| 9692 | }
|
| 9693 | showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning") + cancelHtml);
|
| 9694 | }
|
| 9695 |
|
| 9696 | //setProgressBar(0);
|
| 9697 | if (s_percents >= 0) {
|
| 9698 | setProgressBar(s_percents);
|
| 9699 | }
|
| 9700 | }
|
| 9701 |
|
| 9702 |
|
| 9703 |
|
| 9704 |
|
| 9705 |
|
| 9706 | function sf_startFotaUpgrade(){
|
| 9707 | service.setUpgradeSelectOp({selectOp:'1'},function(result){
|
| 9708 | if (result.result == "success"){
|
| 9709 | sf_showFotaCurrentStatus();
|
| 9710 | }});
|
| 9711 | }
|
| 9712 |
|
| 9713 | function cancelFotaUpgrade(){
|
| 9714 | service.setUpgradeSelectOp({selectOp:'0'},function(result){ });
|
| 9715 | }
|
| 9716 |
|
| 9717 |
|
| 9718 | function refreshFotaStatusForUserSelector(choice){
|
| 9719 | var info = getCurrentStatusInfo();
|
| 9720 | if(choice){
|
| 9721 | var modeData = service.getOpMode();
|
| 9722 | if (!checkConnectedStatus(info.connectStatus, modeData.rj45_state, info.connectWifiStatus)) {
|
| 9723 | showAlert("ota_network_disconnected");
|
| 9724 | return;
|
| 9725 | }
|
| 9726 |
|
| 9727 | if(info.fota_user_selector == 'none'){
|
| 9728 | sf_startFotaUpgrade();
|
| 9729 | }else if(info.fota_user_selector == 'accept'){
|
| 9730 | sf_showFotaCurrentStatus();
|
| 9731 | }else if(info.fota_user_selector == 'cancel'){
|
| 9732 | showAlert("ota_have_cancel");
|
| 9733 | }else if(info.fota_user_selector == 'downloading_cancel'){
|
| 9734 | showAlert("ota_have_cancel");
|
| 9735 | }
|
| 9736 | }else{
|
| 9737 | if(info.fota_user_selector == 'none'){
|
| 9738 | cancelFotaUpgrade();
|
| 9739 | }else if(info.fota_user_selector == 'accept'){
|
| 9740 | sf_showFotaCurrentStatus();
|
| 9741 | }else if(info.fota_user_selector == 'cancel'){
|
| 9742 | // todo:
|
| 9743 | }else if(info.fota_user_selector == 'downloading_cancel'){
|
| 9744 | // todo:
|
| 9745 | }
|
| 9746 | }
|
| 9747 | }
|
| 9748 |
|
| 9749 |
|
| 9750 | // ��ʾ���°汾�������ж��Ƿ�������ʾ
|
| 9751 | function showFotaStatusForUserToConfirm(upgradeState) {
|
| 9752 | var upgState = upgradeState.current_upgrade_state;
|
| 9753 | if (upgState == 'upgrade_pack_redownload') {
|
| 9754 | showConfirm("ota_interrupted", {ok: function () {
|
| 9755 | refreshFotaStatusForUserSelector(1);
|
| 9756 | }, no: function () {
|
| 9757 | refreshFotaStatusForUserSelector(0);
|
| 9758 | }});
|
| 9759 | } else {
|
| 9760 | var upgradingState = ["prepare_install", "low_battery",
|
| 9761 | "connecting_server", "connect_server_success", "downloading", "accept"];
|
| 9762 | if ($.inArray(upgState, upgradingState) != -1) {
|
| 9763 | sf_showFotaCurrentStatus();
|
| 9764 | } else {
|
| 9765 |
|
| 9766 | showConfirm($.i18n.prop('ota_new_version'), {ok: function () {
|
| 9767 | refreshFotaStatusForUserSelector(1);
|
| 9768 | config.ISNOW_NOTICE = false;
|
| 9769 | }, no: function () {
|
| 9770 | refreshFotaStatusForUserSelector(0);
|
| 9771 | config.ISNOW_NOTICE = false;
|
| 9772 | }});
|
| 9773 | }
|
| 9774 | }
|
| 9775 | }
|
| 9776 |
|
| 9777 | showOTAAlert = function () {
|
| 9778 | config.ISNOW_NOTICE = true;
|
| 9779 | var is_mandatory = service.getMandatory().is_mandatory;
|
| 9780 | if (is_mandatory) {
|
| 9781 | sf_showFotaCurrentStatus();
|
| 9782 | } else {
|
| 9783 | var upgradeState = {};
|
| 9784 | upgradeState = service.getCurrentUpgradeState();
|
| 9785 | showFotaStatusForUserToConfirm(upgradeState);
|
| 9786 | }
|
| 9787 | };
|
| 9788 |
|
| 9789 | // ��ֹFota����
|
| 9790 | stopOTAUpgrade = function () {
|
| 9791 | service.setUpgradeSelectOp({selectOp:'2'},function(result){ });
|
| 9792 | sv_fotaUpdateCancel = false;
|
| 9793 | window.clearTimeout(sv_timer);
|
| 9794 | hideLoading();
|
| 9795 | showAlert('ota_cancel');
|
| 9796 | };
|
| 9797 |
|
| 9798 | // �������������Ƿ����ѹ�
|
| 9799 | function setTrafficAlertPopuped(val){
|
| 9800 | sv_trafficAlertPopuped = !!val;
|
| 9801 | sv_trafficAlertPopuped_100 = !!val;
|
| 9802 | if(!val){
|
| 9803 | sv_resetTrafficAlertPopuped = true;
|
| 9804 | }
|
| 9805 | }
|
| 9806 |
|
| 9807 | function setTrafficAlert100Popuped(val){
|
| 9808 | sv_trafficAlertPopuped_100 = !!val;
|
| 9809 | if(!val){
|
| 9810 | sv_resetTrafficAlertPopuped = true;
|
| 9811 | }
|
| 9812 | }
|
| 9813 |
|
| 9814 | // ���������ṹ
|
| 9815 | function getTrafficResult(info){
|
| 9816 | var s_trafficResult = {
|
| 9817 | showConfirm : false,
|
| 9818 | limitPercent : info.limitVolumePercent
|
| 9819 | };
|
| 9820 | if(info.limitVolumeType == '1'){
|
| 9821 | var monthlyTraffic = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
|
| 9822 | s_trafficResult.usedPercent = monthlyTraffic / info.limitVolumeSize * 100;
|
| 9823 | if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
|
| 9824 | s_trafficResult.showConfirm = true;
|
| 9825 | s_trafficResult.type = 'data';
|
| 9826 | }
|
| 9827 | }else{
|
| 9828 | s_trafficResult.usedPercent = info.data_counter.monthlyConnectedTime / info.limitVolumeSize * 100;
|
| 9829 | if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
|
| 9830 | s_trafficResult.showConfirm = true;
|
| 9831 | s_trafficResult.type = 'time';
|
| 9832 | }
|
| 9833 | }
|
| 9834 | return s_trafficResult;
|
| 9835 | }
|
| 9836 |
|
| 9837 | // ��ʼ�� ViewModel����������ͼ����
|
| 9838 | function init() {
|
| 9839 | if(config.PRODUCT_TYPE == 'DATACARD') {
|
| 9840 | $('#statusBar').addClass('padding-right-90');
|
| 9841 | $('#language').addClass('data-card-language');
|
| 9842 | }
|
| 9843 | //preload img
|
| 9844 | var imgAlert = $('<img />').attr('src', 'pic/res_alert.png');
|
| 9845 | var imgConfirm = $('<img />').attr('src', 'pic/res_confirm.png');
|
| 9846 | var imgInfo = $('<img />').attr('src', 'pic/res_info.png');
|
| 9847 |
|
| 9848 | window.setTimeout(function () {
|
| 9849 |
|
| 9850 | var fwVm = new statusViewModel();
|
| 9851 |
|
| 9852 | ko.applyBindings(fwVm, $('#statusBar')[0]);
|
| 9853 |
|
| 9854 | window.setInterval(function () {
|
| 9855 | var info = getCurrentStatusInfo();
|
| 9856 | var s_roamStatus = info.roamingStatus ? true : false;
|
| 9857 | var $langLogoBar = $("#langLogoBar");
|
| 9858 | isLoggedIn = info.isLoggedIn;
|
| 9859 |
|
| 9860 |
|
| 9861 | //fwVm.attachedDevices(info.attachedDevices);
|
| 9862 | fwVm.batteryLevel(info.batteryLevel + '%');
|
| 9863 | fwVm.batteryPers(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
|
| 9864 | fwVm.batteryStatus(info.batteryStatus);
|
| 9865 | fwVm.isShowFotaNewversionIcon(info.new_version_state && info.fota_user_selector && info.fota_package_already_download != "yes" && config.ISNOW_NOTICE && fwVm.updateType() == 'mifi_fota');
|
| 9866 | fwVm.isShowRj45ConnectionIcon(config.RJ45_SUPPORT);
|
| 9867 | fwVm.networkOperator(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,s_roamStatus));
|
| 9868 | fwVm.networkType(getNetworkType(info.networkType));
|
| 9869 | fwVm.pinStatus(info.pinStatus);
|
| 9870 | fwVm.roamingStatus(info.roamingStatus ? "R" : "");
|
| 9871 | fwVm.showAttachedDevices(info.wifiStatus);
|
| 9872 | fwVm.simStatus(sf_convertSimStatusToImage(info.simStatus));
|
| 9873 | fwVm.signalCssClass(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
|
| 9874 | fwVm.isLoggedIn(info.isLoggedIn);
|
| 9875 | fwVm.wifiStatusCssClass(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
|
| 9876 | fwVm.wifiStatusImg(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
|
| 9877 |
|
| 9878 | if(config.HAS_SMS ){
|
| 9879 | if(!sv__hasCheckedSMSCapacity && info.isLoggedIn){
|
| 9880 | checkSMSCapacity(info.smsUnreadCount);
|
| 9881 | } else {
|
| 9882 | fwVm.smsUnreadCount(info.smsUnreadCount);
|
| 9883 | }
|
| 9884 | }
|
| 9885 |
|
| 9886 | sf_getConnectionCssClass(fwVm, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
|
| 9887 | refreshWifiConnectStatus(fwVm, info.connectStatus,info.connectWifiSSID,info.connectWifiStatus);
|
| 9888 | checkTrafficLimitAlert(fwVm, info);
|
| 9889 | updateStatusBarTrans({simStatus: info.simStatus, wifiStatus: info.wifiStatus, deviceSize: info.wirelessDeviceNum, networkType: info.networkType});
|
| 9890 |
|
| 9891 | if(info.isLoggedIn){
|
| 9892 | $("#statusBar:hidden").show();
|
| 9893 | } else {
|
| 9894 | $("#statusBar:visible").hide();
|
| 9895 | }
|
| 9896 | }, 500);
|
| 9897 |
|
| 9898 | if(config.HAS_SMS){
|
| 9899 | window.setInterval(function(){
|
| 9900 | if(fwVm.isLoggedIn()){
|
| 9901 | checkSMSCapacity();
|
| 9902 | }
|
| 9903 | }, 10000);
|
| 9904 | checkSmsModelReady();
|
| 9905 | }
|
| 9906 |
|
| 9907 | window.setInterval(function() {
|
| 9908 | var data = getCurrentStatusInfo();
|
| 9909 | var upgradingState = ["prepare_install", "low_battery", "download_success","downloading"];
|
| 9910 |
|
| 9911 | if (fwVm.isLoggedIn() == true && !($("#progress").is(":visible")) && data.defaultWanName != ""){
|
| 9912 | if ($.inArray(data.current_upgrade_state, upgradingState) != -1){
|
| 9913 | if(null == sv_fotaUpdateCancel){
|
| 9914 | if(!data.is_mandatory){
|
| 9915 | $.modal.close();
|
| 9916 | }
|
| 9917 | sf_showFotaCurrentStatus();
|
| 9918 | }else if(false == sv_fotaUpdateCancel){
|
| 9919 | sv_fotaUpdateCancel = null;
|
| 9920 | }
|
| 9921 | }
|
| 9922 | }
|
| 9923 | }, 1000);
|
| 9924 |
|
| 9925 | var checkFotaUpgradeResult = function () {
|
| 9926 | var info = service.getStatusInfo();
|
| 9927 | if (info.isLoggedIn) {
|
| 9928 | service.getUpgradeResult({}, function (data) {
|
| 9929 | if (data.upgrade_result == "success") {
|
| 9930 | sf_showFotaUpdateResult(true);
|
| 9931 | } else if (data.upgrade_result == "fail") {
|
| 9932 | sf_showFotaUpdateResult(false);
|
| 9933 | } else {
|
| 9934 | window.setTimeout(checkFotaUpgradeResult, 1000);
|
| 9935 | }
|
| 9936 | }, function () {
|
| 9937 | window.setTimeout(checkFotaUpgradeResult, 1000);
|
| 9938 | });
|
| 9939 | } else {
|
| 9940 | window.setTimeout(checkFotaUpgradeResult, 1000);
|
| 9941 | }
|
| 9942 | };
|
| 9943 | if(fwVm.updateType() == "mifi_fota"){
|
| 9944 | checkFotaUpgradeResult();
|
| 9945 | window.setInterval(function () {
|
| 9946 | var info = getCurrentStatusInfo();
|
| 9947 | if (info.isLoggedIn && info.defaultWanName != "") {
|
| 9948 | if(info.new_version_state && info.fota_package_already_download != "yes" && !config.ALREADY_NOTICE){
|
| 9949 | service.getUpgradeResult({}, function (data) {
|
| 9950 | if (data.upgrade_result == "success") {
|
| 9951 | sf_showFotaUpdateResult(true);
|
| 9952 | } else if (data.upgrade_result == "fail") {
|
| 9953 | sf_showFotaUpdateResult(false);
|
| 9954 | } else {
|
| 9955 | if(sv_fotaResultAlertPopuped == false){
|
| 9956 | config.ALREADY_NOTICE = true;
|
| 9957 | showOTAAlert();
|
| 9958 | }
|
| 9959 | }
|
| 9960 | });
|
| 9961 | }
|
| 9962 | }
|
| 9963 | }, 1000);
|
| 9964 | }
|
| 9965 | function checkSMSCapacity(unreadCount){
|
| 9966 | service.getSmsCapability({}, function(info){
|
| 9967 | var showSmsConfirm = false;
|
| 9968 | if(info.nvTotal != 0 && info.nvUsed >= info.nvTotal){
|
| 9969 | $("#sms_unread_count").attr("tipTitle", "sms_capacity_is_full");
|
| 9970 | showSmsConfirm = true;
|
| 9971 | } else if(info.nvTotal != 0 && info.nvUsed + 5 >= info.nvTotal) {
|
| 9972 | $("#sms_unread_count").attr("tipTitle", "sms_capacity_will_full");
|
| 9973 | showSmsConfirm = true;
|
| 9974 | } else {
|
| 9975 | $("#sms_unread_count").attr("tipTitle", "sms_unread_count");
|
| 9976 | }
|
| 9977 | fwVm.showSmsDeleteConfirm(showSmsConfirm);
|
| 9978 | if(typeof unreadCount != "undefined"){
|
| 9979 | fwVm.smsUnreadCount(unreadCount);
|
| 9980 | }
|
| 9981 | sv__hasCheckedSMSCapacity = true;
|
| 9982 | });
|
| 9983 | }
|
| 9984 | }, 1200);
|
| 9985 |
|
| 9986 | tooltip.init();
|
| 9987 |
|
| 9988 | // ������Ϣģ����ʼ��״̬
|
| 9989 | function checkSmsModelReady(){
|
| 9990 | var info = getCurrentStatusInfo();
|
| 9991 | if(info.isLoggedIn){
|
| 9992 | service.getSMSReady({}, function (data) {
|
| 9993 | if (data.sms_cmd_status_result == "1") {
|
| 9994 | window.setTimeout(function(){checkSmsModelReady();}, 1000);
|
| 9995 | } else {
|
| 9996 | sv__initSMSCompleted = true;
|
| 9997 | }
|
| 9998 | });
|
| 9999 | } else {
|
| 10000 | window.setTimeout(function(){checkSmsModelReady();}, 1000);
|
| 10001 | }
|
| 10002 | }
|
| 10003 |
|
| 10004 | // ������������״̬
|
| 10005 | checkTrafficLimitAlert = function(fwVm, info){
|
| 10006 | if(window.location.hash == '#entry'){
|
| 10007 | return false;
|
| 10008 | }
|
| 10009 | var APStationEnabled = config.AP_STATION_SUPPORT ? service.getStatusInfo().ap_station_enable : 'undefined';
|
| 10010 | var trafficResult = getTrafficResult(info);
|
| 10011 | var inShow = $("#confirm-container:visible").length > 0;
|
| 10012 | var notPPP = (config.PRODUCT_TYPE == 'CPE' && checkCableMode(info.blc_wan_mode)) ? true : false;
|
| 10013 |
|
| 10014 | // ��ȡAp Stationʹ��״̬���������ѷ�ʽ
|
| 10015 | if (config.AP_STATION_SUPPORT && (typeof APStationEnabled == "undefined" || APStationEnabled === '')) {
|
| 10016 | service.refreshAPStationStatus({}, $.noop());
|
| 10017 | return false;
|
| 10018 | }
|
| 10019 | APStationEnabled = APStationEnabled == 1;
|
| 10020 |
|
| 10021 | if (!info.isLoggedIn || inShow || (sv_trafficAlertPopuped && sv_trafficAlertPopuped_100) || !info.limitVolumeEnable || (!APStationEnabled && !(info.connectStatus == "ppp_connected")) || notPPP) {
|
| 10022 | return false;
|
| 10023 | }
|
| 10024 |
|
| 10025 | if(sv_resetTrafficAlertPopuped){
|
| 10026 | window.setTimeout(function () {
|
| 10027 | sv_resetTrafficAlertPopuped = false;
|
| 10028 | }, 2000);
|
| 10029 | return false;
|
| 10030 | }
|
| 10031 |
|
| 10032 | if(trafficResult.showConfirm){
|
| 10033 |
|
| 10034 | var confirmMessage = null;
|
| 10035 |
|
| 10036 | if(trafficResult.usedPercent > 100 && !sv_trafficAlertPopuped_100){
|
| 10037 |
|
| 10038 | sv_trafficAlertPopuped = true;
|
| 10039 | sv_trafficAlertPopuped_100 = true;
|
| 10040 |
|
| 10041 | confirmMessage = {msg: APStationEnabled ? 'traffic_beyond_msg' : 'traffic_beyond_disconnect_msg'};
|
| 10042 |
|
| 10043 | } else if (!sv_trafficAlertPopuped) {
|
| 10044 |
|
| 10045 | sv_trafficAlertPopuped = true;
|
| 10046 | sv_trafficAlertPopuped_100 = false;
|
| 10047 | confirmMessage = {msg: APStationEnabled ? 'traffic_limit_msg' : 'traffic_limit_disconnect_msg',
|
| 10048 | params: [trafficResult.limitPercent]};
|
| 10049 | }
|
| 10050 |
|
| 10051 | if (confirmMessage != null) {
|
| 10052 | if (APStationEnabled) {
|
| 10053 | showAlert(confirmMessage);
|
| 10054 | } else {
|
| 10055 | showConfirm(confirmMessage, function () {
|
| 10056 | showLoading("disconnecting");
|
| 10057 | service.disconnect({}, function (data) {
|
| 10058 | if (data.result) {
|
| 10059 | successOverlay();
|
| 10060 | } else {
|
| 10061 | errorOverlay();
|
| 10062 | }
|
| 10063 | });
|
| 10064 | });
|
| 10065 | }
|
| 10066 | }
|
| 10067 | }
|
| 10068 | return true;
|
| 10069 | };
|
| 10070 |
|
| 10071 | // ����״̬�е�tooltip
|
| 10072 | function updateStatusBarTrans(status){
|
| 10073 | $("#statusItemSimStatus").attr("tipTitle", "sim_status_" + status.simStatus);
|
| 10074 | if (status.wifiStatus) {
|
| 10075 | if (status.deviceSize == 0) {
|
| 10076 | $("#wifi_status").attr("tipTitle","wifi_status_on");
|
| 10077 | } else {
|
| 10078 | $("#wifi_status").attr("tipTitle","wifi_status" + status.deviceSize);
|
| 10079 | }
|
| 10080 | } else {
|
| 10081 | $("#wifi_status").attr("tipTitle","wifi_status_off");
|
| 10082 | }
|
| 10083 | }
|
| 10084 |
|
| 10085 |
|
| 10086 | // ˢ��wifi��������״̬
|
| 10087 | function refreshWifiConnectStatus(fwVm, status, wifiSSID, wifiStatus) {
|
| 10088 | fwVm.connectStatus(status);
|
| 10089 | if (status == "ppp_disconnecting") {
|
| 10090 | fwVm.connectStatusTrans("disconnecting");
|
| 10091 | fwVm.connectStatusText($.i18n.prop("disconnecting"));
|
| 10092 | } else if (status == "ppp_connecting") {
|
| 10093 | fwVm.connectStatusTrans("connecting");
|
| 10094 | fwVm.connectStatusText($.i18n.prop("connecting"));
|
| 10095 | } else if (status == "ppp_connected") {
|
| 10096 | fwVm.connectStatusTrans("connected");
|
| 10097 | fwVm.connectStatusText($.i18n.prop("connected"));
|
| 10098 | } else if(wifiSSID){
|
| 10099 | if(wifiStatus =="dhcping" || wifiStatus =="connecting"){
|
| 10100 | fwVm.connectStatus("wifi_connecting");
|
| 10101 | fwVm.connectStatusTrans("connecting");
|
| 10102 | fwVm.connectStatusText($.i18n.prop("connecting"));
|
| 10103 | }else if(wifiStatus =="connect"){
|
| 10104 | fwVm.connectStatus("wifi_connect");
|
| 10105 | fwVm.connectStatusTrans("connected");
|
| 10106 | fwVm.connectStatusText($.i18n.prop("connected"));
|
| 10107 | }else{
|
| 10108 | fwVm.connectStatus("ppp_disconnected");
|
| 10109 | fwVm.connectStatusTrans("disconnected");
|
| 10110 | fwVm.connectStatusText($.i18n.prop("disconnected"));
|
| 10111 | }
|
| 10112 | }else{
|
| 10113 | fwVm.connectStatusTrans("disconnected");
|
| 10114 | fwVm.connectStatusText($.i18n.prop("disconnected"));
|
| 10115 | }
|
| 10116 | }
|
| 10117 |
|
| 10118 | // ��ȡ��ǰ����״̬
|
| 10119 | getNetworkType = function(networkType) {
|
| 10120 | var networkTypeTmp = networkType.toLowerCase();
|
| 10121 | if (networkTypeTmp == '' || networkTypeTmp == 'limited service') {
|
| 10122 | networkTypeTmp = 'limited_service';
|
| 10123 | }
|
| 10124 | if(networkTypeTmp == 'no service') {
|
| 10125 | networkTypeTmp = 'no_service';
|
| 10126 | }
|
| 10127 | if (networkTypeTmp == 'limited_service' || networkTypeTmp == 'no_service') {
|
| 10128 | $("#networkType", "#statusBar").attr("data-trans", "network_type_" + networkTypeTmp);
|
| 10129 | return $.i18n.prop("network_type_" + networkTypeTmp);
|
| 10130 | } else {
|
| 10131 | $("#networkType", "#statusBar").removeAttr("data-trans");
|
| 10132 | return networkType;
|
| 10133 | }
|
| 10134 | };
|
| 10135 |
|
| 10136 | if(config.HAS_SMS && menu.checkIsMenuExist("sms_list")){
|
| 10137 | window.setInterval(function () {
|
| 10138 | var info = getCurrentStatusInfo();
|
| 10139 | if(window.location.hash == "#entry" || sf_simStatusInvalid(info.simStatus)){
|
| 10140 | return;
|
| 10141 | }
|
| 10142 | for(key in sv_messagePopStack){
|
| 10143 | var val = sv_messagePopStack[key];
|
| 10144 | if($.now() - val > 5000){
|
| 10145 | delete(sv_messagePopStack["m" + val]);
|
| 10146 | var node = $(".bubbleItem#m" + val, "#buttom-bubble");
|
| 10147 | node.fadeOut(1000, function(){
|
| 10148 | $(this).remove();
|
| 10149 | });
|
| 10150 | }
|
| 10151 | }
|
| 10152 | if(info.isLoggedIn){
|
| 10153 | if(info.newSmsReceived && !sv_newSMSMessageInDealing){
|
| 10154 | sv_newSMSMessageInDealing = true;
|
| 10155 | service.resetNewSmsReceivedVar();
|
| 10156 | sf_checkNewMessages();
|
| 10157 | }
|
| 10158 | if(info.smsReportReceived){
|
| 10159 | service.resetSmsReportReceivedVar();
|
| 10160 | sf_responseSmsReport();
|
| 10161 | }
|
| 10162 | }
|
| 10163 | }, 1000);
|
| 10164 |
|
| 10165 | if(config.SMS_DATABASE_SORT_SUPPORT){
|
| 10166 | window.setInterval(function(){
|
| 10167 | if(menu.checkIsMenuExist("sms_list")){
|
| 10168 | var info = getCurrentStatusInfo();
|
| 10169 | if(info.isLoggedIn && sv__initSMSCompleted && !sv_newSMSMessageInDealing && !sf_simStatusInvalid(info.simStatus)){
|
| 10170 | sv_newSMSMessageInDealing = true;
|
| 10171 | sf_checkNewMessages();
|
| 10172 | }
|
| 10173 | }
|
| 10174 | }, 20001);
|
| 10175 | }
|
| 10176 | }
|
| 10177 |
|
| 10178 | function sf_checkNewMessages(){
|
| 10179 |
|
| 10180 | var s_tags = 1;
|
| 10181 | var s_smsCount = 5;
|
| 10182 |
|
| 10183 | if(!config.dbMsgs || config.dbMsgs.length == 0){
|
| 10184 | s_smsCount = 500;
|
| 10185 | s_tags = 10;
|
| 10186 | }
|
| 10187 | service.getSMSMessages({
|
| 10188 | page : 0,
|
| 10189 | smsCount : s_smsCount,
|
| 10190 | nMessageStoreType : 0,
|
| 10191 | tags : s_tags,
|
| 10192 | orderBy : "order by id desc"
|
| 10193 | }, function(data){
|
| 10194 | if(data && data.messages){
|
| 10195 | sf_filterNewMessage(data.messages, 0);
|
| 10196 | }
|
| 10197 | sv_newSMSMessageInDealing = false;
|
| 10198 | });
|
| 10199 | service.getSMSMessages({
|
| 10200 | page : 0,
|
| 10201 | smsCount : s_smsCount,
|
| 10202 | nMessageStoreType : 1,
|
| 10203 | tags : s_tags,
|
| 10204 | orderBy : "order by id desc"
|
| 10205 | }, function(data){
|
| 10206 | if(data && data.messages){
|
| 10207 | sf_filterNewMessage(data.messages, 1);
|
| 10208 | }
|
| 10209 | sv_newSMSMessageInDealing = false;
|
| 10210 | });
|
| 10211 | }
|
| 10212 |
|
| 10213 | if(config.HAS_SMS){
|
| 10214 | $(".bubbleItem", "#buttom-bubble").live("mouseover", function(){
|
| 10215 | var $this = $(this);
|
| 10216 | delete(sv_messagePopStack[$this.attr("id")]);
|
| 10217 | }).live("mouseout", function(){
|
| 10218 | var $this = $(this);
|
| 10219 | var now = $.now();
|
| 10220 | sv_messagePopStack["m" + now] = now;
|
| 10221 | $this.attr("id", "m" + now);
|
| 10222 | $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").data("targetid", "m" + now);
|
| 10223 | });
|
| 10224 |
|
| 10225 | $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").die().live("click", function(){
|
| 10226 | var id = $(this).data("targetid");
|
| 10227 | delete(sv_messagePopStack[id]);
|
| 10228 | var node = $(".bubbleItem#" + id, "#buttom-bubble");
|
| 10229 | node.fadeOut(1000, function(){
|
| 10230 | $(this).remove();
|
| 10231 | });
|
| 10232 | });
|
| 10233 | }
|
| 10234 | }
|
| 10235 |
|
| 10236 |
|
| 10237 | return {
|
| 10238 | init:init,
|
| 10239 | setTrafficAlertPopuped: setTrafficAlertPopuped,
|
| 10240 | setTrafficAlert100Popuped: setTrafficAlert100Popuped,
|
| 10241 | getTrafficResult: getTrafficResult,
|
| 10242 | showOTAAlert:showOTAAlert
|
| 10243 | };
|
| 10244 | });
|
| 10245 |
|
| 10246 | // ����ͳ������ģ��
|
| 10247 | define("status_traffic_alert","jquery knockout service statusBar echarts".split(" "),
|
| 10248 |
|
| 10249 | function ($, ko, service, status, echarts) {
|
| 10250 |
|
| 10251 | var sv_trafficGraph = null;
|
| 10252 | var sv_sourceData = null;
|
| 10253 | var sv_usedDataModified = false;
|
| 10254 | var sv_usedTimeModified = false;
|
| 10255 |
|
| 10256 | var sv_trafficStaticalInfo = {
|
| 10257 | // ����ͼ��ʼֵ
|
| 10258 | data: {
|
| 10259 | alarm: {
|
| 10260 |
|
| 10261 | itemStyle: {
|
| 10262 | normal: {
|
| 10263 | color: '#8CC916'
|
| 10264 | }
|
| 10265 | },
|
| 10266 | name: '������',
|
| 10267 | value: 19.7
|
| 10268 | },
|
| 10269 | alert: {
|
| 10270 |
|
| 10271 | itemStyle: {
|
| 10272 | normal: {
|
| 10273 | color: '#FF5500'
|
| 10274 | }
|
| 10275 | },
|
| 10276 | name: '����ֵ',
|
| 10277 | value: 1
|
| 10278 | },
|
| 10279 | free: {
|
| 10280 |
|
| 10281 | itemStyle: {
|
| 10282 | normal: {
|
| 10283 | color: '#D8D8D8'
|
| 10284 | }
|
| 10285 | },
|
| 10286 | name: 'δʹ��',
|
| 10287 | value: 50
|
| 10288 | },
|
| 10289 | full: {
|
| 10290 |
|
| 10291 |
|
| 10292 | itemStyle: {
|
| 10293 | normal: {
|
| 10294 | color: '#DF4313'
|
| 10295 | }
|
| 10296 | },
|
| 10297 | name: '��������',
|
| 10298 | value: 30
|
| 10299 | },
|
| 10300 | left1: {
|
| 10301 |
|
| 10302 | itemStyle: {
|
| 10303 | normal: {
|
| 10304 | color: '#D8D8D8'
|
| 10305 | }
|
| 10306 | },
|
| 10307 | name: '����ֵ��δʹ��',
|
| 10308 | value: 50,
|
| 10309 | },
|
| 10310 | start: {
|
| 10311 |
|
| 10312 | itemStyle: {
|
| 10313 | normal: {
|
| 10314 | color: '#D8D8D8'
|
| 10315 | }
|
| 10316 | },
|
| 10317 | name: '����ֵ��δʹ��',
|
| 10318 | value: 50
|
| 10319 | },
|
| 10320 | used: {
|
| 10321 |
|
| 10322 | itemStyle: {
|
| 10323 | normal: {
|
| 10324 | color: '#8CC916'
|
| 10325 | }
|
| 10326 | },
|
| 10327 | name: '��ʹ��',
|
| 10328 | value: 30
|
| 10329 | }
|
| 10330 | },
|
| 10331 | cacheEle: {},
|
| 10332 | // Ԫ�ػ�ȡ
|
| 10333 | getEle: function (i_elementId) {
|
| 10334 | if (this.cacheEle.hasOwnProperty('id')) {
|
| 10335 | return this.cacheEle[i_elementId];
|
| 10336 | } else {
|
| 10337 | this.cacheEle[i_elementId] = $("#" + i_elementId);
|
| 10338 | return this.cacheEle[i_elementId];
|
| 10339 | }
|
| 10340 | },
|
| 10341 | // ��ȡ�����澯״ֵ̬
|
| 10342 | fetchTrafficAlertInfo: function(){
|
| 10343 | sv_sourceData = getTrafficAlertInfo();
|
| 10344 | return sv_sourceData;
|
| 10345 | },
|
| 10346 | // ��ȡ����ֵ�Ͷ�Ӧ��λֵ
|
| 10347 | getTrafficStatisticalDatalnfo: function (i_valueInfo) {
|
| 10348 | return {
|
| 10349 | data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
|
| 10350 | unit: /[A-Z]{1,2}/.exec(i_valueInfo)[0]
|
| 10351 | }
|
| 10352 | },
|
| 10353 |
|
| 10354 | // ��ȡʱ��ʱ���֡���
|
| 10355 | getTrafficTimeHours: function (i_time) {
|
| 10356 | var s_timeArray = i_time.split(':');
|
| 10357 | return {
|
| 10358 | h: parseInt(s_timeArray[0], 10),
|
| 10359 | m: parseInt(s_timeArray[1], 10),
|
| 10360 | s: parseInt(s_timeArray[2], 10)
|
| 10361 | }
|
| 10362 | },
|
| 10363 | // ��ȡͳ��ʱ���Ͷ�Ӧ��λֵ
|
| 10364 | getTrafficTimeInfo: function (i_valueInfo) {
|
| 10365 | return {
|
| 10366 | data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
|
| 10367 | unit: /[a-z]{4,6}/.exec(i_valueInfo)[0]
|
| 10368 | }
|
| 10369 | },
|
| 10370 | // ʱ�任����S
|
| 10371 | getTrafficTimeToSeconds: function (i_time) {
|
| 10372 | var s_FormattedTime = this.getTrafficTimeHours(i_time);
|
| 10373 | return s_FormattedTime.h * 3600 + s_FormattedTime.m * 60 + s_FormattedTime.s;
|
| 10374 | },
|
| 10375 | // ͨ�����ƻ�ȡ������λ
|
| 10376 | getTrafficUnitByScale: function (i_scale) {
|
| 10377 | if (i_scale == '1024') {
|
| 10378 | return 'GB';
|
| 10379 | } else if (i_scale == '1048576') {
|
| 10380 | return 'TB';
|
| 10381 | } else {
|
| 10382 | return 'MB';
|
| 10383 | }
|
| 10384 | },
|
| 10385 | // ��λ��Ӧֵ��ȡ
|
| 10386 | getTrafficValueByStatisticalUnit: function (i_unit) {
|
| 10387 | i_unit = i_unit.toLowerCase();
|
| 10388 | if(i_unit == 'minute'){
|
| 10389 | return '60';
|
| 10390 | } else if (i_unit == 'gb') {
|
| 10391 | return '1024';
|
| 10392 | } else if(i_unit == 'hour'){
|
| 10393 | return '3600';
|
| 10394 | } else if (i_unit == 'tb') {
|
| 10395 | return '1048576';
|
| 10396 | } else {
|
| 10397 | return '1';
|
| 10398 | }
|
| 10399 | },
|
| 10400 |
|
| 10401 | // ���������Ƿ��ɱà¼
|
| 10402 | isFormEditable: function (fwVm) {
|
| 10403 | var s_dataPageEditState = fwVm.dataLimitTypeChecked() == '1' && (fwVm.viewEditUsedData() || fwVm.viewEditAlertData() || fwVm.viewEditTotalData());
|
| 10404 | var s_timePageEditState = fwVm.dataLimitTypeChecked() == '0' && (fwVm.viewEditUsedTime() || fwVm.viewEditAlertTime() || fwVm.viewEditTotalTime());
|
| 10405 | if (s_dataPageEditState || s_timePageEditState) {
|
| 10406 | $('.border-color-transition:visible').addClass('attention-focus');
|
| 10407 | addTimeout(function () {
|
| 10408 | $('.border-color-transition:visible').removeClass('attention-focus');
|
| 10409 | }, 1500);
|
| 10410 | return true;
|
| 10411 | } else {
|
| 10412 | var s_result = false;
|
| 10413 | if (fwVm.dataLimitTypeChecked() == 1) {
|
| 10414 | if (fwVm.alertDataReach() == '0') {
|
| 10415 | fwVm.editAlertDataHandler();
|
| 10416 | s_result = true;
|
| 10417 | }
|
| 10418 | if (fwVm.limitDataMonth() == '0') {
|
| 10419 | fwVm.editTotalDataHandler();
|
| 10420 | s_result = true;
|
| 10421 | }
|
| 10422 | } else {
|
| 10423 | if (fwVm.alertTimeReach() == '0') {
|
| 10424 | fwVm.editAlertTimeHandler();
|
| 10425 | s_result = true;
|
| 10426 | }
|
| 10427 | if (fwVm.limitTimeMonth() == '0') {
|
| 10428 | fwVm.editTotalTimeHandler();
|
| 10429 | s_result = true;
|
| 10430 | }
|
| 10431 | }
|
| 10432 |
|
| 10433 | if (s_result) {
|
| 10434 | $('.border-color-transition:visible').addClass('attention-focus');
|
| 10435 | addTimeout(function () {
|
| 10436 | $('.border-color-transition:visible').removeClass('attention-focus');
|
| 10437 | }, 1500);
|
| 10438 | }
|
| 10439 | return s_result;
|
| 10440 | }
|
| 10441 | },
|
| 10442 |
|
| 10443 | // ˢ������ͼ��Ϣ������������ֵ����ʾ����
|
| 10444 |
|
| 10445 | refreshFlowDiagramInfo: function (fwVm) {
|
| 10446 | var s_alarm = 0;
|
| 10447 | var s_left = 0;
|
| 10448 | var s_left1 = 0;
|
| 10449 | var s_reach = 0;
|
| 10450 | var s_total = 0;
|
| 10451 | var s_used = 0;
|
| 10452 |
|
| 10453 |
|
| 10454 | var s_startName = $.i18n.prop("echarts_no");
|
| 10455 |
|
| 10456 | if (sv_sourceData.dataLimitChecked == '1') { //if (fwVm.dataLimitChecked() == '1') { //����
|
| 10457 | s_startName = $.i18n.prop("echarts_used");
|
| 10458 | sv_trafficGraphOptions.series[0].data = [];
|
| 10459 |
|
| 10460 | if (fwVm.dataLimitTypeChecked() == '1') { // ����
|
| 10461 | sv_trafficGraphOptions.title.text = "";
|
| 10462 | sv_trafficGraphOptions.series[0].data = [];
|
| 10463 |
|
| 10464 | if (fwVm.limitDataMonth() == 0) {
|
| 10465 | var s_usedData = sv_trafficStaticalInfo.data.used;
|
| 10466 | s_usedData.value = 1;
|
| 10467 | s_usedData.name = $.i18n.prop("echarts_used");
|
| 10468 | s_usedData.selected = false;
|
| 10469 | sv_trafficGraphOptions.series[0].data.push(s_usedData);
|
| 10470 | } else {
|
| 10471 | s_total = fwVm.limitDataMonth() * fwVm.selectedDataUnit() * 1048576;
|
| 10472 | s_used = parseInt(sv_sourceData.monthlySent, 10) + parseInt(sv_sourceData.monthlyReceived, 10);
|
| 10473 | s_reach = s_total * fwVm.alertDataReach() / 100;
|
| 10474 |
|
| 10475 | if (s_used >= s_total) {
|
| 10476 | var s_fullData = sv_trafficStaticalInfo.data.full;
|
| 10477 | s_fullData.value = 100;
|
| 10478 | s_fullData.name = $.i18n.prop("echarts_full");
|
| 10479 | sv_trafficGraphOptions.series[0].data.push(s_fullData);
|
| 10480 | s_startName = $.i18n.prop("echarts_full");
|
| 10481 | } else {
|
| 10482 | if (s_reach > s_used) {
|
| 10483 | s_left1 = s_reach - s_used;
|
| 10484 | s_left = s_total - s_reach;
|
| 10485 | } else {
|
| 10486 | s_alarm = s_used - s_reach;
|
| 10487 | s_left = s_total - s_used;
|
| 10488 | }
|
| 10489 |
|
| 10490 | var s_usedData = sv_trafficStaticalInfo.data.used;
|
| 10491 | if (s_reach - s_used > 0) {
|
| 10492 | s_usedData.value = s_used;
|
| 10493 | } else {
|
| 10494 | s_usedData.value = s_reach;
|
| 10495 | }
|
| 10496 | s_usedData.name = $.i18n.prop("echarts_used");
|
| 10497 | sv_trafficGraphOptions.series[0].data.push(s_usedData);
|
| 10498 |
|
| 10499 | if (s_left1 > 0) {
|
| 10500 | var s_left1Data = sv_trafficStaticalInfo.data.left1;
|
| 10501 | s_left1Data.value = s_left1;
|
| 10502 | s_left1Data.name = $.i18n.prop("echarts_left1");
|
| 10503 | sv_trafficGraphOptions.series[0].data.push(s_left1Data);
|
| 10504 | }
|
| 10505 |
|
| 10506 | var s_alertData = sv_trafficStaticalInfo.data.alert;
|
| 10507 | s_alertData.value = s_total / 200;
|
| 10508 | s_alertData.name = $.i18n.prop("echarts_alert");
|
| 10509 | sv_trafficGraphOptions.series[0].data.push(s_alertData);
|
| 10510 |
|
| 10511 | if (s_alarm > 0) {
|
| 10512 | var s_alarmData = sv_trafficStaticalInfo.data.alarm;
|
| 10513 | s_alarmData.value = s_alarm;
|
| 10514 | s_alarmData.name = $.i18n.prop("echarts_alarm");
|
| 10515 | sv_trafficGraphOptions.series[0].data.push(s_alarmData);
|
| 10516 | }
|
| 10517 |
|
| 10518 | var s_freeData = sv_trafficStaticalInfo.data.free;
|
| 10519 | s_freeData.value = s_left;
|
| 10520 | s_freeData.name = $.i18n.prop("echarts_free");
|
| 10521 | sv_trafficGraphOptions.series[0].data.push(s_freeData);
|
| 10522 | }
|
| 10523 | }
|
| 10524 |
|
| 10525 | }else{// ʱ��
|
| 10526 |
|
| 10527 | sv_trafficGraphOptions.series[0].data = [];
|
| 10528 |
|
| 10529 | if (fwVm.limitTimeMonth() == 0) {
|
| 10530 | var s_usedData = sv_trafficStaticalInfo.data.used;
|
| 10531 | s_usedData.value = 1;
|
| 10532 | s_usedData.selected = false;
|
| 10533 | s_usedData.name = $.i18n.prop("echarts_used");
|
| 10534 | sv_trafficGraphOptions.series[0].data.push(s_usedData);
|
| 10535 | } else {
|
| 10536 | s_total = fwVm.limitTimeMonth() * fwVm.selectedTimeUnit();
|
| 10537 | s_used = sv_sourceData.monthlyConnectedTime;
|
| 10538 | s_reach = s_total * fwVm.alertTimeReach() / 100;
|
| 10539 |
|
| 10540 | if (s_used >= s_total) {
|
| 10541 | var fullTime = sv_trafficStaticalInfo.data.full;
|
| 10542 | fullTime.value = 100;
|
| 10543 | fullTime.name = $.i18n.prop("echarts_full");
|
| 10544 | sv_trafficGraphOptions.series[0].data.push(fullTime);
|
| 10545 | s_startName = $.i18n.prop("echarts_full");
|
| 10546 | } else {
|
| 10547 | if (s_reach - s_used > 0) {
|
| 10548 | s_left1 = s_reach - s_used;
|
| 10549 | s_left = s_total - s_reach;
|
| 10550 | } else {
|
| 10551 | s_alarm = s_used - s_reach;
|
| 10552 | s_left = s_total - s_used;
|
| 10553 | }
|
| 10554 |
|
| 10555 | var s_usedTime = sv_trafficStaticalInfo.data.used;
|
| 10556 | if (s_reach - s_used > 0) {
|
| 10557 | s_usedTime.value = s_used;
|
| 10558 | } else {
|
| 10559 | s_usedTime.value = s_reach;
|
| 10560 | }
|
| 10561 | s_usedTime.name = $.i18n.prop("echarts_used");
|
| 10562 | sv_trafficGraphOptions.series[0].data.push(s_usedTime);
|
| 10563 |
|
| 10564 | if (s_left1 > 0) {
|
| 10565 | var s_left1Time = sv_trafficStaticalInfo.data.left1;
|
| 10566 | s_left1Time.value = s_left1;
|
| 10567 | s_left1Time.name = $.i18n.prop("echarts_left1");
|
| 10568 | sv_trafficGraphOptions.series[0].data.push(s_left1Time);
|
| 10569 | }
|
| 10570 |
|
| 10571 | var s_alertTime = sv_trafficStaticalInfo.data.alert;
|
| 10572 | s_alertTime.value = s_total / 200;
|
| 10573 | s_alertTime.name = $.i18n.prop("echarts_alert");
|
| 10574 | sv_trafficGraphOptions.series[0].data.push(s_alertTime);
|
| 10575 |
|
| 10576 | if (s_alarm > 0) {
|
| 10577 | var s_alarmTime = sv_trafficStaticalInfo.data.alarm;
|
| 10578 | s_alarmTime.value = s_alarm;
|
| 10579 | s_alarmTime.name = $.i18n.prop("echarts_alarm");
|
| 10580 | sv_trafficGraphOptions.series[0].data.push(s_alarmTime);
|
| 10581 | }
|
| 10582 |
|
| 10583 | var s_freeTime = sv_trafficStaticalInfo.data.free;
|
| 10584 | s_freeTime.value = s_left;
|
| 10585 | s_freeTime.name = $.i18n.prop("echarts_free");
|
| 10586 | sv_trafficGraphOptions.series[0].data.push(s_freeTime);
|
| 10587 | }
|
| 10588 | }
|
| 10589 | }
|
| 10590 | } else {
|
| 10591 | var s_usedData = sv_trafficStaticalInfo.data.used;
|
| 10592 | s_usedData.value = 1;
|
| 10593 | s_usedData.selected = false;
|
| 10594 | s_usedData.name = $.i18n.prop("echarts_no");
|
| 10595 |
|
| 10596 | sv_trafficGraphOptions.series[0].data = [s_usedData];
|
| 10597 | sv_trafficGraphOptions.title.text = '';
|
| 10598 | }
|
| 10599 | sv_trafficStaticalInfo.setFlowDiagramInfo(sv_trafficGraphOptions, s_startName);
|
| 10600 | },
|
| 10601 |
|
| 10602 |
|
| 10603 | // �ػ�����ͼ
|
| 10604 | setFlowDiagramInfo: function (i_options, i_startName) {
|
| 10605 | var s_startPart = sv_trafficStaticalInfo.data.start;
|
| 10606 |
|
| 10607 | s_startPart.name = i_startName;
|
| 10608 | s_startPart.selected = false;
|
| 10609 | s_startPart.value = 0;
|
| 10610 |
|
| 10611 | var s_arr = [s_startPart].concat(i_options.series[0].data);
|
| 10612 | i_options.series[0].data = s_arr;
|
| 10613 | sv_trafficGraph.setOption(i_options, true);
|
| 10614 |
|
| 10615 | addTimeout(function () {
|
| 10616 | sv_trafficGraph.resize();
|
| 10617 | }, 1000);
|
| 10618 | }
|
| 10619 | };
|
| 10620 |
|
| 10621 |
|
| 10622 | // ����ͼ��������
|
| 10623 | var sv_trafficGraphOptions = {
|
| 10624 | animation: false,
|
| 10625 | color: ['red', 'red', 'red', 'red', 'red'],
|
| 10626 | series: [
|
| 10627 | {
|
| 10628 | name: '��������',
|
| 10629 | radius: ['0', '75'],
|
| 10630 | selectedOffset: 3,
|
| 10631 | type: 'pie',
|
| 10632 | data: [
|
| 10633 |
|
| 10634 | ],
|
| 10635 | itemStyle: {
|
| 10636 | normal: {
|
| 10637 | labelLine: {
|
| 10638 | show: false
|
| 10639 | },
|
| 10640 | label: {
|
| 10641 | show: false
|
| 10642 | }
|
| 10643 | }
|
| 10644 | }
|
| 10645 | }
|
| 10646 | ],
|
| 10647 | title: {
|
| 10648 | itemGap: 0,
|
| 10649 | text: '',
|
| 10650 | subtextStyle: {
|
| 10651 | color: '#FFF',
|
| 10652 | fontFamily: '΢���ź�',
|
| 10653 | fontSize: 16,
|
| 10654 | fontWeight: 'bolder'
|
| 10655 | },
|
| 10656 | textStyle: {
|
| 10657 | color: '#FFF',
|
| 10658 | fontFamily: '΢���ź�',
|
| 10659 | fontSize: 20,
|
| 10660 | fontWeight: 'bolder'
|
| 10661 | },
|
| 10662 | x: 'center',
|
| 10663 | y: 'center'
|
| 10664 | },
|
| 10665 | tooltip: {
|
| 10666 | formatter: "{b}"
|
| 10667 | }
|
| 10668 | };
|
| 10669 |
|
| 10670 |
|
| 10671 | // ��ȡ������������
|
| 10672 | function getTrafficAlertInfo() {
|
| 10673 | return service.getTrafficAlertInfo();
|
| 10674 | }
|
| 10675 |
|
| 10676 |
|
| 10677 |
|
| 10678 | // ��������ViewModel
|
| 10679 |
|
| 10680 | function trafficViewModel() {
|
| 10681 |
|
| 10682 | var target = this;
|
| 10683 |
|
| 10684 | var info = sv_trafficStaticalInfo.fetchTrafficAlertInfo();
|
| 10685 | var dataMonth = info.limitDataMonth.split("_");
|
| 10686 |
|
| 10687 | sv_usedDataModified = false;
|
| 10688 | sv_usedTimeModified = false;
|
| 10689 |
|
| 10690 | target.alertDataReach = ko.observable(info.alertDataReach || 0);
|
| 10691 | target.alertTimeReach = ko.observable(info.alertTimeReach || 0);
|
| 10692 | target.dataLimitChecked = ko.observable(info.dataLimitChecked == '0' ? '0' : '1');
|
| 10693 | target.dataLimitTypeChecked = ko.observable(info.dataLimitTypeChecked == '0' ? '0' : '1');
|
| 10694 | target.limitTimeMonth = ko.observable(info.limitTimeMonth || 0);
|
| 10695 |
|
| 10696 |
|
| 10697 | // ע��˳��
|
| 10698 | target.usedDataText = ko.observable(transUnit(parseInt(info.monthlySent, 10) + parseInt(info.monthlyReceived, 10), false));
|
| 10699 | var sv_staticalDataInfo = sv_trafficStaticalInfo.getTrafficStatisticalDatalnfo(target.usedDataText());
|
| 10700 | var sv_staticalInfoData = sv_staticalDataInfo.data;
|
| 10701 | target.dataUsed = ko.observable(sv_staticalInfoData);
|
| 10702 | var sv_staticalInfoUnit = sv_staticalDataInfo.unit;
|
| 10703 | target.selectedDataUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_staticalInfoUnit));
|
| 10704 | target.usedDataTextDescData = ko.observable("");
|
| 10705 |
|
| 10706 | target.limitDataMonth = ko.observable(dataMonth[0] || 0);
|
| 10707 | target.selectedDataUnit = ko.observable(dataMonth[1] || 1);
|
| 10708 |
|
| 10709 | var limitDataMonthTmp = transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1024 * 1024, false);
|
| 10710 | var limitDataMonthUnitTmp = limitDataMonthTmp.substring(limitDataMonthTmp.length-2);
|
| 10711 | target.limitDataMonth(limitDataMonthTmp.substring(0, limitDataMonthTmp.length-2));
|
| 10712 | target.selectedDataUnit(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(limitDataMonthUnitTmp));
|
| 10713 |
|
| 10714 | target.usedDataTextDesc = ko.computed(sf_usedDataTextDesc);
|
| 10715 | target.limitDataMonthDescData = ko.observable("");
|
| 10716 | target.limitDataMonthDesc = ko.computed(sf_limitDataMonthDesc);
|
| 10717 | target.alertDataReachDescData = ko.observable("");
|
| 10718 | target.alertDataReachDesc = ko.computed(sf_alertDataReachDesc);
|
| 10719 | target.leftDataDescData = ko.observable("");
|
| 10720 | target.leftDataDesc = ko.computed(sf_leftDataDesc);
|
| 10721 | target.monthlyConnectedTime = ko.observable(transSecond2Time(info.monthlyConnectedTime));
|
| 10722 |
|
| 10723 | var sv_timeInfo1 = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(info.monthlyConnectedTime));
|
| 10724 | target.usedTime = ko.observable(sv_timeInfo1.data);
|
| 10725 | target.selectedTimeUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfo1.unit));
|
| 10726 |
|
| 10727 | target.usedTimeTextDescData = ko.observable("");
|
| 10728 | target.usedTimeTextDesc = ko.computed(sf_usedTimeTextDesc);
|
| 10729 |
|
| 10730 | var sv_timeInfoNew = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(parseFloat(target.limitTimeMonth()) * 3600));
|
| 10731 | target.selectedTimeUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfoNew.unit));
|
| 10732 | target.limitTimeMonth(sv_timeInfoNew.data);
|
| 10733 |
|
| 10734 |
|
| 10735 | target.limitTimeMonthDescData = ko.observable("");
|
| 10736 | target.limitTimeMonthDescText = ko.observable("traffic_limit_time_h");
|
| 10737 | target.limitTimeMonthDesc = ko.computed(sf_limitTimeMonthDesc);
|
| 10738 | target.alertTimeReachDescData = ko.observable("");
|
| 10739 | target.alertTimeReachDesc = ko.computed(sf_alertTimeReachDesc);
|
| 10740 | target.leftTimeDescData = ko.observable("");
|
| 10741 | target.leftTimeDesc = ko.computed(sf_leftTimeDesc);
|
| 10742 | target.save = sf_save;
|
| 10743 | target.viewEditUsedData = ko.observable(false);
|
| 10744 | target.editUsedDataHandler = sf_editUsedDataHandler;
|
| 10745 | target.editUsedDataSaveHandler = sf_editUsedDataSaveHandler;
|
| 10746 | target.saveUsedData = sf_saveUsedData;
|
| 10747 | target.editUsedDataCancelHandler = sf_editUsedDataCancelHandler;
|
| 10748 | target.viewEditTotalData = ko.observable(false);
|
| 10749 | target.editTotalDataHandler = sf_editTotalDataHandler;
|
| 10750 | target.editTotalDataSaveHandler = sf_editTotalDataSaveHandler;
|
| 10751 | target.editTotalDataCancelHandler = sf_editTotalDataCancelHandler;
|
| 10752 | target.viewEditAlertData = ko.observable(false);
|
| 10753 | target.editAlertDataHandler = sf_editAlertDataHandler;
|
| 10754 | target.editAlertDataSaveHandler = sf_editAlertDataSaveHandler;
|
| 10755 | target.editAlertDataCancelHandler = sf_editAlertDataCancelHandler;
|
| 10756 | target.viewEditUsedTime = ko.observable(false);
|
| 10757 | target.editUsedTimeHandler = sf_editUsedTimeHandler;
|
| 10758 | target.saveUsedTime = sf_saveUsedTime;
|
| 10759 | target.editUsedTimeSaveHandler = sf_editUsedTimeSaveHandler;
|
| 10760 | target.editUsedTimeCancelHandler = sf_editUsedTimeCancelHandler;
|
| 10761 | target.viewEditTotalTime = ko.observable(false);
|
| 10762 | target.editTotalTimeHandler = sf_editTotalTimeHandler ;
|
| 10763 | target.editTotalTimeSaveHandler = sf_editTotalTimeSaveHandler;
|
| 10764 | target.editTotalTimeCancelHandler = sf_editTotalTimeCancelHandler;
|
| 10765 | target.viewEditAlertTime = ko.observable(false);
|
| 10766 | target.editAlertTimeHandler = sf_editAlertTimeHandler;
|
| 10767 | target.editAlertTimeSaveHandler = sf_editAlertTimeSaveHandler;
|
| 10768 | target.editAlertTimeCancelHandler = sf_editAlertTimeCancelHandler;
|
| 10769 | sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
|
| 10770 |
|
| 10771 |
|
| 10772 | // ��������������
|
| 10773 | function sf_alertDataReachDesc() {
|
| 10774 | if(isNaN(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach())) {
|
| 10775 | target.alertDataReachDescData(target.alertDataReach() + ', ');
|
| 10776 | return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), ' ');
|
| 10777 | }
|
| 10778 |
|
| 10779 | var s_value = transUnit(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach() * 1048576 / 100, false);
|
| 10780 | target.alertDataReachDescData(target.alertDataReach() + ',' + s_value);
|
| 10781 | return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), s_value);
|
| 10782 | }
|
| 10783 | // ʱ������������
|
| 10784 | function sf_alertTimeReachDesc() {
|
| 10785 | if(isNaN(target.limitTimeMonth() * target.alertTimeReach())) {
|
| 10786 | target.alertTimeReachDescData(target.alertTimeReach() + ', ');
|
| 10787 | return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), ' ');
|
| 10788 | }
|
| 10789 | var s_value = transSecond2Time(target.limitTimeMonth() * target.selectedTimeUnit() * target.alertTimeReach() / 100);
|
| 10790 | target.alertTimeReachDescData(target.alertTimeReach() + ',' + s_value);
|
| 10791 | return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), s_value);
|
| 10792 | }
|
| 10793 |
|
| 10794 |
|
| 10795 | // ��������ֵȡ���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10796 | function sf_editAlertDataCancelHandler() {
|
| 10797 | target.alertDataReach(sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue'));
|
| 10798 | target.viewEditAlertData(false);
|
| 10799 | }
|
| 10800 |
|
| 10801 | // ��������ֵ�à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10802 | function sf_editAlertDataHandler() {
|
| 10803 | sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue', target.alertDataReach());
|
| 10804 | target.viewEditAlertData(true);
|
| 10805 | }
|
| 10806 |
|
| 10807 | // ��������ֵ�����à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10808 | function sf_editAlertDataSaveHandler() {
|
| 10809 | if (sv_trafficStaticalInfo.getEle('alertDataReach').valid()) {
|
| 10810 | target.viewEditAlertData(false);
|
| 10811 | }
|
| 10812 | }
|
| 10813 |
|
| 10814 | // ʱ������ֵȡ���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10815 | function sf_editAlertTimeCancelHandler() {
|
| 10816 | target.alertTimeReach(sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue'));
|
| 10817 | target.viewEditAlertTime(false);
|
| 10818 | }
|
| 10819 | // ʱ������ֵ�à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10820 | function sf_editAlertTimeHandler() {
|
| 10821 | sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue', target.alertTimeReach());
|
| 10822 | target.viewEditAlertTime(true);
|
| 10823 | }
|
| 10824 | // ʱ������ֵ�����à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10825 | function sf_editAlertTimeSaveHandler() {
|
| 10826 | if (sv_trafficStaticalInfo.getEle('alertTimeReach').valid()) {
|
| 10827 | target.viewEditAlertTime(false);
|
| 10828 | }
|
| 10829 | }
|
| 10830 |
|
| 10831 | // �ײ������à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10832 | function sf_editTotalDataHandler() {
|
| 10833 | sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue', target.limitDataMonth());
|
| 10834 | sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue', target.selectedDataUnit());
|
| 10835 | target.viewEditTotalData(true);
|
| 10836 | }
|
| 10837 |
|
| 10838 | // �ײ����������à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10839 | function sf_editTotalDataSaveHandler() {
|
| 10840 | if (sv_trafficStaticalInfo.getEle('limitDataMonth').valid()) {
|
| 10841 | target.usedDataText(transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1048576, false));
|
| 10842 | target.viewEditTotalData(false);
|
| 10843 | }
|
| 10844 | }
|
| 10845 |
|
| 10846 | // �ײ�����ȡ���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10847 | function sf_editTotalDataCancelHandler() {
|
| 10848 | target.limitDataMonth(sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue'));
|
| 10849 | target.selectedDataUnit(sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue'));
|
| 10850 | target.viewEditTotalData(false);
|
| 10851 | }
|
| 10852 | // �ײ�ʱ��ȡ���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10853 | function sf_editTotalTimeCancelHandler() {
|
| 10854 | target.limitTimeMonth(sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue'));
|
| 10855 | target.viewEditTotalTime(false);
|
| 10856 | }
|
| 10857 | // �ײ�ʱ���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10858 | function sf_editTotalTimeHandler() {
|
| 10859 | sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue', target.limitTimeMonth());
|
| 10860 | target.viewEditTotalTime(true);
|
| 10861 | }
|
| 10862 | // �ײ�ʱ�䱣���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10863 | function sf_editTotalTimeSaveHandler() {
|
| 10864 | if (sv_trafficStaticalInfo.getEle('limitTimeMonth').valid()) {
|
| 10865 | target.viewEditTotalTime(false);
|
| 10866 | }
|
| 10867 | }
|
| 10868 |
|
| 10869 | // ��������ȡ���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10870 | function sf_editUsedDataCancelHandler() {
|
| 10871 | target.dataUsed(sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue'));
|
| 10872 | target.selectedDataUsedUnit(sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue'));
|
| 10873 | sv_trafficStaticalInfo.getEle('editUsedDataCancel').siblings('label.error').hide();
|
| 10874 | target.viewEditUsedData(false);
|
| 10875 | }
|
| 10876 | // ���������à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10877 | function sf_editUsedDataHandler() {
|
| 10878 | sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue', target.dataUsed());
|
| 10879 | sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue', target.selectedDataUsedUnit());
|
| 10880 | target.dataUsed(target.dataUsed());
|
| 10881 | target.viewEditUsedData(true);
|
| 10882 | }
|
| 10883 | // �����������水ť�¼�
|
| 10884 | function sf_editUsedDataSaveHandler() {
|
| 10885 | if (sv_trafficStaticalInfo.getEle('dataUsed').valid()) {
|
| 10886 | sv_usedDataModified = true;
|
| 10887 | target.viewEditUsedData(false);
|
| 10888 | }
|
| 10889 | }
|
| 10890 | // ����ʱ��ȡ���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10891 | function sf_editUsedTimeCancelHandler() {
|
| 10892 | target.usedTime(sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue'));
|
| 10893 | target.viewEditUsedTime(false);
|
| 10894 | }
|
| 10895 | // ����ʱ���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10896 | function sf_editUsedTimeHandler() {
|
| 10897 | sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue', target.usedTime());
|
| 10898 | target.viewEditUsedTime(true);
|
| 10899 | }
|
| 10900 |
|
| 10901 | // ����ʱ�䱣���à¼ï¿½ï¿½Å¥ï¿½Â¼ï¿½
|
| 10902 | function sf_editUsedTimeSaveHandler() {
|
| 10903 | if (sv_trafficStaticalInfo.getEle('usedTime').valid()) {
|
| 10904 | target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
|
| 10905 | target.viewEditUsedTime(false);
|
| 10906 | sv_usedTimeModified = true;
|
| 10907 | }
|
| 10908 | }
|
| 10909 |
|
| 10910 | // ʣ������������
|
| 10911 | function sf_leftDataDesc() {
|
| 10912 | var s_left = (target.limitDataMonth() * target.selectedDataUnit() - target.dataUsed() * target.selectedDataUsedUnit()) * 1048576;
|
| 10913 | if(s_left < 0) {
|
| 10914 | s_left = 0;
|
| 10915 | }
|
| 10916 |
|
| 10917 | if(isNaN(s_left)) {
|
| 10918 | target.leftDataDescData('');
|
| 10919 | return $.i18n.prop('traffic_data_left_text', ' ');
|
| 10920 | }
|
| 10921 |
|
| 10922 | target.leftDataDescData(transUnit(s_left, false));
|
| 10923 | return $.i18n.prop('traffic_data_left_text', transUnit(s_left, false));
|
| 10924 | }
|
| 10925 | //ʣ��ʱ��������
|
| 10926 | function sf_leftTimeDesc() {
|
| 10927 | var s_surplus = target.limitTimeMonth() * target.selectedTimeUnit() - sv_trafficStaticalInfo.getTrafficTimeToSeconds(target.monthlyConnectedTime());
|
| 10928 | if(s_surplus < 0) {
|
| 10929 | s_surplus = 0;
|
| 10930 | }
|
| 10931 |
|
| 10932 | if(isNaN(s_surplus)) {
|
| 10933 | target.leftTimeDescData(' ');
|
| 10934 | return $.i18n.prop('traffic_data_left_text', ' ');
|
| 10935 | }
|
| 10936 | target.leftTimeDescData(transSecond2Time(s_surplus));
|
| 10937 | return $.i18n.prop('traffic_data_left_text', transSecond2Time(s_surplus));
|
| 10938 | }
|
| 10939 | // �ײ�����������
|
| 10940 | function sf_limitDataMonthDesc() {
|
| 10941 | if(isNaN(target.limitDataMonth())) {
|
| 10942 | target.limitDataMonthDescData("");
|
| 10943 | return $.i18n.prop('traffic_limit_data_text', ' ');
|
| 10944 | }else{
|
| 10945 | // todo
|
| 10946 | }
|
| 10947 |
|
| 10948 | target.limitDataMonthDescData(target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
|
| 10949 | return $.i18n.prop('traffic_limit_data_text', target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
|
| 10950 | }
|
| 10951 | // �ײ�ʱ��������
|
| 10952 | function sf_limitTimeMonthDesc() {
|
| 10953 | if(isNaN(target.limitTimeMonth())) {
|
| 10954 | target.limitTimeMonthDescData(' ');
|
| 10955 | target.limitTimeMonthDescText('traffic_limit_time_h');
|
| 10956 | return $.i18n.prop('traffic_limit_time_h', ' ');
|
| 10957 | }else{
|
| 10958 | // todo:
|
| 10959 | }
|
| 10960 |
|
| 10961 | target.limitTimeMonthDescData(target.limitTimeMonth());
|
| 10962 |
|
| 10963 | if(target.selectedTimeUnit() == "60"){
|
| 10964 | target.limitTimeMonthDescText('traffic_limit_time_m');
|
| 10965 | return $.i18n.prop('traffic_limit_time_m', target.limitTimeMonth());
|
| 10966 | }else{
|
| 10967 | target.limitTimeMonthDescText('traffic_limit_time_h');
|
| 10968 | return $.i18n.prop('traffic_limit_time_h', target.limitTimeMonth());
|
| 10969 | }
|
| 10970 | }
|
| 10971 |
|
| 10972 | // Ӧ�ð�ť�¼�
|
| 10973 | function sf_save() {
|
| 10974 | if (sv_trafficStaticalInfo.isFormEditable(target) && target.dataLimitChecked() == '1') {
|
| 10975 | return false;
|
| 10976 | }
|
| 10977 |
|
| 10978 | if (target.selectedDataUnit() == '1' && target.selectedDataUsedUnit() == '1048576' && target.dataLimitTypeChecked() == "1" && target.dataLimitChecked() == '1' && !(parseInt(target.dataUsed(), 10) < parseInt('4096', 10)) ) {
|
| 10979 | showAlert('traffic_over_note');
|
| 10980 | return false;
|
| 10981 | }
|
| 10982 |
|
| 10983 | showLoading();
|
| 10984 | service.setTrafficAlertInfo({
|
| 10985 | alertDataReach: parseInt(target.alertDataReach(), 10),
|
| 10986 | alertTimeReach: parseInt(target.alertTimeReach(), 10),
|
| 10987 | dataLimitChecked: target.dataLimitChecked(),
|
| 10988 | dataLimitTypeChecked: target.dataLimitTypeChecked(),
|
| 10989 | limitDataMonth: target.limitDataMonth() + "_" + target.selectedDataUnit(),
|
| 10990 | limitTimeMonth: target.selectedTimeUnit() == "60" ? target.limitTimeMonth()/60 : target.limitTimeMonth()//save by hours
|
| 10991 | }, function (data) {
|
| 10992 | if (data.result == 'success') {
|
| 10993 | if(target.dataLimitTypeChecked() == "1" && sv_usedDataModified) {
|
| 10994 | target.saveUsedData();
|
| 10995 | } else if(target.dataLimitTypeChecked() == "0" && sv_usedTimeModified) {
|
| 10996 | target.saveUsedTime();
|
| 10997 | } else {
|
| 10998 | sv_trafficStaticalInfo.fetchTrafficAlertInfo();
|
| 10999 | sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
|
| 11000 | status.setTrafficAlertPopuped(false);
|
| 11001 | successOverlay();
|
| 11002 | }
|
| 11003 | } else {
|
| 11004 | errorOverlay();
|
| 11005 | }
|
| 11006 | }, function () {
|
| 11007 | sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
|
| 11008 | errorOverlay();
|
| 11009 | });
|
| 11010 | }
|
| 11011 |
|
| 11012 | // ����������������
|
| 11013 | function sf_saveUsedData() {
|
| 11014 | var val = target.dataUsed() * target.selectedDataUsedUnit();
|
| 11015 | service.trafficCalibration({
|
| 11016 | way: 'data',
|
| 11017 | value: val
|
| 11018 | }, function(){
|
| 11019 | sv_trafficStaticalInfo.fetchTrafficAlertInfo();
|
| 11020 | sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
|
| 11021 | successOverlay();
|
| 11022 | target.viewEditUsedData(false);
|
| 11023 | status.setTrafficAlertPopuped(false);
|
| 11024 | sv_usedDataModified = false;
|
| 11025 | }, function(){
|
| 11026 | sv_trafficStaticalInfo.fetchTrafficAlertInfo();
|
| 11027 | sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
|
| 11028 | errorOverlay();
|
| 11029 | });
|
| 11030 | }
|
| 11031 |
|
| 11032 |
|
| 11033 |
|
| 11034 | function sf_saveUsedTime() {
|
| 11035 | service.trafficCalibration({
|
| 11036 | way: 'time',
|
| 11037 | value: target.selectedTimeUsedUnit() == "60" ? parseFloat(target.usedTime())/60 : target.usedTime()
|
| 11038 | }, function(){
|
| 11039 | sv_trafficStaticalInfo.fetchTrafficAlertInfo();
|
| 11040 | sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
|
| 11041 | successOverlay();
|
| 11042 | target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
|
| 11043 | target.viewEditUsedTime(false);
|
| 11044 | status.setTrafficAlertPopuped(false);
|
| 11045 | sv_usedTimeModified = false;
|
| 11046 | }, function(){
|
| 11047 | sv_trafficStaticalInfo.fetchTrafficAlertInfo();
|
| 11048 | sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
|
| 11049 | errorOverlay();
|
| 11050 | });
|
| 11051 | }
|
| 11052 |
|
| 11053 |
|
| 11054 | // ��������������
|
| 11055 | function sf_usedDataTextDesc() {
|
| 11056 | if(isNaN(target.dataUsed())) {
|
| 11057 | target.usedDataTextDescData("");
|
| 11058 | return $.i18n.prop('traffic_used_text', ' ');
|
| 11059 | }
|
| 11060 | target.usedDataTextDescData(target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
|
| 11061 | return $.i18n.prop('traffic_used_text', target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
|
| 11062 | }
|
| 11063 | // ����ʱ��������
|
| 11064 | function sf_usedTimeTextDesc() {
|
| 11065 | target.usedTimeTextDescData(target.monthlyConnectedTime());
|
| 11066 | return $.i18n.prop('traffic_used_text', target.monthlyConnectedTime());
|
| 11067 | }
|
| 11068 |
|
| 11069 |
|
| 11070 | }
|
| 11071 |
|
| 11072 | function init() {
|
| 11073 | sv_trafficGraph = echarts.init($("#traffic_graphic")[0]);
|
| 11074 | window.onresize = sv_trafficGraph.resize;
|
| 11075 | var s_container = $('#container');
|
| 11076 | ko.cleanNode(s_container[0]);
|
| 11077 | var fwVm = new trafficViewModel();
|
| 11078 | ko.applyBindings(fwVm, s_container[0]);
|
| 11079 | $('#trafficAlertForm').validate({
|
| 11080 | submitHandler: function () {
|
| 11081 | fwVm.save();
|
| 11082 | },
|
| 11083 |
|
| 11084 |
|
| 11085 | errorPlacement: function (error, para) {
|
| 11086 | if (para.attr("name") == "alertDataReach") {
|
| 11087 | error.insertAfter("#editAlertDataDiv");
|
| 11088 | } else if (para.attr("name") == "alertTimeReach") {
|
| 11089 | error.insertAfter("#editAlertTimeDiv");
|
| 11090 | } else if (para.attr("name") == "dataUsed") {
|
| 11091 | error.insertAfter("#editUsedDataDiv");
|
| 11092 | } else if (para.attr("name") == "limitDataMonth") {
|
| 11093 | error.insertAfter("#editTotalDataDiv");
|
| 11094 | } else if (para.attr("name") == "limitTimeMonth") {
|
| 11095 | error.insertAfter("#editTotalTimeDiv");
|
| 11096 | } else if (para.attr("name") == "usedTime") {
|
| 11097 | error.insertAfter("#editUsedTimeDiv");
|
| 11098 | } else {
|
| 11099 | error.insertAfter(para);
|
| 11100 | }
|
| 11101 | },
|
| 11102 |
|
| 11103 | rules: {
|
| 11104 | alertDataReach: {
|
| 11105 | range: [ 1, 100 ],
|
| 11106 | digits: true
|
| 11107 | },
|
| 11108 | alertTimeReach: {
|
| 11109 | range: [ 1, 100 ],
|
| 11110 | digits: true
|
| 11111 | },
|
| 11112 | dataUsed: {
|
| 11113 | range : [ 0, 9999 ],
|
| 11114 | decimalRange : true
|
| 11115 | },
|
| 11116 | limitDataMonth: {
|
| 11117 | range : [ 1, 9999 ],
|
| 11118 | decimalRange : true
|
| 11119 | },
|
| 11120 | limitTimeMonth: {
|
| 11121 | range : [ 1, 9999 ],
|
| 11122 | decimalRange : true
|
| 11123 | },
|
| 11124 | usedTime: {
|
| 11125 | range : [ 0, 9999 ],
|
| 11126 | decimalRange : true
|
| 11127 | }
|
| 11128 | }
|
| 11129 |
|
| 11130 | });
|
| 11131 |
|
| 11132 | var sv_originalLan = window.language;
|
| 11133 | window.setInterval(function(){
|
| 11134 | if(sv_originalLan != window.language){
|
| 11135 | sv_originalLan = window.language;
|
| 11136 | sv_trafficStaticalInfo.refreshFlowDiagramInfo(fwVm);
|
| 11137 | }
|
| 11138 | }, 1000);
|
| 11139 |
|
| 11140 | }
|
| 11141 |
|
| 11142 | return {
|
| 11143 | init: init
|
| 11144 | };
|
| 11145 | });
|
| 11146 |
|
| 11147 | // ״̬����ʾ��ʵ��
|
| 11148 | define("tooltip",[ "jquery" ],
|
| 11149 |
|
| 11150 | function($) {
|
| 11151 |
|
| 11152 |
|
| 11153 | // ����Ԫ��λ����Ϣ
|
| 11154 | // @method calculatePositionInfo
|
| 11155 | // @param trigger Ԫ��
|
| 11156 | // @param tooltip ״̬��
|
| 11157 | // @param {JSON} config �����
|
| 11158 |
|
| 11159 | function calculatePositionInfo(trigger, tooltip, config) {
|
| 11160 | var top = trigger.offset().top;
|
| 11161 | var left = trigger.offset().left;
|
| 11162 | var position = config.position[0];
|
| 11163 | var height = tooltip.outerHeight() + trigger.outerHeight();
|
| 11164 | var width = tooltip.outerWidth() + trigger.outerWidth();
|
| 11165 |
|
| 11166 | top -= tooltip.outerHeight() - config.offset[0];
|
| 11167 | left += trigger.outerWidth() + config.offset[1];
|
| 11168 |
|
| 11169 | if (/iPad/i.test(navigator.userAgent)) {
|
| 11170 | top -= $(window).scrollTop();
|
| 11171 | }
|
| 11172 |
|
| 11173 | if (position == 'center') {
|
| 11174 | top += height / 2;
|
| 11175 | }
|
| 11176 | if (position == 'bottom') {
|
| 11177 | top += height;
|
| 11178 | }
|
| 11179 | position = config.position[1];
|
| 11180 | if (position == 'center') {
|
| 11181 | left -= width / 2;
|
| 11182 | }else if (position == 'left') {
|
| 11183 | left -= width;
|
| 11184 | }
|
| 11185 |
|
| 11186 | return {
|
| 11187 | top : top,
|
| 11188 | left : left
|
| 11189 | };
|
| 11190 | }
|
| 11191 |
|
| 11192 | // ״̬����ʼ��
|
| 11193 | function init() {
|
| 11194 |
|
| 11195 | $(".statusItem", "#statusBar").each(function(i, n){
|
| 11196 | var $this = $(this);
|
| 11197 | $this.attr("tipTitle", $this.attr("title")).removeAttr("title");
|
| 11198 | }).hover(
|
| 11199 | function() {
|
| 11200 | var $this = $(this);
|
| 11201 | var title = $this.attr("tipTitle");
|
| 11202 | var tooltip = $("<div>").addClass("tooltip in").appendTo(document.body).hide()
|
| 11203 | .append($this.attr("i18n") ? $.i18n.prop(title) : title);
|
| 11204 | if ($this.attr("i18n")) {
|
| 11205 | tooltip.attr("data-trans", title).attr("id", "tooltip_" + $this.attr("id"));
|
| 11206 | }
|
| 11207 | var pos = calculatePositionInfo($this, tooltip, {
|
| 11208 | position : [ 'bottom', 'center' ],
|
| 11209 | offset : [ 0, 0 ]
|
| 11210 | });
|
| 11211 | tooltip.css({
|
| 11212 | position : 'absolute',
|
| 11213 | top : pos.top,
|
| 11214 | left : pos.left
|
| 11215 | }).show();
|
| 11216 | }, function() {
|
| 11217 | $(".tooltip").hide().remove();
|
| 11218 | });
|
| 11219 | }
|
| 11220 |
|
| 11221 | return {
|
| 11222 | init : init
|
| 11223 | };
|
| 11224 | });
|
| 11225 |
|
| 11226 | define("menu","set service knockout underscore jquery".split(" "),
|
| 11227 | function (set, fnc, libko, libus, libjq) {
|
| 11228 | var displayMenuWhenLogout = false;
|
| 11229 | var vmMenu;
|
| 11230 | var menu = [];
|
| 11231 | var menuResource = "";
|
| 11232 |
|
| 11233 | function menuExistCheck(path) {
|
| 11234 | for (var i = 0; i < menu.length; i++) {
|
| 11235 | if (menu[i].path == path) {
|
| 11236 | return true;
|
| 11237 | }
|
| 11238 | }
|
| 11239 | return false;
|
| 11240 | }
|
| 11241 |
|
| 11242 | function getIsLoggedin() {
|
| 11243 | var loginStatus = fnc.getLoginStatus();
|
| 11244 | return (loginStatus.status == "loggedIn");
|
| 11245 | }
|
| 11246 |
|
| 11247 | function buildNew() {
|
| 11248 | var loggedIn = getIsLoggedin();
|
| 11249 | var menuMain = libus.filter(menu, function (param) {
|
| 11250 | return (param.level == '1' && ((param.requireLogin && loggedIn) || !param.requireLogin) && param.hash != "#entry");
|
| 11251 | });
|
| 11252 | vmMenu.menuMain(menuMain);
|
| 11253 | vmMenu.loggedIn(loggedIn);
|
| 11254 |
|
| 11255 | getMainWth(vmMenu.menuMain().length);
|
| 11256 | vmMenu.showMenu(loggedIn || displayMenuWhenLogout);
|
| 11257 | libjq("#nav").translate();
|
| 11258 | }
|
| 11259 |
|
| 11260 | function getMainWth(len) {
|
| 11261 | var width = 100 / len;
|
| 11262 | libjq('ul#list-nav li').each(function () {
|
| 11263 | libjq(this).css('width', width + '%');
|
| 11264 | });
|
| 11265 | }
|
| 11266 |
|
| 11267 | function menuRefresh() {
|
| 11268 | var currentHash = window.location.hash;
|
| 11269 | var itmRoot = libus.find(menu, function (param) {
|
| 11270 | return param.hash == currentHash;
|
| 11271 | });
|
| 11272 | while (itmRoot.parent) {
|
| 11273 | itmRoot = libus.find(menu, function (param) {
|
| 11274 | return param.hash == itmRoot.parent;
|
| 11275 | });
|
| 11276 | }
|
| 11277 | if (!itmRoot.parent) {
|
| 11278 | libjq("#list-nav li").removeClass("active");
|
| 11279 | var mid = itmRoot.hash.substring(1, itmRoot.hash.length);
|
| 11280 | libjq("#list-nav li[mid=" + mid + "]").addClass("active");
|
| 11281 | }
|
| 11282 | vmMenu.changeMenu(itmRoot);
|
| 11283 | }
|
| 11284 |
|
| 11285 | function menuSearch(hashVal) {
|
| 11286 | hashVal = hashVal || window.location.hash;
|
| 11287 | var loggedIn = getIsLoggedin();
|
| 11288 | return libus.filter(menu, function (param) {
|
| 11289 | return (hashVal == param.hash && ((param.requireLogin && loggedIn) || !param.requireLogin));
|
| 11290 | });
|
| 11291 | }
|
| 11292 |
|
| 11293 | function menuRenderSub(level, baseItem) {
|
| 11294 | var levelItem = libus.find(menu, function (param) {
|
| 11295 | return param.parent == baseItem.hash && param.path == baseItem.path;
|
| 11296 | });
|
| 11297 | libjq(".menu-" + level + "-level").removeClass("active");
|
| 11298 | if (levelItem) {
|
| 11299 | if (level == "two") {
|
| 11300 | menuRenderSub("three", levelItem);
|
| 11301 | //forward/backward support
|
| 11302 | clickMenuTrig(levelItem.hash, level);
|
| 11303 | }
|
| 11304 | libjq(".menu-" + level + "-level." + levelItem.hash.substring(1)).addClass("active");
|
| 11305 | }
|
| 11306 | }
|
| 11307 |
|
| 11308 | function menuActSub() {
|
| 11309 | var currentHash = window.location.hash;
|
| 11310 | var itmRoot = libus.find(menu, function (param) {
|
| 11311 | return param.hash == currentHash;
|
| 11312 | });
|
| 11313 | if (itmRoot.level == 1) {
|
| 11314 | menuRenderSub("two", itmRoot);
|
| 11315 | }
|
| 11316 | if (itmRoot.level == 2) {
|
| 11317 | menuRenderSub("three", itmRoot);
|
| 11318 | //forward/backward support
|
| 11319 | clickMenuTrig(itmRoot.hash, itmRoot.level);
|
| 11320 | }
|
| 11321 | if (itmRoot.level == 3) {
|
| 11322 | //forward/backward support
|
| 11323 | clickMenuTrig(itmRoot.parent, itmRoot.level);
|
| 11324 | libjq(".menu-three-level").removeClass("active");
|
| 11325 | libjq(".menu-three-level." + itmRoot.hash.substring(1)).addClass("active");
|
| 11326 | }
|
| 11327 | }
|
| 11328 |
|
| 11329 | function clickMenuTrig(hash, level) {
|
| 11330 | libjqobj = libjq(".menu-two-level." + hash.substring(1));
|
| 11331 | var levelArr = ['3', 'three', '2', 'two'];
|
| 11332 | if (libus.indexOf(levelArr, level) != -1 && libjqobj.hasClass('active')) {
|
| 11333 | return;
|
| 11334 | }
|
| 11335 |
|
| 11336 | libjqobj.siblings().removeClass('active');
|
| 11337 | libjqobj.addClass('active');
|
| 11338 |
|
| 11339 | libjqobj.siblings().not('.menu-two-level').slideUp();
|
| 11340 | libjqobj.next().has('ul li').slideDown();
|
| 11341 | }
|
| 11342 |
|
| 11343 | set.blc_wan_mode = fnc.getOpMode().blc_wan_mode;
|
| 11344 | if (!set.RJ45_SUPPORT) {
|
| 11345 | menuResource = "menu";
|
| 11346 | } else {
|
| 11347 | switch (set.blc_wan_mode) {
|
| 11348 | case "PPPOE":
|
| 11349 | case "AUTO_PPPOE":
|
| 11350 | menuResource = "menu_pppoe";
|
| 11351 | break;
|
| 11352 | default:
|
| 11353 | menuResource = "menu";
|
| 11354 | break;
|
| 11355 | }
|
| 11356 | }
|
| 11357 |
|
| 11358 | require([set.DEVICE + '/' + menuResource], function (otherMenu) {
|
| 11359 | menu = otherMenu;
|
| 11360 | if (set.SD_CARD_SUPPORT) {
|
| 11361 | menu = menu.concat([{ hash: '#httpshare_guest', path: 'sd_httpshare', level: '', requireLogin: false, checkSIMStatus: false},
|
| 11362 | { hash: '#sdcard', path: 'sd', level: '', requireLogin: true, checkSIMStatus: false},
|
| 11363 | { hash: '#httpshare', path: 'sd_httpshare', level: '', requireLogin: true, checkSIMStatus: false}]);
|
| 11364 | }
|
| 11365 | });
|
| 11366 |
|
| 11367 | function initialize() {
|
| 11368 | vmMenu = new Menu_vm();
|
| 11369 | }
|
| 11370 |
|
| 11371 | function Menu_vm() {
|
| 11372 | var loginState = getIsLoggedin();
|
| 11373 | var target = this;
|
| 11374 | target.loggedIn = libko.observable(loginState);
|
| 11375 |
|
| 11376 | target.showMenu = libko.observable(loginState || displayMenuWhenLogout);
|
| 11377 |
|
| 11378 | var menuMain = libus.filter(menu, function (param) {
|
| 11379 | return (param.level == '1' && ((param.requireLogin && target.loggedIn()) || !param.requireLogin) && param.hash != "#entry");
|
| 11380 | });
|
| 11381 |
|
| 11382 | target.menuMain = libko.observableArray(menuMain);
|
| 11383 | target.secondMenu = libko.observableArray([]);
|
| 11384 | //target.curThirdMenu; cov_2
|
| 11385 | target.changeMenu = function (data) {
|
| 11386 | var secondMenu = getSubMenu(data);
|
| 11387 | if (secondMenu.length == 0) {
|
| 11388 | libjq("#container").addClass("fixContainerWidth");
|
| 11389 | } else {
|
| 11390 | libjq("#container").removeClass("fixContainerWidth");
|
| 11391 | }
|
| 11392 |
|
| 11393 | target.secondMenu(secondMenu);
|
| 11394 | return true;
|
| 11395 | };
|
| 11396 | target.thirdMenu = function () {
|
| 11397 | return target.curThirdMenu;
|
| 11398 | };
|
| 11399 | target.getThirdMenu = function (data) {
|
| 11400 | target.curThirdMenu = getSubMenu(data);
|
| 11401 | };
|
| 11402 | function getSubMenu(data) {
|
| 11403 | return libus.filter(menu, function (param) {
|
| 11404 | return ((param.parent && param.parent == data.hash) && ((param.requireLogin && target.loggedIn()) || !param.requireLogin));
|
| 11405 | });
|
| 11406 | }
|
| 11407 | }
|
| 11408 |
|
| 11409 | return {
|
| 11410 | activeSubMenu: menuActSub,
|
| 11411 | checkIsMenuExist: menuExistCheck,
|
| 11412 | findMenu: menuSearch,
|
| 11413 | rebuild: buildNew,
|
| 11414 | refreshMenu: menuRefresh,
|
| 11415 | init: initialize
|
| 11416 | };
|
| 11417 | });
|