blob: f5e8bdb809d48d4d7525e9482b6bb173abc91b71 [file] [log] [blame]
qumengjia1cd76022024-10-31 17:51:04 +08001
2define("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",
94 password: config.PASSWORD_ENCODE ? Base64.encode(values.password) : values.password
95 };
96 return obj;
97 }
98 function deal(paramD) {
99 if (paramD && (paramD.result == "0" || paramD.result == "4")) {
100 informationAll.isLoggedIn = true;
101 return {
102 result: true
103 };
104 } else {
105 var loginError = {};
106 switch (paramD.result) {
107 case "1":
108 loginError = {
109 errorType: "Login Fail"
110 };
111 break;
112 case "2":
113 loginError = {
114 errorType: "duplicateUser"
115 };
116 break;
117 case "3":
118 loginError = {
119 errorType: "badPassword"
120 };
121 break;
122 default:
123 loginError = {
124 errorType: "Login Fail"
125 };
126 break;
127 }
128 informationAll.isLoggedIn = false;
129 return $.extend(errUnknownObj, loginError);
130 }
131 }
132 }
133 function getLoginStatus() {
134 if (informationAll.isLoggedIn != undefined) {
135 return stuffMake(arguments, {
136 status: informationAll.isLoggedIn ? 'loggedIn' : 'loggedOut'
137 });
138 } else {
139 var resultObject = {};
140 if (!config.HAS_LOGIN) {
141 resultObject.status = 'loggedIn';
142 resultObject.errorType = 'no_login';
143 informationAll.isLoggedIn = true;
144 }
145 return stuffMake(arguments, resultObject, prepare, deal, null, false);
146 }
147 function prepare(values, isPost) {
148 var valueReq = {};
149 valueReq.cmd = "loginfo";
150 valueReq.multi_data = 1;
151 return valueReq;
152 }
153 function deal(paramD) {
154 if (paramD && paramD.loginfo || paramD.loginfo == "") {
155 var loginStatus = {};
156 switch (paramD.loginfo) {
157 case "ok":
158 informationAll.isLoggedIn = true;
159 loginStatus.status = "loggedIn";
160 break;
161 default:
162 informationAll.isLoggedIn = false;
163 loginStatus.status = "loggedOut";
164 break;
165 }
166 return loginStatus;
167 } else {
168 informationAll.isLoggedIn = undefined;
169 return $.extend(errUnknownObj, {
170 errorType: "LoginStatusError"
171 });
172 }
173 }
174 }
175 function enterPIN() {
176 return stuffMake(arguments, {}, prepare, deal, {}, true);
177 function prepare(values, isPost) {
178 var obj = {};
179 obj.goformId = "ENTER_PIN";
180 obj.PinNumber = values.PinNumber;
181 return obj;
182 }
183 function deal(paramD) {
184 if (paramD && paramD.result === "success") {
185 return {
186 result: true
187 };
188 } else {
189 return {
190 result: false
191 };
192 }
193 }
194 }
195 function enterPUK() {
196 return stuffMake(arguments, {}, prepare, deal, {}, true);
197 function prepare(values, isPost) {
198 var obj = {};
199 obj.goformId = "ENTER_PUK";
200 obj.PUKNumber = values.PUKNumber;
201 obj.PinNumber = values.PinNumber;
202 return obj;
203 }
204 function deal(paramD) {
205 if (paramD && paramD.result === "success") {
206 return {
207 result: true
208 };
209 } else {
210 return {
211 result: false
212 };
213 }
214 }
215 }
216
217 function getStatusInfo() {
218 if (informationAll.isLoggedIn === undefined) {
219 var loginStatus = getLoginStatus();
220 return {
221 networkType: informationAll.networkType,
222 signalImg: informationAll.signalImg,
223 networkOperator: informationAll.networkOperator,
224 spn_b1_flag: informationAll.spn_b1_flag,
225 spn_name_data: informationAll.spn_name_data,
226 spn_b2_flag: informationAll.spn_b2_flag,
227 connectStatus: informationAll.connectStatus,
228 rj45ConnectStatus: informationAll.rj45ConnectStatus,
229 ssid1AttachedNum: informationAll.ssid1AttachedNum,
230 ssid2AttachedNum: informationAll.ssid2AttachedNum,
231 wirelessDeviceNum: informationAll.ssid1AttachedNum + informationAll.ssid2AttachedNum,
232 roamingStatus: informationAll.roamingStatus,
233 wifiStatus: informationAll.wifiStatus,
234 simStatus: informationAll.simStatus,
235 pinStatus: informationAll.pinStatus,
236 batteryStatus: informationAll.batteryStatus,
237 batteryLevel: informationAll.batteryLevel,
238 batteryPers: informationAll.batteryPers,
239 batteryTime: informationAll.batteryTime,
240 ssid: informationAll.ssid,
241 authMode: informationAll.authMode,
242 data_counter: informationAll.data_counter,
243 isLoggedIn: loginStatus.status == "loggedIn",
244 newSmsReceived: informationAll.newSmsReceived,
245 smsReportReceived: informationAll.smsReportReceived,
246 smsUnreadCount: informationAll.smsUnreadCount,
247 limitVolumeEnable: informationAll.limitVolumeEnable,
248 limitVolumeType: informationAll.limitVolumeType,
249 limitVolumePercent: informationAll.limitVolumePercent,
250 limitVolumeSize: informationAll.limitVolumeSize,
251 connectWifiProfile: informationAll.connectWifiProfile,
252 connectWifiSSID: informationAll.connectWifiSSID,
253 connectWifiStatus: informationAll.connectWifiStatus,
254 multi_ssid_enable: informationAll.multi_ssid_enable,
255 roamMode: informationAll.roamMode,
256 blc_wan_mode: informationAll.blc_wan_mode,
257 current_upgrade_state: informationAll.current_upgrade_state,
258 is_mandatory: informationAll.is_mandatory,
259 new_version_state: informationAll.new_version_state,
260 allowRoamingUpdate: informationAll.allowRoamingUpdate,
261 ap_station_enable: informationAll.ap_station_enable,
262 ap_station_mode: informationAll.ap_station_mode,
263 dialMode: informationAll.dialMode,
264 fota_package_already_download: informationAll.fota_package_already_download,
265 ethWanMode: informationAll.ethWanMode,
266 fota_user_selector: informationAll.fota_user_selector,
267 defaultWanName: informationAll.defaultWanName
268 };
269 }
270 return {
271 networkType: informationAll.networkType,
272 signalImg: informationAll.signalImg,
273 networkOperator: informationAll.networkOperator,
274 spn_b1_flag: informationAll.spn_b1_flag,
275 spn_name_data: informationAll.spn_name_data,
276 spn_b2_flag: informationAll.spn_b2_flag,
277 connectStatus: informationAll.connectStatus,
278 rj45ConnectStatus: informationAll.rj45ConnectStatus,
279 ssid1AttachedNum: informationAll.ssid1AttachedNum,
280 ssid2AttachedNum: informationAll.ssid2AttachedNum,
281 wirelessDeviceNum: informationAll.ssid1AttachedNum + informationAll.ssid2AttachedNum,
282 roamingStatus: informationAll.roamingStatus,
283 wifiStatus: informationAll.wifiStatus,
284 simStatus: informationAll.simStatus,
285 pinStatus: informationAll.pinStatus,
286 batteryStatus: informationAll.batteryStatus,
287 batteryLevel: informationAll.batteryLevel,
288 batteryPers: informationAll.batteryPers,
289 batteryTime: informationAll.batteryTime,
290 ssid: informationAll.ssid,
291 authMode: informationAll.authMode,
292 data_counter: informationAll.data_counter,
293 isLoggedIn: informationAll.isLoggedIn,
294 newSmsReceived: informationAll.newSmsReceived,
295 smsReportReceived: informationAll.smsReportReceived,
296 smsUnreadCount: informationAll.smsUnreadCount,
297 limitVolumeEnable: informationAll.limitVolumeEnable,
298 limitVolumeType: informationAll.limitVolumeType,
299 limitVolumePercent: informationAll.limitVolumePercent,
300 limitVolumeSize: informationAll.limitVolumeSize,
301 connectWifiProfile: informationAll.connectWifiProfile,
302 connectWifiSSID: informationAll.connectWifiSSID,
303 connectWifiStatus: informationAll.connectWifiStatus,
304 multi_ssid_enable: informationAll.multi_ssid_enable,
305 blc_wan_mode: informationAll.blc_wan_mode,
306 roamMode: informationAll.roamMode,
307 current_upgrade_state: informationAll.current_upgrade_state,
308 is_mandatory: informationAll.is_mandatory,
309 new_version_state: informationAll.new_version_state,
310 allowRoamingUpdate: informationAll.allowRoamingUpdate,
311 ap_station_enable: informationAll.ap_station_enable,
312 ap_station_mode: informationAll.ap_station_mode,
313 dialMode: informationAll.dialMode,
314 fota_package_already_download: informationAll.fota_package_already_download,
315 ethWanMode: informationAll.ethWanMode,
316 fota_user_selector: informationAll.fota_user_selector,
317 defaultWanName: informationAll.defaultWanName
318 };
319 }
320 function getConnectionInfo() {
321 var isData = informationAll.limitVolumeType == '1';
322 var result = {
323 data_counter: informationAll.data_counter,
324 connectStatus: informationAll.connectStatus,
325 rj45ConnectStatus: informationAll.rj45ConnectStatus,
326 limitVolumeEnable: informationAll.limitVolumeEnable,
327 limitVolumeType: informationAll.limitVolumeType,
328 limitVolumePercent: informationAll.limitVolumePercent,
329 networkType: informationAll.networkType
330 };
331 if (isData) {
332 result.limitDataMonth = informationAll.limitVolumeSize;
333 result.limitTimeMonth = 0;
334 } else {
335 result.limitTimeMonth = informationAll.limitVolumeSize;
336 result.limitDataMonth = 0;
337 }
338 result.blc_wan_mode = informationAll.blc_wan_mode;
339 return result;
340 }
341 function resetNewSmsReceivedVar() {
342 informationAll.newSmsReceived = false;
343 }
344 function resetSmsReportReceivedVar() {
345 informationAll.smsReportReceived = false;
346 }
347 function getSmsCapability() {
348 return stuffMake(arguments, {}, prepare, deal, null, false);
349 function prepare(values, isPost) {
350 var valueReq = {};
351 valueReq.cmd = "sms_capacity_info";
352 return valueReq;
353 }
354 function deal(paramD) {
355 return {
356 nvTotal: parseInt(paramD.sms_nv_total, 10),
357 nvUsed: parseInt(paramD.sms_nv_rev_total, 10) + parseInt(paramD.sms_nv_send_total, 10) + parseInt(paramD.sms_nv_draftbox_total, 10),
358 simTotal: parseInt(paramD.sms_sim_total, 10),
359 simUsed: parseInt(paramD.sms_sim_rev_total, 10) + parseInt(paramD.sms_sim_send_total, 10) + parseInt(paramD.sms_sim_draftbox_total, 10),
360 nvReceive: parseInt(paramD.sms_nv_rev_total, 10),
361 nvSend: parseInt(paramD.sms_nv_send_total, 10),
362 nvDraft: parseInt(paramD.sms_nv_draftbox_total, 10),
363 simReceive: parseInt(paramD.sms_sim_rev_total, 10),
364 simSend: parseInt(paramD.sms_sim_send_total, 10),
365 simDraft: parseInt(paramD.sms_sim_draftbox_total, 10)
366 };
367 }
368 }
369 function connect() {
370 var callback = arguments[1];
371 var checkPoint = 0;
372 return stuffMake(arguments, {}, prepare, deal, null, true);
373 function prepare(values, isPost) {
374 var valueReq = {};
375 valueReq.notCallback = true;
376 valueReq.goformId = "CONNECT_NETWORK";
377 return valueReq;
378 }
379 function deal(paramD) {
380 if (paramD.result == "success") {
381 checkPoint = new Date().getTime();
382 addCallback(checkConnectStatus);
383 } else {
384 callback({
385 result: false
386 });
387 }
388 }
389 function checkConnectStatus(paramD) {
390 if (paramD.ppp_status == "ppp_connecting") {
391 informationAll.connectStatus = "ppp_connecting";
392 } else if (paramD.ppp_status == "ppp_connected") {
393 removeCallback(checkConnectStatus);
394 informationAll.connectStatus = "ppp_connected";
395 callback({
396 result: true,
397 status: informationAll.connectStatus
398 });
399 } else if (new Date().getTime() - checkPoint < 1e4) {
400 informationAll.connectStatus = "ppp_connecting";
401 } else {
402 removeCallback(checkConnectStatus);
403 callback({
404 result: false
405 });
406 }
407 }
408 }
409 function disconnect() {
410 var callback = arguments[1];
411 var checkPoint = 0;
412 return stuffMake(arguments, {}, prepare, deal, null, true);
413 function prepare(values, isPost) {
414 var valueReq = {};
415 valueReq.notCallback = true;
416 valueReq.goformId = "DISCONNECT_NETWORK";
417 return valueReq;
418 }
419 function deal(paramD) {
420 if (paramD.result == "success") {
421 checkPoint = new Date().getTime();
422 addCallback(checkDisconnectStatus);
423 } else {
424 callback({
425 result: false
426 });
427 }
428 }
429 function checkDisconnectStatus(paramD) {
430 if (paramD.ppp_status == "ppp_disconnecting") {
431 informationAll.connectStatus = "ppp_disconnecting";
432 } else if (paramD.ppp_status == "ppp_disconnected") {
433 removeCallback(checkDisconnectStatus);
434 informationAll.connectStatus = "ppp_disconnected";
435 callback({
436 result: true,
437 status: informationAll.connectStatus
438 });
439 } else if (new Date().getTime() - checkPoint < 1e4) {
440 informationAll.connectStatus = "ppp_disconnecting";
441 } else {
442 removeCallback(checkDisconnectStatus);
443 callback({
444 result: false
445 });
446 }
447 }
448 }
449 function getApnSettings() {
450 return stuffMake(arguments, {}, prepare, deal, null, false);
451 function prepare(values, isPost) {
452 var valueReq = {};
453 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";
454 valueReq.multi_data = 1;
455 return valueReq;
456 }
457 function deal(result) {
458 if (result) {
459 return {
460 APNs: result.APN_configtmp0 + "||" + result.APN_configtmp1 + "||" + result.APN_configtmp2 + "||" + result.APN_configtmp3 + "||" + result.APN_configtmp4 + "||"
461 +result.APN_configtmp5 + "||" + result.APN_configtmp6 + "||" + result.APN_configtmp7 + "||" + result.APN_configtmp8 + "||" + result.APN_configtmp9 + "||"
462 +result.APN_configtmp10 + "||" + result.APN_configtmp11 + "||" + result.APN_configtmp12 + "||" + result.APN_configtmp13 + "||" + result.APN_configtmp14 + "||"
463 +result.APN_configtmp15 + "||" + result.APN_configtmp16 + "||" + result.APN_configtmp17 + "||" + result.APN_configtmp18 + "||" + result.APN_configtmp19,
464 ipv6APNs: result.ipv6_APN_configtmp0 + "||" + result.ipv6_APN_configtmp1 + "||" + result.ipv6_APN_configtmp2 + "||" + result.ipv6_APN_configtmp3 + "||" + result.ipv6_APN_configtmp4 + "||"
465 +result.ipv6_APN_configtmp5 + "||" + result.ipv6_APN_configtmp6 + "||" + result.ipv6_APN_configtmp7 + "||" + result.ipv6_APN_configtmp8 + "||" + result.ipv6_APN_configtmp9 + "||"
466 +result.ipv6_APN_configtmp10 + "||" + result.ipv6_APN_configtmp11 + "||" + result.ipv6_APN_configtmp12 + "||" + result.ipv6_APN_configtmp13 + "||" + result.ipv6_APN_configtmp14 + "||"
467 +result.ipv6_APN_configtmp15 + "||" + result.ipv6_APN_configtmp16 + "||" + result.ipv6_APN_configtmp17 + "||" + result.ipv6_APN_configtmp18 + "||" + result.ipv6_APN_configtmp19,
468 apnMode: result.apn_mode,
469 profileName: result.m_profile_name || result.profile_name,
470 wanDial: result.wan_dial,
471 pdpType: result.pdp_type == 'IP' ? 'IP' : result.ipv6_pdp_type,
472 pdpSelect: result.pdp_select,
473 index: result.index,
474 currIndex: result.Current_index,
475 autoApns: result.apn_auto_config,
476 autoApnsV6: result.ipv6_apn_auto_config,
477 wanApn: result.wan_apn,
478 authMode: result.ppp_auth_mode.toLowerCase(),
479 username: result.ppp_username,
480 password: result.ppp_passtmp,
481 dnsMode: "",
482 dns1: "",
483 dns2: "",
484 wanApnV6: result.ipv6_wan_apn,
485 authModeV6: result.ipv6_ppp_auth_mode.toLowerCase(),
486 usernameV6: result.ipv6_ppp_username,
487 passwordV6: result.ipv6_ppp_passtmp,
488 dnsModeV6: "",
489 dns1V6: "",
490 dns2V6: "",
491 apnNumPreset: result.apn_num_preset
492 };
493 } else {
494 return {
495 result: false
496 };
497 }
498 }
499 }
mj.quca0a6942025-01-06 22:36:07 -0800500 function getNetworkStatus() {
501 return stuffMake(arguments, {}, prepare, deal, null, false);
502 function prepare(values, isPost) {
503 var valueReq = {};
504 valueReq.cmd = "NETWORK_INFO";
505 return valueReq;
506 }
507 function deal(result) {
508 return {
509 sinr: result.lte_sinr,
510 rsrp: result.lte_rsrp,
511 rsrq: result.lte_rsrq,
512 plmn: result.lte_plmn,
513 pci: result.lte_pci,
514 cellid: result.lte_cellid,
515 band: result.lte_band
516 };
517 }
518 }
qumengjia1cd76022024-10-31 17:51:04 +0800519 function deleteApn() {
520 return stuffMake(arguments, {}, prepare, deal, null, true);
521 function prepare(values, isPost) {
522 var valueReq = {
523 apn_action: "delete",
524 apn_mode: "manual",
525 index: values.index
526 };
527 valueReq.goformId = "APN_PROC_EX";
528 return valueReq;
529 }
530 function deal(paramD) {
531 if (paramD.result == "success") {
532 return {
533 result: true
534 };
535 } else {
536 return {
537 result: false
538 };
539 }
540 }
541 }
542 function setDefaultApn() {
543 return stuffMake(arguments, {}, prepare, deal, null, true);
544 function prepare(values, isPost) {
545 var requestParam = {
546 goformId: "APN_PROC_EX",
547 apn_mode: values.apnMode
548 };
549 if (values.apnMode == 'manual') {
550 requestParam.apn_action = "set_default";
551 requestParam.set_default_flag = "1";
552 requestParam.pdp_type = values.pdpType;
553 requestParam.index = values.index;
554 }
555 return requestParam;
556 }
557 function deal(paramD) {
558 if (paramD.result == "success") {
559 return {
560 result: true
561 };
562 } else {
563 return {
564 result: false
565 };
566 }
567 }
568 }
569 function addOrEditApn() {
570 return stuffMake(arguments, {}, prepare, deal, null, true);
571 function prepare(values, isPost) {
572 var valueReq = {
573 goformId: "APN_PROC_EX",
574 apn_action: "save",
575 apn_mode: "manual",
576 profile_name: values.profileName,
577 wan_dial: '*99#',
578 pdp_type: values.pdpType,
579 pdp_select: 'auto',
580 index: values.index
581 };
582 if (values.pdpType == "IP") {
583 $.extend(valueReq, {
584 wan_apn: values.wanApn,
585 ppp_auth_mode: values.authMode,
586 ppp_username: values.username,
587 ppp_passtmp: values.password,
588 });
589 } else if (values.pdpType == "IPv6") {
590 $.extend(valueReq, {
591 ipv6_wan_apn: values.wanApnV6,
592 ipv6_ppp_auth_mode: values.authModeV6,
593 ipv6_ppp_username: values.usernameV6,
594 ipv6_ppp_passtmp: values.passwordV6
595 });
596 } else {
597 $.extend(valueReq, {
598 wan_apn: values.wanApn,
599 ppp_auth_mode: values.authMode,
600 ppp_username: values.username,
601 ppp_passtmp: values.password,
602 dns_mode: values.dnsMode,
603 prefer_dns_manual: values.dns1,
604 standby_dns_manual: values.dns2,
605 ipv6_wan_apn: values.wanApnV6,
606 ipv6_ppp_auth_mode: values.authModeV6,
607 ipv6_ppp_username: values.usernameV6,
608 ipv6_ppp_passtmp: values.passwordV6
609 });
610 }
611 return valueReq;
612 }
613 function deal(paramD) {
614 if (paramD.result == "success") {
615 return {
616 result: true
617 };
618 } else {
619 return {
620 result: false
621 };
622 }
623 }
624 }
625 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"];
626 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'];
627 if (config.HAS_SMS) {
628 $.merge(loginTimerQueryString, ["sms_received_flag", "sts_received_flag", 'sms_unread_num']);
629 }
630 var timerCallbackStack = [];
631 var timerCallbacks = [timerUpdateStatus];
632 function timerUpdater() {
633 if (!updateTimerFlag) {
634 setTimeout(function () {
635 timerUpdater();
636 }, 1000);
637 return;
638 }
639 var queryParams = checkTimerUpdaterParameters();
640 reqAsync(queryParams, function (paramD) {
641 for (var i = 0; i < timerCallbacks.length; i++) {
642 if (typeof timerCallbacks[i] === "function") {
643 timerCallbacks[i](paramD);
644 }
645 }
646 $.merge(timerCallbacks, timerCallbackStack);
647 timerCallbackStack = [];
648 setTimeout(function () {
649 timerUpdater();
650 }, 1000);
651 }, function () {
652 timerUpdaterErrorCallback();
653 setTimeout(function () {
654 timerUpdater();
655 }, 1000);
656 }, false);
657 }
658 function checkTimerUpdaterParameters() {
659 var queryParams = {
660 multi_data: 1,
661 };
662 if (window.location.hash && window.location.hash != '#entry' && informationAll.isLoggedIn) {
663 if (config.HAS_SMS) {
664 queryParams.sms_received_flag_flag = 0;
665 queryParams.sts_received_flag_flag = 0;
666 }
667 if (loginTimerQueryString.length > 0 && _.indexOf(timerQueryString, loginTimerQueryString[0]) == -1) {
668 $.each(loginTimerQueryString, function (i, n) {
669 timerQueryString.push(n);
670 });
671 }
672 } else {
673 if (loginTimerQueryString.length > 0 && _.indexOf(timerQueryString, loginTimerQueryString[0]) != -1) {
674 timerQueryString = _.without(timerQueryString, loginTimerQueryString);
675 }
676 }
677 queryParams.cmd = timerQueryString.join(",");
678 return queryParams;
679 }
680 function addCallback(cb) {
681 if (_.indexOf(timerCallbackStack, cb) == -1) {
682 timerCallbackStack.push(cb);
683 }
684 }
685 function removeCallback(cb) {
686 timerCallbacks = _.without(timerCallbacks, cb);
687 if (timerCallbacks.length == 0) {
688 timerCallbacks.push(timerUpdateStatus);
689 }
690 return timerCallbackStack;
691 }
692 function addQueryString(query) {
693 if (_.indexOf(timerQueryString, query) == -1) {
694 timerQueryString.push(query);
695 }
696 }
697 function removeQueryString(query) {
698 timerQueryString = _.without(timerQueryString, query);
699 return timerQueryString;
700 }
701 function timerUpdateStatus(paramD) {
702 informationAll.defaultWanName = paramD.default_wan_name;
703 informationAll.signalImg = typeof paramD.signalbar == 'undefined' ? '0' : paramD.signalbar;
704 informationAll.networkType = paramD.sub_network_type ? paramD.sub_network_type : (paramD.network_type ? paramD.network_type : '');
705 if (informationAll.networkType.toLowerCase().indexOf("limited_service") != -1 || informationAll.networkType.toLowerCase().indexOf("limited service") != -1) {
706 informationAll.networkType = "limited_service";
707 } else if (informationAll.networkType.toLowerCase().indexOf("no_service") != -1 || informationAll.networkType.toLowerCase().indexOf("no service") != -1) {
708 informationAll.networkType = "no_service";
709 }
710 informationAll.networkOperator = paramD.network_provider ? paramD.network_provider : '';
711 informationAll.spn_b1_flag = paramD.spn_b1_flag;
712 informationAll.spn_b2_flag = paramD.spn_b2_flag;
713 informationAll.spn_name_data = paramD.spn_name_data;
714 informationAll.connectStatus = typeof paramD.ppp_status == 'undefined' ? 'ppp_disconnected' : paramD.ppp_status;
715 informationAll.rj45ConnectStatus = (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state;
716 informationAll.ethWanMode = paramD.ethwan_mode;
717 informationAll.ssid1AttachedNum = paramD.sta_count == "" ? 0 : parseInt(paramD.sta_count, 10);
718 informationAll.ssid2AttachedNum = paramD.m_sta_count == "" ? 0 : parseInt(paramD.m_sta_count, 10);
719 informationAll.roamingStatus = getRoamStatus(informationAll.networkType, paramD.modem_main_state, paramD.simcard_roam);
720 informationAll.wifiStatus = paramD.wifi_cur_state == "1";
721 informationAll.simStatus = paramD.modem_main_state;
722 informationAll.pinStatus = paramD.pin_status;
723 var needMinutes = 3 * 60 * 60;
724 var batteryLevel = (paramD.battery_vol_percent && paramD.battery_vol_percent.length > 0) ? paramD.battery_vol_percent : 100;
725 informationAll.batteryPers = paramD.battery_pers;
726 var remainMinutes = Math.round(needMinutes * (1 - batteryLevel / 100));
727 informationAll.batteryStatus = (typeof paramD.battery_charging == 'undefined') ? '0' : paramD.battery_charging;
728 informationAll.batteryLevel = batteryLevel;
729 informationAll.batteryTime = remainMinutes.toString();
730 informationAll.data_counter = {
731 uploadRate: paramD.realtime_tx_thrpt == '' ? 0 : paramD.realtime_tx_thrpt,
732 downloadRate: paramD.realtime_rx_thrpt == '' ? 0 : paramD.realtime_rx_thrpt,
733 currentSent: paramD.realtime_tx_bytes == '' ? 0 : paramD.realtime_tx_bytes,
734 currentReceived: paramD.realtime_rx_bytes == '' ? 0 : paramD.realtime_rx_bytes,
735 currentConnectedTime: paramD.realtime_time == '' ? 0 : paramD.realtime_time,
736 monthlySent: paramD.monthly_tx_bytes == '' ? 0 : paramD.monthly_tx_bytes,
737 monthlyReceived: paramD.monthly_rx_bytes == '' ? 0 : paramD.monthly_rx_bytes,
738 traffic_alined_delta: paramD.traffic_alined_delta == '' ? 0 : paramD.traffic_alined_delta,
739 monthlyConnectedTime: paramD.monthly_time == '' ? 0 : paramD.monthly_time,
740 month: paramD.date_month == '' ? 1 : paramD.date_month
741 };
742 informationAll.ssid = paramD.SSID1;
743 informationAll.authMode = paramD.AuthMode;
744 informationAll.isLoggedIn = config.HAS_LOGIN ? paramD.loginfo == "ok" : true;
745 if (config.HAS_SMS) {
746 if (!informationAll.newSmsReceived) {
747 informationAll.newSmsReceived = paramD.sms_received_flag > 0;
748 }
749 if (!informationAll.smsReportReceived) {
750 informationAll.smsReportReceived = paramD.sts_received_flag > 0;
751 }
752 if (typeof paramD.sms_dev_unread_num != "undefined") {
753 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);
754 } else {
755 informationAll.smsUnreadCount = parseInt(paramD.sms_unread_num | 0, 10)
756 }
757 }
758 if (paramD.data_volume_limit_switch == '1') {
759 informationAll.limitVolumeEnable = true;
760 informationAll.limitVolumeType = paramD.data_volume_limit_unit == 'data' ? '1' : '0';
761 informationAll.limitVolumePercent = paramD.data_volume_alert_percent;
762 if (paramD.data_volume_limit_unit == 'data') {
763 var limitMonth = paramD.data_volume_limit_size.split("_");
764 informationAll.limitVolumeSize = limitMonth[0] * limitMonth[1] * 1024 * 1024;
765 } else {
766 informationAll.limitVolumeSize = paramD.data_volume_limit_size * 60 * 60;
767 }
768 } else {
769 informationAll.limitVolumeEnable = false;
770 informationAll.limitVolumeType = '1';
771 informationAll.limitVolumePercent = '100';
772 informationAll.limitVolumeSize = '0';
773 }
774 informationAll.connectWifiProfile = paramD.EX_wifi_profile;
775 informationAll.connectWifiSSID = paramD.EX_SSID1;
776 informationAll.connectWifiStatus = paramD.sta_ip_status;
777 informationAll.multi_ssid_enable = paramD.m_ssid_enable;
778 informationAll.roamMode = paramD.roam_setting_option;
779 if (paramD.blc_wan_mode == "AUTO") {
780 informationAll.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';
781 } else {
782 informationAll.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';
783 }
784 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";
785 informationAll.current_upgrade_state = paramD.fota_current_upgrade_state;
786 if (informationAll.current_upgrade_state == "verify_failed") {
787 informationAll.current_upgrade_state = "upgrade_pack_error";
788 }
789 informationAll.fota_user_selector = paramD.fota_upgrade_selector;
790 informationAll.is_mandatory = paramD.is_mandatory == "1" || paramD.fota_new_version_state == "has_critical";
791 informationAll.allowRoamingUpdate = paramD.upg_roam_switch;
792 informationAll.dialMode = paramD.dial_mode;
793 informationAll.fota_package_already_download = paramD.fota_package_already_download;
794 }
795 function timerUpdaterErrorCallback() {
796 informationAll.batteryStatus = '0';
797 }
798 function getRoamStatus(networkType, modemState, simcardRoam) {
799 if (("" == $.trim(networkType)) || "no_service" == networkType.toLowerCase() || "limited_service" == networkType.toLowerCase() || "modem_sim_undetected" == modemState || "modem_waitpin" == modemState || "modem_waitpuk" == modemState) {
800 return false;
801 }
802 if ("Internal" == simcardRoam || "International" == simcardRoam) {
803 return true;
804 } else {
805 return false;
806 }
807 }
808 $(document).ready(function () {
809 setTimeout(function () {
810 timerUpdater();
811 }, 0);
812 });
813 function setNetwork(strNetworkNumber, nRat, nSubAct, callback) {
814 if ((typeof(strNetworkNumber) !== "string") || (strNetworkNumber === "") || (typeof(nRat) !== "number") || (isNaN(nRat))) {
815 if (typeof(callback) === "function") {
816 callback(false);
817 return;
818 }
819 }
820 var nRat1 = -1;
821 if (nRat === 0) {
822 nRat1 = 0;
823 } else if (nRat === 2) {
824 nRat1 = 2;
825 } else if (nRat == 7) {
826 nRat1 = 7;
827 } else {
828 nRat1 = -1;
829 }
830 if (-1 === nRat1) {
831 if (typeof(callback) === "function") {
832 callback(false);
833 return;
834 }
835 }
836 var SubAct;
837 if (nSubAct.toString() == "NaN") {
838 SubAct = "";
839 } else {
840 SubAct = nSubAct;
841 }
842 reqAsync({
843 goformId: "SET_NETWORK",
844 NetworkNumber: strNetworkNumber,
845 Rat: nRat,
846 nSubrat: SubAct
847 }, function (paramD) {
848 if (paramD && paramD.result == "success") {
849 var flag;
850 var counter = 0;
851 var timer = setInterval(function () {
852 var obj = reqSync({
853 cmd: 'm_netselect_result',
854 }, false);
855 if (!obj) {
856 callback(false);
857 return;
858 }
859 if (obj.m_netselect_result == "manual_success") {
860 flag = "1";
861 window.clearInterval(timer);
862 callback(true);
863 } else if (obj.m_netselect_result == "manual_fail") {
864 flag = "0";
865 window.clearInterval(timer);
866 callback(false);
867 } else if (counter < 120) {
868 counter++;
869 } else {
870 window.clearInterval(timer);
871 callback(false);
872 }
873 }, 1000);
874 } else {
875 callback(false);
876 }
877 }, function (paramD) {
878 callback(false);
879 }, true);
880 }
881 function savePhoneBook() {
882 var callback = arguments[1];
883 return stuffMake(arguments, {}, prepare, deal, null, true);
884 function prepare(values, isPost) {
885 var valueReq = {};
886 valueReq.notCallback = true;
887 valueReq.goformId = "PBM_CONTACT_ADD";
888 valueReq.location = values.location;
889 valueReq.name = encodeMessage(values.name);
890 valueReq.mobilephone_num = values.mobile_phone_number;
891 if (valueReq.location == 1) {
892 valueReq.add_index_pc = values.index;
893 valueReq.homephone_num = values.home_phone_number;
894 valueReq.officephone_num = values.office_phone_number;
895 valueReq.email = encodeMessage(values.mail);
896 valueReq.groupchoose = values.group;
897 if (!valueReq.groupchoose) {
898 valueReq.groupchoose = "common";
899 }
900 } else {
901 valueReq.edit_index = values.index;
902 }
903 if (values.delId != undefined) {
904 valueReq.delId = values.delId;
905 }
906 return valueReq;
907 }
908 function deal(paramD) {
909 if (paramD && paramD.result == "success") {
910 addTimerSomething("pbm_write_flag", checkSavePhoneBook);
911 } else {
912 callback(paramD);
913 }
914 }
915 function checkSavePhoneBook(paramD) {
916 checkPbmWriteFlag(paramD, callback, checkSavePhoneBook);
917 }
918 }
919 function checkPbmWriteFlag(paramD, callback, fn) {
920 if (paramD.pbm_write_flag == "0") {
921 removeTimerSomething("pbm_write_flag", fn);
922 callback({
923 result: "success"
924 });
925 } 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") {
926 removeTimerSomething("pbm_write_flag", fn);
927 callback({
928 result: "fail"
929 });
930 } else {}
931 }
932 function deletePhoneBooks() {
933 var callback = arguments[1];
934 return stuffMake(arguments, {}, prepare, deal, null, true);
935 function prepare(values, isPost) {
936 var valueReq = {};
937 valueReq.notCallback = true;
938 valueReq.goformId = "PBM_CONTACT_DEL";
939 valueReq.del_option = "delete_num";
940 valueReq.delete_id = values.indexs.join(",");
941 return valueReq;
942 }
943 function deal(paramD) {
944 if (paramD && paramD.result == "success") {
945 addTimerSomething("pbm_write_flag", checkDeletePhoneBooks);
946 } else {
947 callback(paramD);
948 }
949 }
950 function checkDeletePhoneBooks(paramD) {
951 checkPbmWriteFlag(paramD, callback, checkDeletePhoneBooks);
952 }
953 }
954 function deleteAllPhoneBooks() {
955 var callback = arguments[1];
956 return stuffMake(arguments, {}, prepare, deal, null, true);
957 function prepare(values, isPost) {
958 var valueReq = {};
959 valueReq.notCallback = true;
960 valueReq.goformId = "PBM_CONTACT_DEL";
961 valueReq.del_option = "delete_all";
962 valueReq.del_all_location = values.location;
963 return valueReq;
964 }
965 function deal(paramD) {
966 if (paramD && paramD.result == "success") {
967 addTimerSomething("pbm_write_flag", checkDeleteAllPhoneBooks);
968 } else {
969 callback(paramD);
970 }
971 }
972 function checkDeleteAllPhoneBooks(paramD) {
973 checkPbmWriteFlag(paramD, callback, checkDeleteAllPhoneBooks);
974 }
975 }
976 function deleteAllPhoneBooksByGroup() {
977 var callback = arguments[1];
978 return stuffMake(arguments, {}, prepare, deal, null, true);
979 function prepare(values, isPost) {
980 var valueReq = {};
981 valueReq.notCallback = true;
982 valueReq.goformId = "PBM_CONTACT_DEL";
983 valueReq.del_option = "delete_all_by_group";
984 valueReq.del_all_location = 3;
985 valueReq.del_group = values.group;
986 return valueReq;
987 }
988 function deal(paramD) {
989 if (paramD && paramD.result == "success") {
990 addTimerSomething("pbm_write_flag", checkDeleteAllPhoneBooksByGroup);
991 } else {
992 callback(paramD);
993 }
994 }
995 function checkDeleteAllPhoneBooksByGroup(paramD) {
996 checkPbmWriteFlag(paramD, callback, checkDeleteAllPhoneBooksByGroup);
997 }
998 }
999 function setConnectionMode() {
1000 return stuffMake(arguments, {}, prepare, deal, null, true);
1001 function prepare(values, isPost) {
1002 var valueReq = {};
1003 valueReq.goformId = "SET_CONNECTION_MODE";
1004 valueReq.ConnectionMode = values.connectionMode;
1005 valueReq.roam_setting_option = values.isAllowedRoaming;
1006 return valueReq;
1007 }
1008 function deal(paramD) {
1009 if (paramD) {
1010 return paramD;
1011 } else {
1012 callback(paramD);
1013 }
1014 }
1015 }
1016 function getConnectionMode() {
1017 return stuffMake(arguments, {}, prepare, deal, null, false);
1018 function prepare(values, isPost) {
1019 var valueReq = {};
1020 valueReq.cmd = "ConnectionMode";
1021 return valueReq;
1022 }
1023 function deal(paramD) {
1024 if (paramD) {
1025 var result = {};
1026 result.connectionMode = paramD.connectionMode;
1027 result.isAllowedRoaming = paramD.autoConnectWhenRoaming;
1028 return result;
1029 } else {
1030 return errUnknownObj;
1031 }
1032 }
1033 }
1034 function _getPhoneBooks(array, location) {
1035 if (array[0].data_per_page == 0) {
1036 return {
1037 "pbm_data": []
1038 };
1039 }
1040 return stuffMake(array, {}, prepare, deal, null, false);
1041 function prepare(values, isPost) {
1042 var valueReq = {};
1043 valueReq.mem_store = location;
1044 if (location == 2) {
1045 valueReq.cmd = "pbm_data_total";
1046 } else {
1047 valueReq.cmd = "pbm_data_info";
1048 }
1049 valueReq.page = values.page;
1050 valueReq.data_per_page = values.data_per_page;
1051 valueReq.orderBy = values.orderBy;
1052 valueReq.isAsc = values.isAsc;
1053 return valueReq;
1054 }
1055 function deal(paramD) {
1056 if (paramD && paramD.pbm_data) {
1057 var books = [];
1058 $.each(paramD.pbm_data, function (i) {
1059 books.push({
1060 pbm_id: paramD.pbm_data[i].pbm_id,
1061 pbm_location: paramD.pbm_data[i].pbm_location,
1062 pbm_number: paramD.pbm_data[i].pbm_number,
1063 pbm_anr: paramD.pbm_data[i].pbm_anr,
1064 pbm_anr1: paramD.pbm_data[i].pbm_anr1,
1065 pbm_group: paramD.pbm_data[i].pbm_group,
1066 pbm_name: decodeMessage(paramD.pbm_data[i].pbm_name),
1067 pbm_email: decodeMessage(paramD.pbm_data[i].pbm_email)
1068 });
1069 });
1070 return {
1071 pbm_data: books
1072 };
1073 } else {
1074 return errUnknownObj;
1075 }
1076 }
1077 }
1078 function getPhoneBooksByGroup() {
1079 if (arguments[0].data_per_page == 0) {
1080 return {
1081 "pbm_data": []
1082 };
1083 }
1084 return stuffMake(arguments, {}, prepare, deal, null, false);
1085 function prepare(values, isPost) {
1086 var valueReq = {};
1087 valueReq.cmd = "pbm_data_total";
1088 valueReq.mem_store = 3;
1089 valueReq.pbm_group = values.group;
1090 valueReq.page = values.page;
1091 valueReq.data_per_page = values.data_per_page;
1092 valueReq.orderBy = values.orderBy;
1093 valueReq.isAsc = values.isAsc;
1094 return valueReq;
1095 }
1096 function deal(paramD) {
1097 if (paramD && paramD.pbm_data) {
1098 var books = [];
1099 $.each(paramD.pbm_data, function (i) {
1100 books.push({
1101 pbm_id: paramD.pbm_data[i].pbm_id,
1102 pbm_location: paramD.pbm_data[i].pbm_location,
1103 pbm_number: paramD.pbm_data[i].pbm_number,
1104 pbm_anr: paramD.pbm_data[i].pbm_anr,
1105 pbm_anr1: paramD.pbm_data[i].pbm_anr1,
1106 pbm_group: paramD.pbm_data[i].pbm_group,
1107 pbm_name: decodeMessage(paramD.pbm_data[i].pbm_name),
1108 pbm_email: decodeMessage(paramD.pbm_data[i].pbm_email)
1109 });
1110 });
1111 return {
1112 pbm_data: books
1113 };
1114 } else {
1115 return errUnknownObj;
1116 }
1117 }
1118 }
1119 function getDevicePhoneBooks() {
1120 return _getPhoneBooks(arguments, 1);
1121 }
1122 function getSIMPhoneBooks() {
1123 return _getPhoneBooks(arguments, 0);
1124 }
1125 function getPhoneBooks() {
1126 return _getPhoneBooks(arguments, 2);
1127 }
1128 function getPhoneBookReady() {
1129 return stuffMake(arguments, {}, prepare, deal, null, false);
1130 function prepare(values, isPost) {
1131 var valueReq = {};
1132 valueReq.cmd = "pbm_init_flag";
1133 return valueReq;
1134 }
1135 function deal(paramD) {
1136 if (paramD) {
1137 return paramD;
1138 } else {
1139 return errUnknownObj;
1140 }
1141 }
1142 }
1143 function getPhoneBookCapacity(array, isSIM) {
1144 return stuffMake(array, {}, prepare, deal, null, false);
1145 function prepare(values, isPost) {
1146 var valueReq = {};
1147 valueReq.cmd = "pbm_capacity_info";
1148 if (isSIM) {
1149 valueReq.pbm_location = "pbm_sim";
1150 } else {
1151 valueReq.pbm_location = "pbm_native";
1152 }
1153 return valueReq;
1154 }
1155 function deal(paramD) {
1156 if (paramD) {
1157 return paramD;
1158 } else {
1159 return errUnknownObj;
1160 }
1161 }
1162 }
1163 function getSIMPhoneBookCapacity() {
1164 var paramD = getPhoneBookCapacity(arguments, true);
1165 return {
1166 simPbmTotalCapacity: parseInt(paramD.pbm_sim_max_record_num),
1167 simPbmUsedCapacity: parseInt(paramD.pbm_sim_used_record_num),
1168 simType: paramD.pbm_sim_type,
1169 maxNameLen: parseInt(paramD.pbm_sim_max_name_len),
1170 maxNumberLen: parseInt(paramD.pbm_sim_max_number_len) > 40 ? 40 : parseInt(paramD.pbm_sim_max_number_len)
1171 };
1172 }
1173 function getDevicePhoneBookCapacity() {
1174 var paramD = getPhoneBookCapacity(arguments, false);
1175 return {
1176 pcPbmTotalCapacity: parseInt(paramD.pbm_dev_max_record_num),
1177 pcPbmUsedCapacity: parseInt(paramD.pbm_dev_used_record_num)
1178 };
1179 }
1180 function getAttachedCableDevices() {
1181 return stuffMake(arguments, {}, prepare, deal, null, false);
1182 function prepare(values, isPost) {
1183 var obj = {
1184 cmd: "lan_station_list"
1185 };
1186 return obj;
1187 }
1188 function deal(paramD) {
1189 var deviceArr = [];
1190 var attachedDevices = paramD.lan_station_list || paramD.station_list;
1191 for (var i = 0; attachedDevices && i < attachedDevices.length; i++) {
1192 var obj = {};
1193 obj.macAddress = attachedDevices[i].mac_addr;
1194 var hostname = attachedDevices[i].hostname;
1195 obj.hostName = hostname == "" ? $.i18n.prop("unknown") : hostname;
1196 obj.ipAddress = attachedDevices[i].ip_addr;
1197 deviceArr.push(obj);
1198 }
1199 return {
1200 attachedDevices: deviceArr
1201 };
1202 }
1203 }
1204 function getCurrentlyAttachedDevicesInfo() {
1205 return stuffMake(arguments, {}, prepare, deal, null, false);
1206 function prepare(values, isPost) {
1207 var obj = {
1208 cmd: "station_list"
1209 };
1210 return obj;
1211 }
1212 function deal(paramD) {
1213 var deviceArr = [];
1214 var attachedDevices = paramD.station_list;
1215 for (var i = 0; attachedDevices && i < attachedDevices.length; i++) {
1216 var obj = {};
1217 obj.macAddress = attachedDevices[i].mac_addr;
1218 var hostname = attachedDevices[i].hostname;
1219 obj.hostName = hostname == "" ? $.i18n.prop("unknown") : hostname;
1220 obj.ipAddress = attachedDevices[i].ip_addr;
1221 deviceArr.push(obj);
1222 }
1223 return {
1224 attachedDevices: deviceArr
1225 };
1226 }
1227 }
1228
1229 function setLanguage() {
1230 return stuffMake(arguments, {}, prepare, deal, null, true);
1231 function prepare(values, isPost) {
1232 var valueReq = {};
1233 valueReq.goformId = "SET_WEB_LANGUAGE";
1234 valueReq.Language = values.Language;
1235 return valueReq;
1236 }
1237 function deal(paramD) {
1238 if (paramD) {
1239 return paramD;
1240 } else {
1241 return errUnknownObj;
1242 }
1243 }
1244 }
1245 function getLanguage() {
1246 return stuffMake(arguments, {}, prepare, deal, null, false);
1247 function prepare(values, isPost) {
1248 var valueReq = {};
1249 valueReq.cmd = "Language";
1250 valueReq.multi_data = 1;
1251 return valueReq;
1252 }
1253 function deal(paramD) {
1254 if (paramD) {
1255 var result = {};
1256 result.Language = (paramD && paramD.Language) ? paramD.Language : "en";
1257 return result;
1258 } else {
1259 return errUnknownObj;
1260 }
1261 }
1262 }
1263
1264 function setBearerPreference() {
1265 return stuffMake(arguments, {}, prepare, deal, null, true);
1266 function prepare(values, isPost) {
1267 var valueReq = {};
1268 valueReq.goformId = "SET_BEARER_PREFERENCE";
1269 valueReq.BearerPreference = values.strBearerPreference;
1270 return valueReq;
1271 }
1272 function deal(paramD) {
1273 if (paramD) {
1274 return paramD;
1275 } else {
1276 return errUnknownObj;
1277 }
1278 }
1279 }
1280 function scanForNetwork(callback) {
1281 $.post("/reqproc/proc_post", {
1282 goformId: "SCAN_NETWORK"
1283 }, function (paramD) {
1284 if (paramD.result == "success") {
1285 checkScanStatus();
1286 } else {
1287 callback(false, []);
1288 }
1289 }, "json").error(function () {
1290 callback(false, []);
1291 });
1292 function checkScanStatus() {
1293 $.getJSON("/reqproc/proc_get", {
1294 cmd: "m_netselect_status",
1295 "_": new Date().getTime()
1296 }, function (paramD) {
1297 if (paramD.m_netselect_status == "manual_selecting") {
1298 setTimeout(checkScanStatus, 1000);
1299 } else {
1300 $.getJSON("/reqproc/proc_get", {
1301 cmd: "m_netselect_contents",
1302 "_": new Date().getTime()
1303 }, function (paramD2) {
1304 if (trim(paramD2.m_netselect_contents) != "") {
1305 parseScanResult(paramD2.m_netselect_contents);
1306 } else {
1307 callback(false, []);
1308 }
1309 }).error(function () {
1310 callback(false, []);
1311 });
1312 }
1313 }).error(function () {
1314 callback(false, []);
1315 });
1316 }
1317 function parseScanResult(result) {
1318 var pattern = /([^,;]*),([^,]*),([^,]*),([^,]*),([^,;]*)/g;
1319 var listNetwork = [];
1320 var mts;
1321 var unit = result.split(";");
1322 var unitString = "";
1323 for (i = 0; i < unit.length; i++) {
1324 var unitLength = unit[i].split(",").length;
1325 if (unitLength == 4) {
1326 unitString += unit[i] + ",NON;";
1327 } else {
1328 unitString += unit[i] + ";";
1329 }
1330 }
1331 while (mts = pattern.exec(unitString)) {
1332 if (mts != null) {
1333 listNetwork.push({
1334 strShortName: mts[2].replace(/\"/g, ''),
1335 strNumeric: mts[3].replace(/\D/g, ''),
1336 nRat: parseInt(mts[4], 10),
1337 nState: parseInt(mts[1], 10),
1338 SubAct: parseInt(mts[5], 10)
1339 });
1340 }
1341 }
1342 callback(true, listNetwork);
1343 }
1344 }
1345 function getNetSelectInfo() {
1346 return stuffMake(arguments, {}, prepare, deal, null, false);
1347 function prepare(values, isPost) {
1348 var valueReq = {};
1349 valueReq.cmd = "current_network_mode,m_netselect_save,net_select_mode,m_netselect_contents,net_select,ppp_status,modem_main_state";
1350 valueReq.multi_data = 1;
1351 return valueReq;
1352 }
1353 function deal(paramD) {
1354 if (paramD) {
1355 var result = {};
1356 result.current_network_mode = paramD.current_network_mode;
1357 result.net_select_mode = paramD.net_select_mode;
1358 result.m_netselect_save = paramD.m_netselect_save;
1359 result.m_netselect_contents = paramD.m_netselect_contents;
1360 result.net_select = paramD.net_select;
1361 result.ppp_status = paramD.ppp_status;
1362 result.modem_main_state = paramD.modem_main_state;
1363 return result;
1364 } else {
1365 return errUnknownObj;
1366 }
1367 }
1368 }
1369
1370 function getSMSMessages() {
1371 return stuffMake(arguments, {}, prepare, deal, {}, false);
1372 function prepare(values, isPost) {
1373 var obj = {
1374 cmd: "sms_data_total",
1375 page: values.page,
1376 data_per_page: config.SMS_DATABASE_SORT_SUPPORT ? values.smsCount : 500,
1377 mem_store: values.nMessageStoreType,
1378 tags: values.tags,
1379 order_by: values.orderBy
1380 };
1381 return obj;
1382 }
1383 function deal(paramD) {
1384 if (paramD && paramD.messages && paramD.messages.length > 0) {
1385 return {
1386 messages: parseMessages(paramD.messages)
1387 };
1388 } else {
1389 return {
1390 messages: []
1391 };
1392 }
1393 }
1394 }
1395 function parseMessages(messages, isReport) {
1396 var result = [];
1397 for (var i = 0; i < messages.length; i++) {
1398 if (!config.SHOW_UN_COMPLETE_CONCAT_SMS && typeof messages[i].received_all_concat_sms != "undefined" && messages[i].received_all_concat_sms == '0') {
1399 continue;
1400 }
1401 var oneMessage = {};
1402 oneMessage.id = messages[i].id;
1403 oneMessage.number = messages[i].number;
1404 oneMessage.content = isReport ? messages[i].content : decodeMessageContent(messages[i].content);
1405 oneMessage.time = transTime('20' + messages[i].date);
1406 oneMessage.isNew = messages[i].tag == "1";
1407 oneMessage.groupId = messages[i].draft_group_id;
1408 oneMessage.tag = messages[i].tag;
1409 oneMessage.receivedAll = messages[i].received_all_concat_sms == '1';
1410 result.push(oneMessage);
1411 }
1412 if (!config.SMS_DATABASE_SORT_SUPPORT) {
1413 var ids = [];
1414 var tmpResult = [];
1415 for (var i = result.length; i--; ) {
1416 var n = result[i];
1417 var idx = $.inArray(n.id, ids);
1418 if (idx == -1) {
1419 ids.push(n.id);
1420 tmpResult.push(n);
1421 } else {
1422 if (n.content.length > tmpResult[idx].content.length) {
1423 tmpResult[idx] = n;
1424 }
1425 }
1426 }
1427 return _.sortBy(tmpResult, function (n) {
1428 return 0 - n.id;
1429 });
1430 } else {
1431 return result;
1432 }
1433 }
1434 function decodeMessageContent(msgContent) {
1435 return decodeMessage(escapeMessage(msgContent));
1436 }
1437 function sendSMS() {
1438 var callback = arguments[1];
1439 var errorCabllback = arguments[2] ? arguments[2] : callback;
1440 return stuffMake(arguments, {}, prepare, deal, null, true);
1441 function prepare(values, isPost) {
1442 var obj = {
1443 goformId: "SEND_SMS",
1444 notCallback: true,
1445 Number: values.number,
1446 sms_time: getCurrentTimeString(),
1447 MessageBody: escapeMessage(encodeMessage(values.message)),
1448 ID: values.id,
1449 encode_type: getEncodeType(values.message).encodeType
1450 };
1451 return obj;
1452 }
1453 function deal(paramD) {
1454 if (!paramD) {
1455 errorCabllback($.extend(errUnknownObj, {
1456 errorType: "sendFail",
1457 errorText: "send_fail_try_again"
1458 }));
1459 return;
1460 }
1461 if (paramD.result == "success") {
1462 setTimeout(function () {
1463 getSmsStatusInfo({
1464 smsCmd: 4,
1465 errorType: "sendFail",
1466 errorText: "send_fail_try_again"
1467 }, callback, errorCabllback);
1468 }, 1000);
1469 } else {
1470 errorCabllback($.extend(errUnknownObj, {
1471 errorType: "sendFail",
1472 errorText: "send_fail_try_again"
1473 }));
1474 }
1475 }
1476 }
1477 function saveSMS() {
1478 var callback = arguments[1];
1479 var errorCabllback = arguments[2] ? arguments[2] : callback;
1480 return stuffMake(arguments, {}, prepare, deal, null, true);
1481 function prepare(values, isPost) {
1482 var obj = {
1483 notCallback: true,
1484 goformId: "SAVE_SMS",
1485 SMSMessage: escapeMessage(encodeMessage(values.message)),
1486 SMSNumber: values.numbers.join(";") + ";",
1487 Index: values.index,
1488 encode_type: getEncodeType(values.message).encodeType,
1489 sms_time: values.currentTimeString,
1490 draft_group_id: values.groupId
1491 };
1492 return obj;
1493 }
1494 function deal(paramD) {
1495 if (!paramD) {
1496 errorCabllback($.extend(errUnknownObj, {
1497 errorType: "saveFail",
1498 errorText: "save_fail"
1499 }));
1500 return;
1501 }
1502 if (paramD.result == "success") {
1503 getSmsStatusInfo({
1504 smsCmd: 5,
1505 errorType: "saveFail",
1506 errorText: "save_fail"
1507 }, callback, errorCabllback);
1508 } else {
1509 errorCabllback($.extend(errUnknownObj, {
1510 errorType: "saveFail",
1511 errorText: "save_fail"
1512 }));
1513 }
1514 }
1515 }
1516 function deleteAllMessages() {
1517 var callback = arguments[1];
1518 var errorCabllback = arguments[2] ? arguments[2] : callback;
1519 return stuffMake(arguments, {}, prepare, deal, null, true);
1520 function prepare(values, isPost) {
1521 var obj = {
1522 goformId: "ALL_DELETE_SMS",
1523 notCallback: true,
1524 which_cgi: values.location
1525 };
1526 return obj;
1527 }
1528 function deal(paramD) {
1529 if (!paramD) {
1530 errorCabllback($.extend(errUnknownObj, {
1531 errorType: "deleteFail",
1532 errorText: "delete_fail_try_again"
1533 }));
1534 return;
1535 }
1536 if (paramD.result == "success") {
1537 addTimerSomething("sms_cmd_status_info", checkDeleteStatus);
1538 } else {
1539 errorCabllback($.extend(errUnknownObj, {
1540 errorType: "deleteFail",
1541 errorText: "delete_fail_try_again"
1542 }));
1543 }
1544 }
1545 function checkDeleteStatus(paramD) {
1546 var status = paramD.sms_cmd_status_info;
1547 if (status == "2") {
1548 removeTimerSomething("sms_cmd_status_info", checkDeleteStatus);
1549 errorCabllback($.extend(errUnknownObj, {
1550 errorType: "deleteFail",
1551 errorText: "delete_fail_try_again"
1552 }));
1553 } else if (status == "3") {
1554 removeTimerSomething("sms_cmd_status_info", checkDeleteStatus);
1555 callback({
1556 result: true
1557 });
1558 }
1559 }
1560 }
1561 function deleteMessage() {
1562 var callback = arguments[1];
1563 var errorCabllback = arguments[2] ? arguments[2] : callback;
1564 return stuffMake(arguments, {}, prepare, deal, null, true);
1565 function prepare(values, isPost) {
1566 var msgIds = values.ids.join(";") + ";";
1567 var obj = {
1568 goformId: "DELETE_SMS",
1569 msg_id: msgIds,
1570 notCallback: true
1571 };
1572 return obj;
1573 }
1574 function deal(paramD) {
1575 if (!paramD) {
1576 errorCabllback($.extend(errUnknownObj, {
1577 errorType: "deleteFail",
1578 errorText: "delete_fail_try_again"
1579 }));
1580 return;
1581 }
1582 if (paramD.result == "success") {
1583 getSmsStatusInfo({
1584 smsCmd: 6,
1585 errorType: "deleteFail",
1586 errorText: "delete_fail_try_again"
1587 }, callback, errorCabllback);
1588 } else {
1589 errorCabllback($.extend(errUnknownObj, {
1590 errorType: "deleteFail",
1591 errorText: "delete_fail_try_again"
1592 }));
1593 }
1594 }
1595 }
1596 function getSmsStatusInfo(obj, callback, errorCabllback) {
1597 reqAsync({
1598 cmd: "sms_cmd_status_info",
1599 sms_cmd: obj.smsCmd,
1600 }, function (paramD) {
1601 if (paramD) {
1602 var status = paramD.sms_cmd_status_result;
1603 if (status == "2") {
1604 errorCabllback($.extend(errUnknownObj, {
1605 errorType: obj.errorType,
1606 errorText: obj.errorText
1607 }));
1608 } else if (status == "3") {
1609 callback({
1610 result: "success"
1611 });
1612 } else {
1613 window.setTimeout(function () {
1614 getSmsStatusInfo(obj, callback, errorCabllback);
1615 }, 1000);
1616 }
1617 } else {
1618 errorCabllback($.extend(errUnknownObj, {
1619 errorType: obj.errorType,
1620 errorText: obj.errorText
1621 }));
1622 }
1623 }, function (paramD) {
1624 errorCabllback($.extend(errUnknownObj, {
1625 errorType: obj.errorType,
1626 errorText: obj.errorText
1627 }));
1628 }, false);
1629 }
1630 function getSMSReady() {
1631 if (config.smsIsReady) {
1632 var callback = arguments[1];
1633 if (callback) {
1634 return callback({
1635 "sms_cmd": "1",
1636 "sms_cmd_status_result": "3"
1637 });
1638 } else {
1639 return {
1640 "sms_cmd": "1",
1641 "sms_cmd_status_result": "3"
1642 };
1643 }
1644 } else {
1645 return stuffMake(arguments, {}, prepare, deal, null, false);
1646 }
1647 function prepare(values, isPost) {
1648 var valueReq = {};
1649 valueReq.cmd = "sms_cmd_status_info";
1650 valueReq.sms_cmd = 1;
1651 return valueReq;
1652 }
1653 function deal(paramD) {
1654 if (paramD) {
1655 if (paramD.sms_cmd_status_result == "3") {
1656 config.smsIsReady = true;
1657 }
1658 return paramD;
1659 } else {
1660 return errUnknownObj;
1661 }
1662 }
1663 }
1664 function setSmsRead() {
1665 return stuffMake(arguments, {}, prepare, deal, null, true);
1666 function prepare(values, isPost) {
1667 var msgIds = values.ids.join(";");
1668 if (values.ids.length > 0) {
1669 msgIds += ";";
1670 }
1671 var obj = {
1672 goformId: "SET_MSG_READ",
1673 msg_id: msgIds,
1674 tag: 0
1675 };
1676 return obj;
1677 }
1678 function deal(paramD) {
1679 if (paramD.result == "success") {
1680 return {
1681 result: true
1682 };
1683 } else {
1684 return {
1685 result: false
1686 };
1687 }
1688 }
1689 }
1690 function getSMSDeliveryReport() {
1691 return stuffMake(arguments, {}, prepare, deal, {}, false);
1692 function prepare(values, isPost) {
1693 var obj = {
1694 cmd: "sms_status_rpt_data",
1695 page: values.page,
1696 data_per_page: values.smsCount
1697 };
1698 return obj;
1699 }
1700 function deal(paramD) {
1701 if (paramD) {
1702 return {
1703 messages: parseMessages(paramD.messages, true)
1704 };
1705 } else {
1706 return errUnknownObj;
1707 }
1708 }
1709 }
1710 function logout() {
1711 return stuffMake(arguments, {}, prepare, deal, null, true);
1712 function prepare(values, isPost) {
1713 var obj = $.extend({}, values);
1714 obj.goformId = "LOGOUT";
1715 return obj;
1716 }
1717 function deal(paramD) {
1718 if (paramD && paramD.result == "success") {
1719 informationAll.isLoggedIn = false;
1720 return {
1721 result: true
1722 };
1723 } else {
1724 return $.extend(errUnknownObj, {
1725 errorType: "loggedOutError"
1726 });
1727 }
1728 }
1729 }
1730 function changeManageInfo() {
1731 return stuffMake(arguments, {}, prepare, deal, null, true);
1732 function prepare(values, isPost) {
1733 var obj = {};
1734 obj.newPassword = config.PASSWORD_ENCODE ? Base64.encode(values.newValue) : values.newValue;
1735 obj.oldPassword = config.PASSWORD_ENCODE ? Base64.encode(values.oldValue) : values.oldValue;
1736 obj.goformId = "CHANGE_PASSWORD";
1737 return obj;
1738 }
1739 function deal(paramD) {
1740 if (paramD && paramD.result === "success") {
1741 return {
1742 result: true
1743 };
1744 } else {
1745 return $.extend(errUnknownObj, {
1746 errorType: "badPassword"
1747 });
1748 }
1749 }
1750 }
1751 function getPinData() {
1752 return stuffMake(arguments, {}, prepare, deal, null, false);
1753 function prepare(values, isPost) {
1754 var valueReq = {};
1755 valueReq.cmd = "pinnumber,pin_status,puknumber";
1756 valueReq.multi_data = 1;
1757 return valueReq;
1758 }
1759 function deal(paramD) {
1760 if (paramD) {
1761 return paramD;
1762 } else {
1763 return errUnknownObj;
1764 }
1765 }
1766 }
1767 function enablePin() {
1768 return stuffMake(arguments, {}, prepare, deal, null, true);
1769 function prepare(values, isPost) {
1770 var obj = {};
1771 obj.goformId = "ENABLE_PIN";
1772 obj.OldPinNumber = values.oldPin;
1773 return obj;
1774 }
1775 function deal(paramD) {
1776 if (paramD && paramD.result === "success") {
1777 return {
1778 result: true
1779 };
1780 } else {
1781 return {
1782 result: false
1783 };
1784 }
1785 }
1786 }
1787 function disablePin() {
1788 return stuffMake(arguments, {}, prepare, deal, null, true);
1789 function prepare(values, isPost) {
1790 var obj = {};
1791 obj.goformId = "DISABLE_PIN";
1792 obj.OldPinNumber = values.oldPin;
1793 return obj;
1794 }
1795 function deal(paramD) {
1796 if (paramD && paramD.result === "success") {
1797 return {
1798 result: true
1799 };
1800 } else {
1801 return {
1802 result: false
1803 };
1804 }
1805 }
1806 }
1807 function changePin() {
1808 return stuffMake(arguments, {}, prepare, deal, null, true);
1809 function prepare(values, isPost) {
1810 var obj = {};
1811 obj.goformId = "ENABLE_PIN";
1812 obj.OldPinNumber = values.oldPin;
1813 obj.NewPinNumber = values.newPin;
1814 return obj;
1815 }
1816 function deal(paramD) {
1817 if (paramD && paramD.result === "success") {
1818 return {
1819 result: true
1820 };
1821 } else {
1822 return {
1823 result: false
1824 };
1825 }
1826 }
1827 }
1828 function getLanInfo() {
1829 return stuffMake(arguments, {}, prepare, deal, null, false);
1830 function prepare(values, isPost) {
1831 var valueReq = {};
1832 valueReq.cmd = "lan_ipaddr,lan_netmask,mac_address,dhcpEnabled,dhcpStart,dhcpEnd,dhcpLease_hour";
1833 valueReq.multi_data = 1;
1834 return valueReq;
1835 }
1836 function deal(paramD) {
1837 if (paramD) {
1838 var result = {};
1839 result.ipAddress = paramD.lan_ipaddr;
1840 result.subnetMask = paramD.lan_netmask;
1841 result.macAddress = paramD.mac_address;
1842 result.dhcpServer = paramD.dhcpEnabled;
1843 result.dhcpStart = paramD.dhcpStart;
1844 result.dhcpEnd = paramD.dhcpEnd;
1845 result.dhcpLease = parseInt(paramD.dhcpLease_hour, 10);
1846 return result;
1847 } else {
1848 return errUnknownObj;
1849 }
1850 }
1851 }
1852 function setLanInfo() {
1853 return stuffMake(arguments, {}, prepare, deal, null, true);
1854 function prepare(values, isPost) {
1855 var valueReq = {};
1856 valueReq.goformId = "DHCP_SETTING";
1857 valueReq.lanIp = values.ipAddress;
1858 valueReq.lanNetmask = values.subnetMask;
1859 valueReq.lanDhcpType = values.dhcpServer == "1" ? "SERVER" : "DISABLE";
1860 if (valueReq.lanDhcpType == "SERVER") {
1861 valueReq.dhcpStart = values.dhcpStart;
1862 valueReq.dhcpEnd = values.dhcpEnd;
1863 valueReq.dhcpLease = values.dhcpLease;
1864 }
1865 valueReq.dhcp_reboot_flag = 1;
1866 return valueReq;
1867 }
1868 function deal(paramD) {
1869 if (paramD) {
1870 return paramD;
1871 } else {
1872 return errUnknownObj;
1873 }
1874 }
1875 }
1876 function getSmsSetting() {
1877 return stuffMake(arguments, {}, prepare, deal, null, false);
1878 function prepare(values, isPost) {
1879 var valueReq = {};
1880 valueReq.cmd = "sms_parameter_info";
1881 return valueReq;
1882 }
1883 function deal(paramD) {
1884 if (paramD) {
1885 var result = {};
1886 result.centerNumber = paramD.sms_para_sca;
1887 result.memStroe = paramD.sms_para_mem_store;
1888 result.deliveryReport = paramD.sms_para_status_report;
1889 switch (parseInt(paramD.sms_para_validity_period, 10)) {
1890 case 143:
1891 result.validity = "twelve_hours";
1892 break;
1893 case 167:
1894 result.validity = "one_day";
1895 break;
1896 case 173:
1897 result.validity = "one_week";
1898 break;
1899 case 244:
1900 result.validity = "largest";
1901 break;
1902 case 255:
1903 result.validity = "largest";
1904 break;
1905 default:
1906 result.validity = "twelve_hours";
1907 break;
1908 }
1909 return result;
1910 } else {
1911 return errUnknownObj;
1912 }
1913 }
1914 }
1915 function setSmsSetting() {
1916 var callback = arguments[1];
1917 var errorCabllback = arguments[2] ? arguments[2] : callback;
1918 return stuffMake(arguments, {}, prepare, deal, null, true);
1919 function prepare(values, isPost) {
1920 var valueReq = {};
1921 valueReq.goformId = "SET_MESSAGE_CENTER";
1922 valueReq.save_time = values.validity;
1923 valueReq.MessageCenter = values.centerNumber;
1924 valueReq.status_save = values.deliveryReport;
1925 valueReq.save_location = 'native';
1926 valueReq.notCallback = true;
1927 return valueReq;
1928 }
1929 function deal(paramD) {
1930 if (!paramD) {
1931 errorCabllback($.extend(errUnknownObj, {
1932 errorType: "smsSettingFail",
1933 errorText: "error_info"
1934 }));
1935 return;
1936 }
1937 if (paramD.result == "success") {
1938 getSmsStatusInfo({
1939 smsCmd: 3,
1940 errorType: "smsSettingFail",
1941 errorText: "error_info"
1942 }, callback, errorCabllback);
1943 } else {
1944 errorCabllback($.extend(errUnknownObj, {
1945 errorType: "deleteFail",
1946 errorText: "delete_fail_try_again"
1947 }));
1948 }
1949 }
1950 }
1951 function restoreFactorySettings() {
1952 var preErrorObj = {};
1953 if (config.HAS_PARENTAL_CONTROL && config.currentUserInChildGroup != false) {
1954 preErrorObj = {
1955 errorType: 'no_auth'
1956 };
1957 }
1958 return stuffMake(arguments, preErrorObj, prepare, deal, null, true);
1959 function prepare(values, isPost) {
1960 var valueReq = {};
1961 valueReq.goformId = "RESTORE_FACTORY_SETTINGS";
1962 return valueReq;
1963 }
1964 function deal(paramD) {
1965 if (paramD) {
1966 return paramD;
1967 } else {
1968 return errUnknownObj;
1969 }
1970 }
1971 }
1972 function checkRestoreStatus(successCallback) {
1973 var valueReq = {};
1974 valueReq.cmd = "restore_flag";
1975 valueReq.multi_data = 1;
1976 reqAsync(valueReq, function (paramD) {
1977 if (paramD && paramD.restore_flag === "1") {
1978 successCallback();
1979 } else {
1980 setTimeout(function () {
1981 checkRestoreStatus(successCallback);
1982 }, 5000);
1983 }
1984 }, function () {
1985 setTimeout(function () {
1986 checkRestoreStatus(successCallback);
1987 }, 5000);
1988 }, false);
1989 }
1990 function getWpsInfo() {
1991 return stuffMake(arguments, {}, prepare, deal, null, false);
1992 function prepare(values, isPost) {
1993 var valueReq = {};
1994 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";
1995 valueReq.multi_data = 1;
1996 return valueReq;
1997 }
1998 function deal(paramD) {
1999 if (paramD) {
2000 var result = {};
2001 result.wpsFlag = paramD.WscModeOption;
2002 result.authMode = paramD.AuthMode;
2003 result.wpsType = paramD.wps_mode;
2004 result.radioFlag = paramD.wifi_cur_state == "1" ? "1" : "0";
2005 result.encrypType = paramD.EncrypType;
2006 result.wpsSSID = paramD.WPS_SSID;
2007 result.ssidEnable = paramD.m_ssid_enable;
2008 result.ssid = paramD.SSID1;
2009 result.multiSSID = paramD.m_SSID;
2010 result.m_encrypType = paramD.m_EncrypType;
2011 result.wifi_wps_index = paramD.wifi_wps_index;
2012 result.AuthMode = paramD.AuthMode;
2013 result.m_AuthMode = paramD.m_AuthMode;
2014 result.ap_station_enable = paramD.wifi_sta_connection;
2015 return result;
2016 } else {
2017 return errUnknownObj;
2018 }
2019 }
2020 }
2021 function openWps() {
2022 return stuffMake(arguments, {}, prepare, deal, null, true);
2023 function prepare(values, isPost) {
2024 var valueReq = {};
2025 valueReq.goformId = "WIFI_WPS_SET";
2026 valueReq.WPS_SSID = values.wpsSSID;
2027 valueReq.wps_mode = values.wpsType;
2028 valueReq.wifi_wps_index = values.wpsIndex;
2029 if (valueReq.wps_mode == 'PIN') {
2030 valueReq.wps_pin = values.wpsPin;
2031 }
2032 return valueReq;
2033 }
2034 function deal(paramD) {
2035 if (paramD) {
2036 return paramD;
2037 } else {
2038 return errUnknownObj;
2039 }
2040 }
2041 }
2042 function openWps_5g() {
2043 return stuffMake(arguments, {}, prepare, deal, null, true);
2044 function prepare(values, isPost) {
2045 var valueReq = {};
2046 valueReq.goformId = "WIFI_M_WPS_SET";
2047 valueReq.m_WPS_SSID = values.wpsSSID;
2048 valueReq.m_wps_mode = values.wpsType;
2049 valueReq.m_wifi_wps_index = values.wpsIndex;
2050 if (valueReq.m_wps_mode == 'PIN') {
2051 valueReq.m_wps_pin = values.wpsPin;
2052 }
2053 return valueReq;
2054 }
2055 function deal(paramD) {
2056 if (paramD) {
2057 return paramD;
2058 } else {
2059 return errUnknownObj;
2060 }
2061 }
2062 }
2063 function getSleepMode() {
2064 return stuffMake(arguments, {}, prepare, deal, null, false);
2065 function prepare(values, isPost) {
2066 var valueReq = {};
2067 valueReq.cmd = "wifi_sleep_mode,Sleep_interval";
2068 valueReq.multi_data = 1;
2069 return valueReq;
2070 }
2071 function deal(paramD) {
2072 if (paramD) {
2073 var result = {};
2074 result.wifiSleepMode = paramD.wifi_sleep_mode;
2075 result.sleepMode = paramD.Sleep_interval;
2076 return result;
2077 } else {
2078 return errUnknownObj;
2079 }
2080 }
2081 }
2082 function setSleepMode() {
2083 return stuffMake(arguments, {}, prepare, deal, null, true);
2084 function prepare(values, isPost) {
2085 var valueReq = {};
2086 valueReq.goformId = "SET_WIFI_SLEEP_INFO";
2087 valueReq.sysWifiSleepMode = values.wifiSleepMode;
2088 valueReq.sysIdleTimeToSleep = values.sleepMode;
2089 return valueReq;
2090 }
2091 function deal(paramD) {
2092 if (paramD) {
2093 return paramD;
2094 } else {
2095 return errUnknownObj;
2096 }
2097 }
2098 }
2099 function getSysSecurity() {
2100 return stuffMake(arguments, {}, prepare, deal, null, false);
2101 function prepare(values, isPost) {
2102 var valueReq = {};
2103 valueReq.cmd = "RemoteManagement,WANPingFilter";
2104 valueReq.multi_data = 1;
2105 return valueReq;
2106 }
2107 function deal(paramD) {
2108 if (paramD) {
2109 var result = {};
2110 result.remoteFlag = paramD.RemoteManagement == "1" ? "1" : "0";
2111 result.pingFlag = paramD.WANPingFilter == "1" ? "1" : "0";
2112 return result;
2113 } else {
2114 return errUnknownObj;
2115 }
2116 }
2117 }
2118 function setSysSecurity() {
2119 return stuffMake(arguments, {}, prepare, deal, null, true);
2120 function prepare(values, isPost) {
2121 var valueReq = {};
2122 valueReq.goformId = "FW_SYS";
2123 valueReq.remoteManagementEnabled = values.remoteFlag;
2124 valueReq.pingFrmWANFilterEnabled = values.pingFlag;
2125 return valueReq;
2126 }
2127 function deal(paramD) {
2128 if (paramD) {
2129 return paramD;
2130 } else {
2131 return errUnknownObj;
2132 }
2133 }
2134 }
2135 function getPortForward() {
2136 return stuffMake(arguments, {}, prepare, deal, null, false);
2137 function prepare(values, isPost) {
2138 var valueReq = {};
2139 valueReq.cmd = "PortForwardEnable,PortForwardRules_0,PortForwardRules_1,PortForwardRules_2,PortForwardRules_3,PortForwardRules_4,PortForwardRules_5,PortForwardRules_6,PortForwardRules_7,PortForwardRules_8,PortForwardRules_9";
2140 valueReq.multi_data = 1;
2141 return valueReq;
2142 }
2143 function deal(paramD) {
2144 if (paramD) {
2145 var result = {};
2146 result.portForwardEnable = paramD.PortForwardEnable;
2147 var rules = [];
2148 if (paramD.PortForwardRules_0 != "") {
2149 rules.push([0, paramD.PortForwardRules_0]);
2150 }
2151 if (paramD.PortForwardRules_1 != "") {
2152 rules.push([1, paramD.PortForwardRules_1]);
2153 }
2154 if (paramD.PortForwardRules_2 != "") {
2155 rules.push([2, paramD.PortForwardRules_2]);
2156 }
2157 if (paramD.PortForwardRules_3 != "") {
2158 rules.push([3, paramD.PortForwardRules_3]);
2159 }
2160 if (paramD.PortForwardRules_4 != "") {
2161 rules.push([4, paramD.PortForwardRules_4]);
2162 }
2163 if (paramD.PortForwardRules_5 != "") {
2164 rules.push([5, paramD.PortForwardRules_5]);
2165 }
2166 if (paramD.PortForwardRules_6 != "") {
2167 rules.push([6, paramD.PortForwardRules_6]);
2168 }
2169 if (paramD.PortForwardRules_7 != "") {
2170 rules.push([7, paramD.PortForwardRules_7]);
2171 }
2172 if (paramD.PortForwardRules_8 != "") {
2173 rules.push([8, paramD.PortForwardRules_8]);
2174 }
2175 if (paramD.PortForwardRules_9 != "") {
2176 rules.push([9, paramD.PortForwardRules_9]);
2177 }
2178 result.portForwardRules = parsePortForwardRules(rules);
2179 return result;
2180 } else {
2181 return errUnknownObj;
2182 }
2183 }
2184 function parsePortForwardRules(paramD) {
2185 var rules = [];
2186 if (paramD && paramD.length > 0) {
2187 for (var i = 0; i < paramD.length; i++) {
2188 var aRule = {};
2189 var elements = paramD[i][1].split(",");
2190 aRule.index = paramD[i][0];
2191 aRule.ipAddress = elements[0];
2192 aRule.portRange = elements[1] + ' - ' + elements[2];
2193 aRule.protocol = transProtocol(elements[3]);
2194 aRule.comment = elements[4];
2195 rules.push(aRule);
2196 }
2197 }
2198 return rules;
2199 }
2200 }
2201 function setPortForward() {
2202 return stuffMake(arguments, {}, prepare, deal, null, true);
2203 function prepare(values, isPost) {
2204 var valueReq = {};
2205 valueReq.goformId = "FW_FORWARD_ADD";
2206 valueReq.ipAddress = values.ipAddress;
2207 valueReq.portStart = values.portStart;
2208 valueReq.portEnd = values.portEnd;
2209 valueReq.protocol = values.protocol;
2210 valueReq.comment = values.comment;
2211 return valueReq;
2212 }
2213 function deal(paramD) {
2214 if (paramD) {
2215 return paramD;
2216 } else {
2217 return errUnknownObj;
2218 }
2219 }
2220 }
2221 function deleteForwardRules() {
2222 return stuffMake(arguments, {}, prepare, deal, null, true);
2223 function prepare(values, isPost) {
2224 var valueReq = {};
2225 valueReq.goformId = "FW_FORWARD_DEL";
2226 valueReq.delete_id = values.indexs.join(';') + ";";
2227 return valueReq;
2228 }
2229 function deal(paramD) {
2230 if (paramD) {
2231 return paramD;
2232 } else {
2233 return errUnknownObj;
2234 }
2235 }
2236 }
2237 function enableVirtualServer() {
2238 return stuffMake(arguments, {}, prepare, deal, null, true);
2239 function prepare(values, isPost) {
2240 var valueReq = {};
2241 valueReq.goformId = "VIRTUAL_SERVER";
2242 valueReq.PortForwardEnable = values.portForwardEnable;
2243 return valueReq;
2244 }
2245 function deal(paramD) {
2246 if (paramD) {
2247 return paramD;
2248 } else {
2249 return errUnknownObj;
2250 }
2251 }
2252 }
2253 function wifiDecode(fact1,fact2,encode_aes) {//wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes,paramD.m_WPAPSK1_enaes);
2254 var kstr = fact1 + fact2 + "FFFFFFFFFFFFFFFFFFFFFFFF";
2255 var kstr_final;
2256 var kiv_final;
2257
2258 kstr_final = kstr.substring(0, 24);
2259 kiv_final = kstr.substring(0, 16);
2260
2261 var tkey = CryptoJS.enc.Latin1.parse(kstr_final);
2262 var tiv = CryptoJS.enc.Latin1.parse(kiv_final);
2263 var decdata = CryptoJS.AES.decrypt(encode_aes, tkey, {
2264 iv: tiv,
2265 mode: CryptoJS.mode.CBC,
2266 padding: CryptoJS.pad.ZeroPadding
2267 }).toString(CryptoJS.enc.Utf8);
2268
2269 return decdata;
2270 }
2271 function getQuickSettingInfo() {
2272 return stuffMake(arguments, {}, prepare, deal, null, false);
2273 function prepare(values, isPost) {
2274 var valueReq = {};
2275 var wpask = config.PASSWORD_ENCODE ? ",WPAPSK1_encode" : ",imei,rnum_js,WPAPSK1_enaes";
2276 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";
2277 valueReq.multi_data = 1;
2278 return valueReq;
2279 }
2280 function deal(paramD) {
2281 if (paramD) {
2282 if (config.PASSWORD_ENCODE) {
2283 paramD.WPAPSK1 = Base64.decode(paramD.WPAPSK1_encode);
2284 } else {
2285 paramD.WPAPSK1 = wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes);
2286 }
2287 return paramD;
2288 } else {
2289 return errUnknownObj;
2290 }
2291 }
2292 }
2293 function setQuickSetting4IPv6() {
2294 stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
2295 function prepare(values) {
2296 var valueReq = {
2297 goformId: "QUICK_SETUP_EX",
2298 index: values.apn_index,
2299 pdp_type: values.pdp_type,
2300 apn_mode: values.apnMode,
2301 profile_name: values.profile_name,
2302 wan_apn: values.wan_apn,
2303 ppp_auth_mode: values.ppp_auth_mode,
2304 ppp_username: values.ppp_username,
2305 ppp_passtmp: values.ppp_passtmp,
2306 ipv6_wan_apn: values.ipv6_wan_apn,
2307 ipv6_ppp_auth_mode: values.ipv6_ppp_auth_mode,
2308 ipv6_ppp_username: values.ipv6_ppp_username,
2309 ipv6_ppp_passtmp: values.ipv6_ppp_passtmp,
2310 SSID_name: values.SSID_name,
2311 SSID_Broadcast: values.SSID_Broadcast,
2312 Encryption_Mode_hid: values.Encryption_Mode_hid,
2313 security_shared_mode: values.security_shared_mode,
2314 WPA_PreShared_Key: config.PASSWORD_ENCODE ? Base64.encode(values.WPA_PreShared_Key) : values.WPA_PreShared_Key,
2315 wep_default_key: values.wep_default_key,
2316 WPA_ENCRYPTION_hid: values.WPA_ENCRYPTION_hid
2317 }
2318 valueReq.wep_key_1 = values.wep_key_1;
2319 valueReq.wep_key_2 = values.wep_key_2;
2320 valueReq.wep_key_3 = values.wep_key_3;
2321 valueReq.wep_key_4 = values.wep_key_4;
2322 if (values.wep_default_key == '1') {
2323 valueReq.WEP2Select = values.WEP2Select;
2324 } else if (values.wep_default_key == '2') {
2325 valueReq.WEP3Select = values.WEP3Select;
2326 } else if (values.wep_default_key == '3') {
2327 valueReq.WEP4Select = values.WEP4Select;
2328 } else {
2329 valueReq.WEP1Select = values.WEP1Select;
2330 }
2331 return valueReq;
2332 }
2333 function deal(paramD) {
2334 if (paramD) {
2335 return paramD;
2336 } else {
2337 return $.extend(errUnknownObj, {
2338 errorType: "SetSetUpError"
2339 });
2340 }
2341 }
2342 }
2343 function stuffMakeAndCheckServerIsOnline(arg, prepare, deal) {
2344 var isServerOnline = false;
2345 var isCallbackExecuted = false;
2346 var values = prepare(arg[0]);
2347 var callback = arg[1];
2348 var successCallback = function (paramD) {
2349 isServerOnline = true;
2350 if (!isCallbackExecuted && callback) {
2351 callback(deal(paramD));
2352 }
2353 isCallbackExecuted = true;
2354 };
2355 var errorMethod = arg[2];
2356 var errorCallback = function () {
2357 isServerOnline = true;
2358 if (errorMethod) {
2359 errorMethod();
2360 }
2361 };
2362 reqAsync(values, successCallback, errorCallback, true);
2363 addTimeout(function () {
2364 if (isServerOnline == false) {
2365 var timer = addInterval(function () {
2366 if (isServerOnline == false) {
2367 getLanguage({}, function (paramD) {
2368 window.clearInterval(timer);
2369 successCallback({
2370 result: "success"
2371 });
2372 });
2373 }
2374 }, 1000);
2375 }
2376 }, 5000);
2377 }
2378 function getSDConfiguration() {
2379 return stuffMake(arguments, {}, prepare, deal, null, false);
2380 function prepare(values, isPost) {
2381 var valueReq = {
2382 cmd: "sdcard_mode_option,sd_card_state,HTTP_SHARE_STATUS,HTTP_SHARE_WR_AUTH,HTTP_SHARE_FILE",
2383 multi_data: 1
2384 };
2385 return valueReq;
2386 }
2387 function deal(paramD) {
2388 if (paramD) {
2389 var fileToShare;
2390 if ("mmc2" == paramD.HTTP_SHARE_FILE || "/mmc2" == paramD.HTTP_SHARE_FILE || "/mmc2/" == paramD.HTTP_SHARE_FILE) {
2391 fileToShare = "1";
2392 } else {
2393 fileToShare = "0";
2394 }
2395 var result = {
2396 sd_mode: paramD.sdcard_mode_option == "1" ? "0" : "1",
2397 sd_status: paramD.sd_card_state,
2398 share_status: paramD.HTTP_SHARE_STATUS == "Enabled" ? "1" : "0",
2399 share_auth: paramD.HTTP_SHARE_WR_AUTH == "readOnly" ? "0" : "1",
2400 file_to_share: fileToShare,
2401 share_file: paramD.HTTP_SHARE_FILE
2402 };
2403 return result;
2404 } else {
2405 return errUnknownObj;
2406 }
2407 }
2408 }
2409 function setSdCardMode() {
2410 return stuffMake(arguments, {}, prepare, deal, null, true);
2411 function prepare(values, isPost) {
2412 var valueReq = {
2413 goformId: "HTTPSHARE_MODE_SET",
2414 mode_set: values.mode == "0" ? "http_share_mode" : "usb_mode"
2415 };
2416 return valueReq;
2417 }
2418 function deal(paramD) {
2419 if (paramD && paramD.result == 'success') {
2420 return {
2421 result: 'success'
2422 };
2423 } else if (paramD && paramD.result == 'processing') {
2424 return {
2425 result: 'processing'
2426 };
2427 } else {
2428 return {
2429 result: false
2430 };
2431 }
2432 }
2433 }
2434 function checkFileExists() {
2435 return stuffMake(arguments, {}, prepare, deal, null, true);
2436 function prepare(values, isPost) {
2437 var valueReq = {
2438 goformId: "GOFORM_HTTPSHARE_CHECK_FILE",
2439 path_SD_CARD: values.path
2440 };
2441 return valueReq;
2442 }
2443 function deal(paramD) {
2444 if (paramD) {
2445 if (paramD.result == "no_sdcard") {
2446 return {
2447 status: "no_sdcard"
2448 };
2449 } else if (paramD.result == "noexist") {
2450 return {
2451 status: "noexist"
2452 };
2453 } else if (paramD.result == "processing") {
2454 return {
2455 status: "processing"
2456 };
2457 } else {
2458 return {
2459 status: "exist"
2460 };
2461 }
2462 } else {
2463 return errUnknownObj;
2464 }
2465 }
2466 }
2467 function getFileList() {
2468 return stuffMake(arguments, {}, prepare, deal, null, true);
2469 function prepare(values, isPost) {
2470 var valueReq = {
2471 goformId: "HTTPSHARE_ENTERFOLD",
2472 path_SD_CARD: values.path,
2473 indexPage: values.index
2474 };
2475 return valueReq;
2476 }
2477 function deal(paramD) {
2478 if (paramD) {
2479 if (paramD.result == 'failure') {
2480 return $.extend(errUnknownObj, {
2481 errorType: "get_file_list_failure"
2482 });
2483 } else if (paramD.result == "no_sdcard") {
2484 return $.extend(errUnknownObj, {
2485 errorType: "no_sdcard"
2486 });
2487 } else {
2488 return parseSdCardFile(paramD.result);
2489 }
2490 } else {
2491 return errUnknownObj;
2492 }
2493 }
2494 function parseSdCardFile(result) {
2495 var fileInfo = {};
2496 fileInfo.totalRecord = result.totalRecord;
2497 var fileArr = [];
2498 var details = result.fileInfo;
2499 for (var i = 0; details && i < details.length; i++) {
2500 if (details[i].fileName == "") {
2501 continue;
2502 }
2503 var obj = {};
2504 obj.fileName = details[i].fileName;
2505 obj.attribute = details[i].attribute;
2506 obj.size = details[i].size;
2507 obj.lastUpdateTime = details[i].lastUpdateTime;
2508 fileArr.push(obj);
2509 }
2510 fileInfo.details = fileArr;
2511 return fileInfo;
2512 }
2513 }
2514 function fileRename() {
2515 return stuffMake(arguments, {}, prepare, deal, null, true);
2516 function prepare(values, isPost) {
2517 var d = new Date();
2518 var currentTime = d.getTime();
2519 var zoneOffsetSeconds = d.getTimezoneOffset() * 60;
2520 return {
2521 goformId: "HTTPSHARE_FILE_RENAME",
2522 path_SD_CARD: values.path,
2523 OLD_NAME_SD_CARD: values.oldPath,
2524 NEW_NAME_SD_CARD: values.newPath,
2525 path_SD_CARD_time: transUnixTime(currentTime),
2526 path_SD_CARD_time_unix: Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3)
2527 };
2528 }
2529 function deal(paramD) {
2530 if (paramD) {
2531 if (paramD.result == "success") {
2532 return {
2533 result: true
2534 };
2535 } else if (paramD.result == "no_sdcard") {
2536 return $.extend(errUnknownObj, {
2537 errorType: "no_sdcard"
2538 });
2539 } else if (paramD.result == "noexist") {
2540 return $.extend(errUnknownObj, {
2541 errorType: "no_exist"
2542 });
2543 } else if (paramD.result == "processing") {
2544 return $.extend(errUnknownObj, {
2545 errorType: "sd_file_processing_cant_rename"
2546 });
2547 } else {
2548 return {
2549 result: false
2550 };
2551 }
2552 } else {
2553 return errUnknownObj;
2554 }
2555 }
2556 }
2557 function getSdMemorySizes() {
2558 return stuffMake(arguments, {}, prepare, deal, null, false);
2559 function prepare(values, isPost) {
2560 var valueReq = {
2561 cmd: "HTTPSHARE_GETCARD_VALUE"
2562 };
2563 return valueReq;
2564 }
2565 function deal(paramD) {
2566 if (!paramD || (paramD.result && paramD.result == "no_sdcard")) {
2567 return $.extend(errUnknownObj, {
2568 errorType: "no_sdcard"
2569 });
2570 } else {
2571 return {
2572 totalMemorySize: paramD.sd_card_total_size == "" ? 0 : paramD.sd_card_total_size * 32 * 1024,
2573 availableMemorySize: paramD.sd_card_avi_space == "" ? 0 : paramD.sd_card_avi_space * 32 * 1024
2574 };
2575 }
2576 }
2577 }
2578 function deleteFilesAndFolders() {
2579 return stuffMake(arguments, {}, prepare, deal, null, true);
2580 function prepare(values, isPost) {
2581 var currentTime = new Date().getTime();
2582 var valueReq = {
2583 goformId: "HTTPSHARE_DEL",
2584 path_SD_CARD: values.path,
2585 name_SD_CARD: values.names,
2586 path_SD_CARD_time: transUnixTime(currentTime),
2587 path_SD_CARD_time_unix: Math.round(currentTime / 1e3)
2588 };
2589 return valueReq;
2590 }
2591 function deal(paramD) {
2592 if (paramD.result && paramD.result == "failure") {
2593 return {
2594 status: "failure"
2595 };
2596 } else if (paramD.result && paramD.result == "no_sdcard") {
2597 return {
2598 status: "no_sdcard"
2599 };
2600 } else if (paramD.result && paramD.result == "processing") {
2601 return {
2602 status: "processing"
2603 };
2604 } else if (paramD.result && paramD.result == "success") {
2605 return {
2606 status: "success"
2607 };
2608 } else {
2609 return errUnknownObj;
2610 }
2611 }
2612 }
2613 function createFolder() {
2614 return stuffMake(arguments, {}, prepare, deal, null, true);
2615 function prepare(values, isPost) {
2616 var d = new Date();
2617 var currentTime = d.getTime();
2618 var zoneOffsetSeconds = d.getTimezoneOffset() * 60;
2619 return {
2620 goformId: "HTTPSHARE_NEW",
2621 path_SD_CARD: values.path,
2622 path_SD_CARD_time: transUnixTime(currentTime),
2623 path_SD_CARD_time_unix: Math.round((currentTime - zoneOffsetSeconds * 1000) / 1e3)
2624 };
2625 }
2626 function deal(paramD) {
2627 if (paramD.result && paramD.result == "failure") {
2628 return $.extend(errUnknownObj, {
2629 errorType: "create_folder_failure"
2630 });
2631 } else if (paramD.result && paramD.result == "no_sdcard") {
2632 return $.extend(errUnknownObj, {
2633 errorType: "no_sdcard"
2634 });
2635 } else if (paramD.result && paramD.result == "success") {
2636 return {
2637 result: true
2638 };
2639 } else {
2640 return errUnknownObj;
2641 }
2642 }
2643 }
2644 function setSdCardSharing() {
2645 return stuffMake(arguments, {}, prepare, deal, null, true);
2646 function prepare(values, isPost) {
2647 var valueReq = {
2648 goformId: "HTTPSHARE_AUTH_SET",
2649 HTTP_SHARE_STATUS: values.share_status == "1" ? "Enabled" : "Disabled",
2650 HTTP_SHARE_WR_AUTH: values.share_auth == "1" ? "readWrite" : "readOnly",
2651 HTTP_SHARE_FILE: values.share_file
2652 };
2653 return valueReq;
2654 }
2655 function deal(paramD) {
2656 if (paramD) {
2657 if (paramD.result == "no_sdcard") {
2658 return $.extend(errUnknownObj, {
2659 errorType: "no_sdcard"
2660 });
2661 } else {
2662 return {
2663 result: true
2664 };
2665 }
2666 } else {
2667 return errUnknownObj;
2668 }
2669 }
2670 }
2671 function getPortFilter() {
2672 return stuffMake(arguments, {}, prepare, deal, null, false);
2673 function prepare(values, isPost) {
2674 var valueReq = {};
2675 valueReq.cmd = "IPPortFilterEnable,DefaultFirewallPolicy,IPPortFilterRules_0,IPPortFilterRules_1,IPPortFilterRules_2,IPPortFilterRules_3,IPPortFilterRules_4,IPPortFilterRules_5,IPPortFilterRules_6,IPPortFilterRules_7,IPPortFilterRules_8,IPPortFilterRules_9";
2676 valueReq.cmd += ",IPPortFilterRulesv6_0,IPPortFilterRulesv6_1,IPPortFilterRulesv6_2,IPPortFilterRulesv6_3,IPPortFilterRulesv6_4,IPPortFilterRulesv6_5,IPPortFilterRulesv6_6,IPPortFilterRulesv6_7,IPPortFilterRulesv6_8,IPPortFilterRulesv6_9";
2677 valueReq.multi_data = 1;
2678 return valueReq;
2679 }
2680 function deal(paramD) {
2681 if (paramD) {
2682 var result = {};
2683 result.portFilterEnable = paramD.IPPortFilterEnable;
2684 result.defaultPolicy = paramD.DefaultFirewallPolicy;
2685 var rules = [];
2686 if (paramD.IPPortFilterRules_0 != "") {
2687 rules.push([0, paramD.IPPortFilterRules_0]);
2688 }
2689 if (paramD.IPPortFilterRules_1 != "") {
2690 rules.push([1, paramD.IPPortFilterRules_1]);
2691 }
2692 if (paramD.IPPortFilterRules_2 != "") {
2693 rules.push([2, paramD.IPPortFilterRules_2]);
2694 }
2695 if (paramD.IPPortFilterRules_3 != "") {
2696 rules.push([3, paramD.IPPortFilterRules_3]);
2697 }
2698 if (paramD.IPPortFilterRules_4 != "") {
2699 rules.push([4, paramD.IPPortFilterRules_4]);
2700 }
2701 if (paramD.IPPortFilterRules_5 != "") {
2702 rules.push([5, paramD.IPPortFilterRules_5]);
2703 }
2704 if (paramD.IPPortFilterRules_6 != "") {
2705 rules.push([6, paramD.IPPortFilterRules_6]);
2706 }
2707 if (paramD.IPPortFilterRules_7 != "") {
2708 rules.push([7, paramD.IPPortFilterRules_7]);
2709 }
2710 if (paramD.IPPortFilterRules_8 != "") {
2711 rules.push([8, paramD.IPPortFilterRules_8]);
2712 }
2713 if (paramD.IPPortFilterRules_9 != "") {
2714 rules.push([9, paramD.IPPortFilterRules_9]);
2715 }
2716 result.portFilterRules = parsePortFilterRules(rules, "IPv4");
2717 var v6Rules = [];
2718 if (paramD.IPPortFilterRulesv6_0 != "") {
2719 v6Rules.push([10, paramD.IPPortFilterRulesv6_0]);
2720 }
2721 if (paramD.IPPortFilterRulesv6_1 != "") {
2722 v6Rules.push([11, paramD.IPPortFilterRulesv6_1]);
2723 }
2724 if (paramD.IPPortFilterRulesv6_2 != "") {
2725 v6Rules.push([12, paramD.IPPortFilterRulesv6_2]);
2726 }
2727 if (paramD.IPPortFilterRulesv6_3 != "") {
2728 v6Rules.push([13, paramD.IPPortFilterRulesv6_3]);
2729 }
2730 if (paramD.IPPortFilterRulesv6_4 != "") {
2731 v6Rules.push([14, paramD.IPPortFilterRulesv6_4]);
2732 }
2733 if (paramD.IPPortFilterRulesv6_5 != "") {
2734 v6Rules.push([15, paramD.IPPortFilterRulesv6_5]);
2735 }
2736 if (paramD.IPPortFilterRulesv6_6 != "") {
2737 v6Rules.push([16, paramD.IPPortFilterRulesv6_6]);
2738 }
2739 if (paramD.IPPortFilterRulesv6_7 != "") {
2740 v6Rules.push([17, paramD.IPPortFilterRulesv6_7]);
2741 }
2742 if (paramD.IPPortFilterRulesv6_8 != "") {
2743 v6Rules.push([18, paramD.IPPortFilterRulesv6_8]);
2744 }
2745 if (paramD.IPPortFilterRulesv6_9 != "") {
2746 v6Rules.push([19, paramD.IPPortFilterRulesv6_9]);
2747 }
2748 result.portFilterRules = _.union(result.portFilterRules, parsePortFilterRules(v6Rules, "IPv6"));
2749 return result;
2750 } else {
2751 return errUnknownObj;
2752 }
2753 }
2754 function parsePortFilterRules(paramD, ipTypeTmp) {
2755 var rules = [];
2756 if (paramD && paramD.length > 0) {
2757 for (var i = 0; i < paramD.length; i++) {
2758 var aRule = {};
2759 var elements = paramD[i][1].split(",");
2760 aRule.index = paramD[i][0];
2761 aRule.macAddress = elements[11];
2762 aRule.destIpAddress = elements[4] == "any/0" ? "" : elements[4];
2763 aRule.sourceIpAddress = elements[0] == "any/0" ? "" : elements[0];
2764 aRule.destPortRange = elements[6] == '0' ? '' : elements[6] + " - " + elements[7];
2765 aRule.sourcePortRange = elements[2] == '0' ? '' : elements[2] + " - " + elements[3];
2766 aRule.action = elements[9] == 1 ? "filter_accept" : "filter_drop";
2767 aRule.protocol = transProtocol(elements[8]);
2768 aRule.comment = elements[10];
2769 aRule.ipType = ipTypeTmp;
2770 rules.push(aRule);
2771 }
2772 }
2773 return rules;
2774 }
2775 }
2776 function setPortFilterBasic() {
2777 return stuffMake(arguments, {}, prepare, deal, null, true);
2778 function prepare(values, isPost) {
2779 var valueReq = {};
2780 valueReq.goformId = "BASIC_SETTING";
2781 valueReq.portFilterEnabled = values.portFilterEnable;
2782 valueReq.defaultFirewallPolicy = values.defaultPolicy;
2783 return valueReq;
2784 }
2785 function deal(paramD) {
2786 if (paramD) {
2787 return paramD;
2788 } else {
2789 return errUnknownObj;
2790 }
2791 }
2792 }
2793 function setPortFilter() {
2794 return stuffMake(arguments, {}, prepare, deal, null, true);
2795 function prepare(values, isPost) {
2796 var valueReq = {};
2797 valueReq.goformId = "ADD_IP_PORT_FILETER_V4V6";
2798 valueReq.ip_version = values.ipType;
2799 valueReq.mac_address = values.macAddress;
2800 valueReq.dip_address = values.destIpAddress;
2801 valueReq.sip_address = values.sourceIpAddress;
2802 valueReq.dFromPort = values.destPortStart;
2803 valueReq.dToPort = values.destPortEnd;
2804 valueReq.sFromPort = values.sourcePortStart;
2805 valueReq.sToPort = values.sourcePortEnd;
2806 valueReq.action = values.action;
2807 valueReq.protocol = values.protocol;
2808 valueReq.comment = values.comment;
2809 return valueReq;
2810 }
2811 function deal(paramD) {
2812 if (paramD) {
2813 return paramD;
2814 } else {
2815 return errUnknownObj;
2816 }
2817 }
2818 }
2819 function deleteFilterRules() {
2820 return stuffMake(arguments, {}, prepare, deal, null, true);
2821 function prepare(values, isPost) {
2822 var valueReq = {};
2823 var deleteIds = _.filter(values.indexs, function (item) {
2824 return item.length == 1;
2825 });
2826 valueReq.goformId = "DEL_IP_PORT_FILETER_V4V6";
2827 var deletev6Ids = [];
2828 _.each(values.indexs, function (item) {
2829 if (item.length == 2) {
2830 deletev6Ids.push(item.substring(1));
2831 }
2832 });
2833 valueReq.delete_id_v6 = deletev6Ids.length > 0 ? deletev6Ids.join(';') + ";" : "";
2834 valueReq.delete_id = deleteIds.length > 0 ? deleteIds.join(';') + ";" : "";
2835 return valueReq;
2836 }
2837 function deal(paramD) {
2838 if (paramD) {
2839 return paramD;
2840 } else {
2841 return errUnknownObj;
2842 }
2843 }
2844 }
2845 function getWifiAdvance() {
2846 return stuffMake(arguments, {}, prepare, deal, null, false);
2847 function prepare(values, isPost) {
2848 var valueReq = {};
2849 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";
2850 valueReq.multi_data = 1;
2851 return valueReq;
2852 }
2853 function deal(paramD) {
2854 if (paramD) {
2855 var result = {
2856 mode: paramD.WirelessMode,
2857 countryCode: paramD.CountryCode,
2858 channel: paramD.Channel,
2859 rate: paramD.HT_MCS,
2860 wifiBand: paramD.wifi_band == 'a' ? 'a' : 'b',
2861 bandwidth: paramD.wifi_11n_cap,
2862 MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,
2863 MAX_Access_num: paramD.MAX_Access_num,
2864 m_MAX_Access_num: paramD.m_MAX_Access_num,
2865 ap_station_enable: paramD.wifi_sta_connection
2866 };
2867 return result;
2868 } else {
2869 return errUnknownObj;
2870 }
2871 }
2872 }
2873 function setWifiAdvance() {
2874 stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
2875 function prepare(values) {
2876 var valueReq = {
2877 goformId: "SET_WIFI_INFO",
2878 wifiMode: values.mode,
2879 countryCode: values.countryCode,
2880 MAX_Access_num: values.station,
2881 m_MAX_Access_num: values.m_station
2882 };
2883 if (config.WIFI_BAND_SUPPORT) {
2884 valueReq.wifi_band = values.wifiBand;
2885 }
2886 if (config.WIFI_BAND_SUPPORT && values.wifiBand == 'a') {
2887 valueReq.selectedChannel = 'auto';
2888 } else {
2889 valueReq.selectedChannel = values.channel;
2890 valueReq.abg_rate = values.rate;
2891 }
2892 if (config.WIFI_BANDWIDTH_SUPPORT) {
2893 valueReq.wifi_11n_cap = values.bandwidth;
2894 }
2895 return valueReq;
2896 }
2897 function deal(paramD) {
2898 if (paramD) {
2899 return paramD;
2900 } else {
2901 return errUnknownObj;
2902 }
2903 }
2904 }
2905 function getDeviceInfo() {
2906 return stuffMake(arguments, {}, prepare, deal, null, false);
2907 function prepare(values, isPost) {
2908 var wpask = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";
2909 var valueReq = {
mj.qu457a30a2025-01-06 18:02:38 -08002910 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",
qumengjia1cd76022024-10-31 17:51:04 +08002911 multi_data: 1
2912 };
2913 return valueReq;
2914 }
2915 function deal(paramD) {
2916 if (paramD) {
2917 return {
2918 ssid: paramD.SSID1,
2919 authMode: paramD.AuthMode,
2920 passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),
2921 m_ssid: paramD.m_SSID,
2922 m_AuthMode: paramD.m_AuthMode,
2923 m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),
2924 m_max_access_num: paramD.m_MAX_Access_num,
2925 multi_ssid_enable: paramD.m_ssid_enable,
2926 ipAddress: paramD.lan_ipaddr,
2927 wanIpAddress: paramD.wan_ipaddr,
2928 staticWanIpAddress: paramD.static_wan_ipaddr,
2929 ipv6WanIpAddress: paramD.ipv6_wan_ipaddr,
2930 ipv6PdpType: paramD.ipv6_pdp_type,
2931 macAddress: paramD.mac_address,
2932 simSerialNumber: paramD.msisdn,
2933 lanDomain: paramD.LocalDomain,
2934 imei: paramD.imei,
2935 signal: convertSignal(paramD),
2936 imsi: paramD.imsi || paramD.sim_imsi,
mj.qu39da3602025-01-06 01:36:47 -08002937 iccid: paramD.ziccid,
mj.qu457a30a2025-01-06 18:02:38 -08002938 cellid: paramD.cell_id,
qumengjia1cd76022024-10-31 17:51:04 +08002939 sw_version: paramD.cr_version,
2940 hw_version: paramD.hw_version,
2941 max_access_num: paramD.MAX_Access_num,
2942 wifiRange: paramD.wifi_coverage,
2943 pdpType: paramD.pdp_type,
2944 rj45ConnectStatus: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state,
2945 blc_wan_mode: informationAll.blc_wan_mode,
2946 connectStatus: paramD.ppp_status,
2947 wifiConStatus: paramD.sta_ip_status,
2948 ethwan_mode: paramD.ethwan_mode.toUpperCase()
2949 };
2950 } else {
2951 return errUnknownObj;
2952 }
2953 }
2954 }
2955 function getDeviceInfoLow() {
2956 return stuffMake(arguments, {}, prepare, deal, null, false);
2957 function prepare(values, isPost) {
2958 var valueReq = {
2959 cmd: "imei,rnum_js",
2960 multi_data: 1
2961 };
2962 return valueReq;
2963 }
2964 function deal(paramD) {
2965 if (paramD) {
2966 var kstr = paramD.rnum_js + paramD.imei + "FFFFFFFFFFFFFFFFFFFFFFFF";
2967 var kstr_final;
2968 var kiv_final;
2969
2970 kstr_final = kstr.substring(0, 24);
2971 kiv_final = kstr.substring(0, 16);
2972
2973 return {
2974 skey: kstr_final,
2975 siv: kiv_final
2976 };
2977 } else {
2978
2979 return {
2980 skey: "FFFFFFFFFFFFFFFFFFFFFFFF",
2981 siv: "FFFFFFFFFFFFFFFF"
2982 };
2983 }
2984 }
2985 }
2986 function getWifiRange() {
2987 return stuffMake(arguments, {}, prepare, deal, null, false);
2988 function prepare(values, isPost) {
2989 var valueReq = {};
2990 valueReq.cmd = "wifi_coverage";
2991 return valueReq;
2992 }
2993 function deal(paramD) {
2994 if (paramD) {
2995 var result = {};
2996 result.wifiRangeMode = paramD.wifi_coverage;
2997 return result;
2998 } else {
2999 return errUnknownObj;
3000 }
3001 }
3002 }
3003 function setWifiRange() {
3004 return stuffMake(arguments, {}, prepare, deal, null, true);
3005 function prepare(values, isPost) {
3006 var valueReq = {};
3007 valueReq.goformId = "SET_WIFI_COVERAGE";
3008 valueReq.wifi_coverage = values.wifiRangeMode;
3009 return valueReq;
3010 }
3011 function deal(paramD) {
3012 if (paramD) {
3013 return paramD;
3014 } else {
3015 return errUnknownObj;
3016 }
3017 }
3018 }
3019 function getUpnpSetting() {
3020 return stuffMake(arguments, {}, prepare, deal, null, false);
3021 function prepare(values, isPost) {
3022 var valueReq = {};
3023 valueReq.cmd = "upnpEnabled";
3024 valueReq.multi_data = 1;
3025 return valueReq;
3026 }
3027 function deal(paramD) {
3028 if (paramD) {
3029 var result = {};
3030 result.upnpSetting = paramD.upnpEnabled == "1" ? "1" : "0";
3031 return result;
3032 } else {
3033 return errUnknownObj;
3034 }
3035 }
3036 }
3037 function setUpnpSetting() {
3038 return stuffMake(arguments, {}, prepare, deal, null, true);
3039 function prepare(values, isPost) {
3040 var valueReq = {};
3041 valueReq.goformId = "UPNP_SETTING";
3042 valueReq.upnp_setting_option = values.upnpSetting;
3043 return valueReq;
3044 }
3045 function deal(paramD) {
3046 if (paramD) {
3047 return paramD;
3048 } else {
3049 return errUnknownObj;
3050 }
3051 }
3052 }
3053 function getDmzSetting() {
3054 return stuffMake(arguments, {}, prepare, deal, null, false);
3055 function prepare(values, isPost) {
3056 var valueReq = {};
3057 valueReq.cmd = "DMZEnable,DMZIPAddress";
3058 valueReq.multi_data = 1;
3059 return valueReq;
3060 }
3061 function deal(paramD) {
3062 if (paramD) {
3063 var result = {};
3064 result.dmzSetting = paramD.DMZEnable == "1" ? "1" : "0";
3065 result.ipAddress = paramD.DMZIPAddress;
3066 return result;
3067 } else {
3068 return errUnknownObj;
3069 }
3070 }
3071 }
3072 function setDmzSetting() {
3073 return stuffMake(arguments, {}, prepare, deal, null, true);
3074 function prepare(values, isPost) {
3075 var valueReq = {};
3076 valueReq.goformId = "DMZ_SETTING";
3077 valueReq.DMZEnabled = values.dmzSetting;
3078 if (valueReq.DMZEnabled == '1') {
3079 valueReq.DMZIPAddress = values.ipAddress;
3080 }
3081 return valueReq;
3082 }
3083 function deal(paramD) {
3084 if (paramD) {
3085 return paramD;
3086 } else {
3087 return errUnknownObj;
3088 }
3089 }
3090 }
3091 function getPortMap() {
3092 return stuffMake(arguments, {}, prepare, deal, null, false);
3093 function prepare(values, isPost) {
3094 var valueReq = {};
3095 valueReq.cmd = "PortMapEnable,PortMapRules_0,PortMapRules_1,PortMapRules_2,PortMapRules_3,PortMapRules_4,PortMapRules_5,PortMapRules_6,PortMapRules_7,PortMapRules_8,PortMapRules_9",
3096 valueReq.multi_data = 1;
3097 return valueReq;
3098 }
3099 function deal(paramD) {
3100 if (paramD) {
3101 var result = {};
3102 result.portMapEnable = paramD.PortMapEnable;
3103 var rules = [];
3104 if (paramD.PortMapRules_0 != "") {
3105 rules.push([0, paramD.PortMapRules_0]);
3106 }
3107 if (paramD.PortMapRules_1 != "") {
3108 rules.push([1, paramD.PortMapRules_1]);
3109 }
3110 if (paramD.PortMapRules_2 != "") {
3111 rules.push([2, paramD.PortMapRules_2]);
3112 }
3113 if (paramD.PortMapRules_3 != "") {
3114 rules.push([3, paramD.PortMapRules_3]);
3115 }
3116 if (paramD.PortMapRules_4 != "") {
3117 rules.push([4, paramD.PortMapRules_4]);
3118 }
3119 if (paramD.PortMapRules_5 != "") {
3120 rules.push([5, paramD.PortMapRules_5]);
3121 }
3122 if (paramD.PortMapRules_6 != "") {
3123 rules.push([6, paramD.PortMapRules_6]);
3124 }
3125 if (paramD.PortMapRules_7 != "") {
3126 rules.push([7, paramD.PortMapRules_7]);
3127 }
3128 if (paramD.PortMapRules_8 != "") {
3129 rules.push([8, paramD.PortMapRules_8]);
3130 }
3131 if (paramD.PortMapRules_9 != "") {
3132 rules.push([9, paramD.PortMapRules_9]);
3133 }
3134 result.portMapRules = parsePortMapRules(rules);
3135 return result;
3136 } else {
3137 return errUnknownObj;
3138 }
3139 }
3140 function parsePortMapRules(paramD) {
3141 var rules = [];
3142 if (paramD && paramD.length > 0) {
3143 for (var i = 0; i < paramD.length; i++) {
3144 var aRule = {};
3145 var elements = paramD[i][1].split(",");
3146 aRule.index = paramD[i][0];
3147 aRule.sourcePort = elements[1];
3148 aRule.destIpAddress = elements[0];
3149 aRule.destPort = elements[2];
3150 aRule.protocol = transProtocol(elements[3]);
3151 aRule.comment = elements[4];
3152 rules.push(aRule);
3153 }
3154 }
3155 return rules;
3156 }
3157 }
3158 function setPortMap() {
3159 return stuffMake(arguments, {}, prepare, deal, null, true);
3160 function prepare(values, isPost) {
3161 var valueReq = {};
3162 valueReq.goformId = "ADD_PORT_MAP";
3163 valueReq.portMapEnabled = values.portMapEnable;
3164 valueReq.fromPort = values.sourcePort;
3165 valueReq.ip_address = values.destIpAddress;
3166 valueReq.toPort = values.destPort;
3167 valueReq.protocol = values.protocol;
3168 valueReq.comment = values.comment;
3169 return valueReq;
3170 }
3171 function deal(paramD) {
3172 if (paramD) {
3173 return paramD;
3174 } else {
3175 return errUnknownObj;
3176 }
3177 }
3178 }
3179 function enablePortMap() {
3180 return stuffMake(arguments, {}, prepare, deal, null, true);
3181 function prepare(values, isPost) {
3182 var valueReq = {};
3183 valueReq.goformId = "ADD_PORT_MAP";
3184 valueReq.portMapEnabled = values.portMapEnable;
3185 return valueReq;
3186 }
3187 function deal(paramD) {
3188 if (paramD) {
3189 return paramD;
3190 } else {
3191 return errUnknownObj;
3192 }
3193 }
3194 }
3195 function deleteMapRules() {
3196 return stuffMake(arguments, {}, prepare, deal, null, true);
3197 function prepare(values, isPost) {
3198 var valueReq = {};
3199 valueReq.goformId = "DEL_PORT_MAP";
3200 valueReq.delete_id = values.indexs.join(';') + ";";
3201 return valueReq;
3202 }
3203 function deal(paramD) {
3204 if (paramD) {
3205 return paramD;
3206 } else {
3207 return errUnknownObj;
3208 }
3209 }
3210 }
3211 function getTrafficAlertInfo() {
3212 return stuffMake(arguments, {}, prepare, deal, null, false);
3213 function prepare(values, isPost) {
3214 return {
3215 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",
3216 multi_data: 1
3217 };
3218 }
3219 function deal(paramD) {
3220 if (paramD) {
3221 var isData = paramD.data_volume_limit_unit == 'data';
3222 var result = {
3223 dataLimitChecked: paramD.data_volume_limit_switch,
3224 dataLimitTypeChecked: isData ? '1' : '0',
3225 limitDataMonth: isData ? paramD.data_volume_limit_size : '0',
3226 alertDataReach: isData ? paramD.data_volume_alert_percent : '0',
3227 limitTimeMonth: isData ? '0' : paramD.data_volume_limit_size,
3228 alertTimeReach: isData ? '0' : paramD.data_volume_alert_percent,
3229 monthlySent: paramD.monthly_tx_bytes == '' ? 0 : paramD.monthly_tx_bytes,
3230 monthlyReceived: paramD.monthly_rx_bytes == '' ? 0 : paramD.monthly_rx_bytes,
3231 monthlyConnectedTime: paramD.monthly_time == '' ? 0 : paramD.monthly_time,
3232 traffic_alined_delta: paramD.traffic_alined_delta == '' ? 0 : paramD.traffic_alined_delta
3233 };
3234 return result;
3235 } else {
3236 return errUnknownObj;
3237 }
3238 }
3239 }
3240 function setTrafficAlertInfo() {
3241 return stuffMake(arguments, {}, prepare, deal, null, true);
3242 function prepare(values, isPost) {
3243 var isData = values.dataLimitTypeChecked == '1';
3244 var valueReq = {
3245 goformId: "DATA_LIMIT_SETTING",
3246 data_volume_limit_switch: values.dataLimitChecked
3247 };
3248 if (values.dataLimitChecked == '1') {
3249 valueReq.data_volume_limit_unit = isData ? 'data' : 'time';
3250 valueReq.data_volume_limit_size = isData ? values.limitDataMonth : values.limitTimeMonth;
3251 valueReq.data_volume_alert_percent = isData ? values.alertDataReach : values.alertTimeReach;
3252 }
3253 return valueReq;
3254 }
3255 function deal(paramD) {
3256 if (paramD) {
3257 return paramD;
3258 } else {
3259 return errUnknownObj;
3260 }
3261 }
3262 }
3263 function getUSSDResponse() {
3264 var callback = arguments[1];
3265 return stuffMake(arguments, {}, prepare, deal, null, true);
3266 function prepare(values, isPost) {
3267 if (values.sendOrReply == "send") {
3268 return {
3269 goformId: "USSD_PROCESS",
3270 USSD_operator: values.operator,
3271 USSD_send_number: values.strUSSDCommand,
3272 notCallback: true
3273 };
3274 } else if (values.sendOrReply == "reply") {
3275 return {
3276 goformId: "USSD_PROCESS",
3277 USSD_operator: values.operator,
3278 USSD_reply_number: values.strUSSDCommand,
3279 notCallback: true
3280 };
3281 }
3282 }
3283 function deal(paramD) {
3284 if (!paramD) {
3285 callback(false, "ussd_fail");
3286 return;
3287 }
3288 if (paramD.result == "success") {
3289 callbackTemp = callback;
3290 getResponse();
3291 } else {
3292 callback(false, "ussd_fail");
3293 }
3294 }
3295 }
3296 function getResponse() {
3297 $.ajax({
3298 url: "/reqproc/proc_get",
3299 data: {
3300 cmd: "ussd_write_flag"
3301 },
3302 cache: false,
3303 async: true,
3304 dataType: "json",
3305 success: function (result) {
3306 if (result.ussd_write_flag == "1") {
3307 callbackTemp(false, "ussd_no_service");
3308 } else if (result.ussd_write_flag == "4" || result.ussd_write_flag == "unknown" || result.ussd_write_flag == "3") {
3309 callbackTemp(false, "ussd_timeout");
3310 } else if (result.ussd_write_flag == "15") {
3311 setTimeout(getResponse, 1000);
3312 } else if (result.ussd_write_flag == "10") {
3313 callbackTemp(false, "ussd_retry");
3314 } else if (result.ussd_write_flag == "99") {
3315 callbackTemp(false, "ussd_unsupport");
3316 } else if (result.ussd_write_flag == "41") {
3317 callbackTemp(false, "operation_not_supported");
3318 } else if (result.ussd_write_flag == "2") {
3319 callbackTemp(false, "network_terminated");
3320 } else if (result.ussd_write_flag == "16") {
3321 $.ajax({
3322 url: "/reqproc/proc_get",
3323 data: {
3324 cmd: "ussd_data_info"
3325 },
3326 dataType: "json",
3327 async: true,
3328 cache: false,
3329 success: function (paramD) {
3330 var content = {};
3331 content.data = paramD.ussd_data;
3332 content.ussd_action = paramD.ussd_action;
3333 content.ussd_dcs = paramD.ussd_dcs;
3334 callbackTemp(true, content);
3335 },
3336 error: function () {
3337 callbackTemp(false, "ussd_info_error");
3338 }
3339 });
3340 } else {
3341 callbackTemp(false, "ussd_fail");
3342 }
3343 },
3344 error: function () {
3345 callbackTemp(false, "ussd_fail");
3346 }
3347 });
3348 }
3349 function USSDReplyCancel(callback) {
3350 $.ajax({
3351 url: "/reqproc/proc_post",
3352 data: {
3353 goformId: "USSD_PROCESS",
3354 USSD_operator: "ussd_cancel"
3355 },
3356 cache: false,
3357 dataType: "json",
3358 success: function (paramD) {
3359 if (paramD.result == "success") {
3360 getCancelResponse();
3361 } else {
3362 callback(false);
3363 }
3364 }
3365 });
3366 function getCancelResponse() {
3367 $.ajax({
3368 url: "/reqproc/proc_get",
3369 data: {
3370 cmd: "ussd_write_flag"
3371 },
3372 cache: false,
3373 async: true,
3374 dataType: "json",
3375 success: function (result) {
3376 if (result.ussd_write_flag == "15") {
3377 setTimeout(getCancelResponse, 1000);
3378 } else if (result.ussd_write_flag == "13") {
3379 callback(true);
3380 } else {
3381 callback(false);
3382 }
3383 },
3384 error: function () {
3385 callback(false);
3386 }
3387 });
3388 }
3389 }
3390 function unlockNetwork() {
3391 var callback = arguments[1];
3392 var checkPoint = 0;
3393 return stuffMake(arguments, {}, prepare, deal, null, true);
3394 function prepare(values) {
3395 return {
3396 goformId: "UNLOCK_NETWORK",
3397 notCallback: true,
3398 unlock_network_code: values.unlock_network_code
3399 };
3400 }
3401 function deal(paramD) {
3402 if (paramD && paramD.result == "success") {
3403 addCallback(checkUnlockNetworkStatus);
3404 } else {
3405 callback({
3406 result: 'fail'
3407 });
3408 }
3409 }
3410 function checkUnlockNetworkStatus() {
3411 if (checkPoint > 5) {
3412 removeCallback(checkUnlockNetworkStatus);
3413 callback({
3414 result: 'fail'
3415 });
3416 } else if (informationAll.simStatus != 'modem_imsi_waitnck') {
3417 removeCallback(checkUnlockNetworkStatus);
3418 callback({
3419 result: 'success'
3420 });
3421 }
3422 checkPoint++;
3423 }
3424 }
3425 function getNetworkUnlockTimes() {
3426 return stuffMake(arguments, {}, prepare, deal, null, false);
3427 function prepare(values, isPost) {
3428 return {
3429 cmd: "unlock_nck_time"
3430 };
3431 }
3432 function deal(paramD) {
3433 if (paramD) {
3434 return paramD;
3435 } else {
3436 return errUnknownObj;
3437 }
3438 }
3439 }
3440 function setUpdateInfoWarning() {
3441 var callback = arguments[1];
3442 return stuffMake(arguments, {}, prepare, deal, null, true);
3443 function prepare(values) {
3444 return {
3445 goformId: "SET_UPGRADE_NOTICE",
3446 upgrade_notice_flag: values.upgrade_notice_flag,
3447 notCallback: true
3448 };
3449 }
3450 function deal(paramD) {
3451 if (paramD.result == "success") {
3452 callback(true);
3453 } else {
3454 callback(false);
3455 }
3456 }
3457 }
3458 function getUpdateInfoWarning() {
3459 return stuffMake(arguments, {}, prepare, deal, null, false);
3460 function prepare(values, isPost) {
3461 return {
3462 cmd: "upgrade_notice_flag"
3463 };
3464 }
3465 function deal(paramD) {
3466 if (paramD) {
3467 return paramD;
3468 } else {
3469 return errUnknownObj;
3470 }
3471 }
3472 }
3473 function getAPStationBasic() {
3474 return stuffMake(arguments, {}, prepare, deal, null, false);
3475 function prepare(values, isPost) {
3476 return {
3477 multi_data: 1,
3478 cmd: "wifi_sta_connection,pswan_priority,wifiwan_priority,ethwan_priority"
3479 };
3480 }
3481 function deal(paramD) {
3482 if (paramD) {
3483 return {
3484 ap_station_enable: paramD.wifi_sta_connection,
3485 ap_station_mode: parseInt(paramD.wifiwan_priority, 10) > parseInt(paramD.pswan_priority, 10) ? "wifi_pref" : "dial_pref"
3486 }
3487 } else {
3488 return errUnknownObj;
3489 }
3490 }
3491 }
3492 function setAPStationBasic() {
3493 var tmp = arguments[0];
3494 return stuffMake(arguments, {}, prepare, deal, null, true);
3495 function prepare(values) {
3496 return {
3497 goformId: "WIFI_STA_CONTROL",
3498 wifi_sta_connection: values.ap_station_enable
3499 };
3500 }
3501 function deal(paramD) {
3502 if (paramD && paramD.result == "success") {
3503 informationAll.ap_station_enable = tmp.ap_station_enable == 1;
3504 return paramD;
3505 } else {
3506 return errUnknownObj;
3507 }
3508 }
3509 }
3510 function refreshAPStationStatus() {
3511 return getAPStationBasic({}, function (paramD) {
3512 informationAll.ap_station_enable = paramD.ap_station_enable == 1;
3513 informationAll.ap_station_mode = paramD.ap_station_mode;
3514 });
3515 }
3516 function getHotspotList() {
3517 return stuffMake(arguments, {}, prepare, deal, null, false);
3518 function prepare(values, isPost) {
3519 var cmdStr = "wifi_profile_num,wifi_profile";
3520 for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
3521 cmdStr = cmdStr + ",wifi_profile" + i;
3522 }
3523 return {
3524 multi_data: 1,
3525 cmd: cmdStr
3526 };
3527 }
3528 function deal(paramD) {
3529 if (paramD) {
3530 var wifiList = [];
3531 for (var i = 0; i < config.AP_STATION_LIST_LENGTH; i++) {
3532 var wifiStr = "";
3533 if (i == 0) {
3534 wifiStr = paramD.wifi_profile;
3535 } else {
3536 wifiStr = paramD["wifi_profile" + i];
3537 }
3538 var wifiArray = wifiStr.split(";");
3539 for (var j = 0; j < wifiArray.length; j++) {
3540 var item = wifiArray[j].split(",");
3541 if (!item[0]) {
3542 break;
3543 }
3544 var wifiJson = {
3545 profileName: item[0],
3546 fromProvider: item[1],
3547 connectStatus: item[2],
3548 signal: item[3],
3549 ssid: item[4],
3550 authMode: item[5],
3551 encryptType: item[6],
3552 password: item[7] == "0" ? "" : item[7],
3553 keyID: item[8],
3554 mac: item[9]
3555 };
3556 wifiList.push(wifiJson);
3557 }
3558 }
3559 return {
3560 hotspotList: wifiList
3561 };
3562 } else {
3563 return errUnknownObj;
3564 }
3565 }
3566 }
3567 function searchHotspot() {
3568 return stuffMake(arguments, {}, prepare, deal, null, true);
3569 function prepare(values) {
3570 return {
3571 goformId: "WLAN_SET_STA_REFRESH"
3572 };
3573 }
3574 function deal(paramD) {
3575 if (paramD) {
3576 return paramD;
3577 } else {
3578 return errUnknownObj;
3579 }
3580 }
3581 }
3582 function getSearchHotspotList() {
3583 return stuffMake(arguments, {}, prepare, deal, null, false);
3584 function prepare(values, isPost) {
3585 return {
3586 multi_data: 1,
3587 cmd: "scan_finish,EX_APLIST,EX_APLIST1"
3588 }
3589 }
3590 function deal(paramD) {
3591 if (paramD) {
3592 if (paramD.scan_finish == "0") {
3593 return {
3594 scan_finish: "0",
3595 hotspotList: []
3596 };
3597 }
3598 if (paramD.scan_finish == "2") {
3599 return {
3600 scan_finish: "2",
3601 hotspotList: []
3602 };
3603 }
3604 var wifiList = [];
3605 for (var i = 0; i <= 1; i++) {
3606 var wifiStr;
3607 if (i == 0) {
3608 wifiStr = paramD.EX_APLIST;
3609 } else {
3610 wifiStr = paramD.EX_APLIST1;
3611 }
3612 var wifiArray = wifiStr.split(";");
3613 for (var j = 0; j < wifiArray.length; j++) {
3614 var item = wifiArray[j].split(",");
3615 if (!item[0]) {
3616 break;
3617 }
3618 var wifiJson = {
3619 fromProvider: item[0],
3620 connectStatus: item[1],
3621 ssid: item[2],
3622 signal: item[3],
3623 channel: item[4],
3624 authMode: item[5],
3625 encryptType: item[6],
3626 mac: item[7]
3627 }
3628 wifiList.push(wifiJson);
3629 }
3630 }
3631 return {
3632 scan_finish: "1",
3633 hotspotList: wifiList
3634 };
3635 } else {
3636 return errUnknownObj;
3637 }
3638 }
3639 }
3640 function creatHotspotString(hotspot) {
3641 var tmp = [];
3642 tmp.push(hotspot.profileName);
3643 tmp.push(hotspot.fromProvider || "0");
3644 tmp.push(hotspot.connectStatus || "0");
3645 tmp.push(hotspot.signal);
3646 tmp.push(hotspot.ssid);
3647 tmp.push(hotspot.authMode);
3648 tmp.push(hotspot.encryptType);
3649 tmp.push(hotspot.password || "0");
3650 tmp.push(hotspot.keyID);
3651 tmp.push(hotspot.mac);
3652 return tmp.join(",");
3653 }
3654 function saveHotspot() {
3655 return stuffMake(arguments, {}, prepare, deal, null, true);
3656 function prepare(values) {
3657 var apList = values.apList;
3658 var action = "modify";
3659 if (values.profileName == "") {
3660 action = "add";
3661 var newName = (jQuery.fn.jquery + Math.random()).replace(/\D/g, "");
3662 values.profileName = newName;
3663 apList.push({
3664 profileName: newName,
3665 fromProvider: "0",
3666 connectStatus: "0",
3667 signal: values.signal,
3668 ssid: values.ssid,
3669 authMode: values.authMode,
3670 encryptType: values.encryptType,
3671 password: values.password || "0",
3672 keyID: values.keyID,
3673 mac: values.mac
3674 });
3675 }
3676 var wifi = {
3677 "profile0": []
3678 };
3679 for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
3680 wifi["profile" + i] = [];
3681 }
3682 var activeHotspotStr = "";
3683 for (var i = 0; i < apList.length; i++) {
3684 var hotspotStr = "";
3685 if (values.profileName == apList[i].profileName) {
3686 hotspotStr = creatHotspotString(values);
3687 activeHotspotStr = hotspotStr;
3688 } else {
3689 hotspotStr = creatHotspotString(apList[i]);
3690 }
3691 var index = parseInt(i % 10);
3692 wifi["profile" + index].push(hotspotStr);
3693 }
3694 var profileParams = {
3695 wifi_profile: wifi.profile0.join(";")
3696 };
3697 for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
3698 profileParams["wifi_profile" + i] = wifi["profile" + i].join(";");
3699 }
3700 var valueReq = $.extend({
3701 goformId: "WIFI_SPOT_PROFILE_UPDATE",
3702 wifi_profile_num: apList.length,
3703 wifi_update_profile: activeHotspotStr,
3704 action: action
3705 }, profileParams);
3706 return valueReq;
3707 }
3708 function deal(paramD) {
3709 if (paramD) {
3710 return paramD;
3711 } else {
3712 return errUnknownObj;
3713 }
3714 }
3715 }
3716 function deleteHotspot() {
3717 return stuffMake(arguments, {}, prepare, deal, null, true);
3718 function prepare(values) {
3719 var apList = values.apList;
3720 var wifi = {
3721 "profile0": []
3722 };
3723 for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
3724 wifi["profile" + i] = [];
3725 }
3726 var foundDelete = false;
3727 var activeHotspotStr = "";
3728 for (var i = 0; i < apList.length; i++) {
3729 var hotspotStr = creatHotspotString(apList[i]);
3730 if (apList[i].profileName == values.profileName) {
3731 foundDelete = true;
3732 activeHotspotStr = hotspotStr;
3733 continue;
3734 }
3735 var idIndex = i;
3736 if (foundDelete) {
3737 idIndex = i - 1;
3738 }
3739 var index = parseInt(idIndex % 10);
3740 wifi["profile" + index].push(hotspotStr);
3741 }
3742 var num = foundDelete ? apList.length - 1 : apList.length;
3743 var profileParams = {
3744 wifi_profile: wifi.profile0.join(";")
3745 };
3746 for (var i = 1; i < config.AP_STATION_LIST_LENGTH; i++) {
3747 profileParams["wifi_profile" + i] = wifi["profile" + i].join(";");
3748 }
3749 var valueReq = $.extend({
3750 goformId: "WIFI_SPOT_PROFILE_UPDATE",
3751 wifi_profile_num: num,
3752 wifi_update_profile: activeHotspotStr,
3753 action: "delete"
3754 }, profileParams);
3755 return valueReq;
3756 }
3757 function deal(paramD) {
3758 if (paramD) {
3759 return paramD;
3760 } else {
3761 return errUnknownObj;
3762 }
3763 }
3764 }
3765 function connectHotspot() {
3766 return stuffMake(arguments, {}, prepare, deal, null, true);
3767 function prepare(values) {
3768 return {
3769 goformId: "WLAN_SET_STA_CON",
3770 EX_SSID1: values.EX_SSID1,
3771 EX_AuthMode: values.EX_AuthMode,
3772 EX_EncrypType: values.EX_EncrypType,
3773 EX_DefaultKeyID: values.EX_DefaultKeyID,
3774 EX_WEPKEY: values.EX_WEPKEY,
3775 EX_WPAPSK1: values.EX_WPAPSK1,
3776 EX_wifi_profile: values.EX_wifi_profile,
3777 EX_mac: values.EX_mac
3778 };
3779 }
3780 function deal(paramD) {
3781 if (paramD && (paramD.result == "success" || paramD.result == "processing")) {
3782 return paramD;
3783 } else {
3784 return errUnknownObj;
3785 }
3786 }
3787 }
3788 function disconnectHotspot() {
3789 return stuffMake(arguments, {}, prepare, deal, null, true);
3790 function prepare(values) {
3791 return {
3792 goformId: "WLAN_SET_STA_DISCON"
3793 };
3794 }
3795 function deal(paramD) {
3796 if (paramD && paramD.result == "success") {
3797 return paramD;
3798 } else {
3799 return errUnknownObj;
3800 }
3801 }
3802 }
3803 function getOpMode() {
3804 return stuffMake(arguments, {}, prepare, deal, null, false);
3805 function prepare(values, isPost) {
3806 return {
3807 multi_data: 1,
3808 cmd: "blc_wan_mode,blc_wan_auto_mode,loginfo,ppp_status,rj45_state,ethwan_mode"
3809 };
3810 }
3811 function deal(paramD) {
3812 if (paramD) {
3813 var result = {};
3814 if (paramD.blc_wan_mode == 'AUTO') {
3815 result.blc_wan_mode = paramD.blc_wan_auto_mode ? paramD.blc_wan_auto_mode : 'AUTO_PPP';
3816 } else {
3817 result.blc_wan_mode = paramD.blc_wan_mode ? paramD.blc_wan_mode : 'PPP';
3818 }
3819 result.loginfo = paramD.loginfo;
3820 result.ppp_status = paramD.ppp_status;
3821 result.rj45_state = (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state;
3822 result.ethwan_mode = paramD.ethwan_mode.toUpperCase();
3823 return result;
3824 } else {
3825 return errUnknownObj;
3826 }
3827 }
3828 }
3829 function getRj45PlugState() {
3830 return stuffMake(arguments, {}, prepare, deal, null, false);
3831 function prepare(values, isPost) {
3832 return {
3833 cmd: "rj45_plug"
3834 };
3835 }
3836 function deal(paramD) {
3837 if (paramD) {
3838 var result = {};
3839 result.rj45_plug = paramD.rj45_plug == "" ? "wan_lan_off" : paramD.rj45_plug;
3840 return result;
3841 } else {
3842 return errUnknownObj;
3843 }
3844 }
3845 }
3846 function checkOpMode(opmode, rj45state) {
3847 if (config.RJ45_SUPPORT) {
3848 if (rj45state == "dead" || rj45state == "") {
3849 return 'PPP';
3850 } else if (!opmode || opmode == "undefined") {
3851 if (rj45state == "working") {
3852 return 'PPPOE';
3853 } else {
3854 return 'PPP';
3855 }
3856 } else {
3857 return opmode;
3858 }
3859 } else {
3860 return 'PPP';
3861 }
3862 }
3863 function SetOperationMode(values, callback) {
3864 return stuffMake(arguments, {}, prepare, deal, null, true);
3865 function prepare(values) {
3866 var valueReq = $.extend({
3867 goformId: "OPERATION_MODE"
3868 }, values);
3869 return valueReq;
3870 }
3871 function deal(paramD) {
3872 if (paramD && paramD.result == "success") {
3873 return paramD;
3874 } else {
3875 return errUnknownObj;
3876 }
3877 }
3878 }
3879 function getPppoeParams() {
3880 return stuffMake(arguments, {}, prepare, deal, null, false);
3881 function prepare(values, isPost) {
3882 return {
3883 multi_data: 1,
3884 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"
3885 };
3886 }
3887 function deal(paramD) {
3888 if (paramD) {
3889 return {
3890 opms_wan_auto_mode: paramD.opms_wan_auto_mode,
3891 ethwan_mode: paramD.ethwan_mode.toUpperCase(),
3892 pppoe_username: paramD.pppoe_username,
3893 pppoe_cc: paramD.pppoe_cc,
3894 ethwan_dialmode: paramD.ethwan_dialmode == "manual" ? "manual_dial" : "auto_dial",
3895 ppp_status: paramD.ppp_status,
3896 static_wan_ipaddr: paramD.static_wan_ipaddr,
3897 static_wan_netmask: paramD.static_wan_netmask,
3898 static_wan_gateway: paramD.static_wan_gateway,
3899 static_wan_primary_dns: paramD.static_wan_primary_dns,
3900 static_wan_secondary_dns: paramD.static_wan_secondary_dns,
3901 rj45_state: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state,
3902 lan_ipaddr: paramD.lan_ipaddr,
3903 lan_netmask: paramD.lan_netmask
3904 }
3905 } else {
3906 return errUnknownObj;
3907 }
3908 }
3909 }
3910 function setPppoeDialMode(values, callback) {
3911 return stuffMake(arguments, {}, prepare, deal, null, true);
3912 function prepare(values) {
3913 var valueReq = $.extend({
3914 notCallback: true
3915 }, values);
3916 return valueReq;
3917 }
3918 function deal(paramD) {
3919 if (paramD.result == "success") {
3920 callback({
3921 result: true
3922 });
3923 } else {
3924 callback({
3925 result: false
3926 });
3927 }
3928 }
3929 }
3930 function getSntpParams(values, callback) {
3931 return stuffMake(arguments, {}, prepare, deal, null, false);
3932 function prepare(values, isPost) {
3933 return {
3934 multi_data: 1,
3935 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"
3936 };
3937 }
3938 function deal(paramD) {
3939 if (paramD) {
3940 var sntp_servers = getSntpServers(paramD);
3941 return {
3942 sntp_year: paramD.sntp_year,
3943 sntp_month: paramD.sntp_month,
3944 sntp_day: paramD.sntp_day,
3945 sntp_hour: paramD.sntp_hour,
3946 sntp_minute: paramD.sntp_minute,
3947 sntp_second: paramD.sntp_second,
3948 sntp_time_set_mode: paramD.sntp_time_set_mode,
3949 sntp_servers: sntp_servers,
3950 sntp_server0: paramD.sntp_server0,
3951 sntp_server1: paramD.sntp_server1,
3952 sntp_server2: paramD.sntp_server2,
3953 sntp_static_server0: paramD.sntp_static_server0,
3954 sntp_static_server1: paramD.sntp_static_server1,
3955 sntp_static_server2: paramD.sntp_static_server2,
3956 sntp_other_server0: paramD.sntp_other_server0,
3957 sntp_other_server1: paramD.sntp_other_server1,
3958 sntp_other_server2: paramD.sntp_other_server2,
3959 sntp_timezone: paramD.sntp_timezone,
3960 sntp_timezone_index: paramD.sntp_timezone_index ? paramD.sntp_timezone_index : "0",
3961 sntp_dst_enable: paramD.sntp_dst_enable,
3962 ppp_status: paramD.ppp_status,
3963 blc_wan_mode: informationAll.blc_wan_mode,
3964 sntp_process_result: paramD.sntp_process_result,
3965 rj45_state: (typeof paramD.rj45_state == 'undefined' || paramD.rj45_state == '') ? 'dead' : paramD.rj45_state
3966 }
3967 } else {
3968 return errUnknownObj;
3969 }
3970 }
3971 function getSntpServers(paramD) {
3972 var serverArray = [];
3973 for (var i = 0; i < 3; i++) {
3974 var tmp = "sntp_static_server" + (i).toString();
3975 if (paramD[tmp] != "") {
3976 var obj = {};
3977 obj.name = paramD[tmp];
3978 obj.value = paramD[tmp];
3979 serverArray.push(obj);
3980 }
3981 }
3982 var otherArray = [{
3983 name: "Other",
3984 value: "Other"
3985 }, {
3986 name: "NONE",
3987 value: ""
3988 }
3989 ];
3990 for (var j = 0; j < 2; j++) {
3991 serverArray.push(otherArray[j]);
3992 }
3993 return serverArray;
3994 }
3995 }
3996 function setSNTPDate(values, callback) {
3997 return stuffMake(arguments, {}, prepare, deal, null, true);
3998 function prepare(values) {
3999 var valueReq = $.extend({}, values);
4000 return valueReq;
4001 }
4002 function deal(paramD) {
4003 if (paramD && paramD.result == "success") {
4004 return paramD;
4005 } else {
4006 return errUnknownObj;
4007 }
4008 }
4009 }
4010 function setSntpSetting(values, callback) {
4011 var valueReq = $.extend({}, values); {
4012 $.post("reqproc/proc_post", valueReq, function (paramD) {
4013 if (paramD && paramD.result == "success") {
4014 if (values.manualsettime == "auto") {
4015 setTimeout(checkSyncStatus, 2000);
4016 callback(paramD);
4017 } else {
4018 callback(true);
4019 }
4020 } else if (paramD && paramD.result == "processing") {
4021 callback(paramD);
4022 } else {
4023 callback(false);
4024 }
4025 }, "json");
4026 }
4027 function checkSyncStatus() {
4028 $.ajax({
4029 url: "reqproc/proc_get",
4030 dataType: "json",
4031 data: {
4032 cmd: "sntp_process_result"
4033 },
4034 cache: false,
4035 async: false,
4036 success: function (paramD) {
4037 if (paramD.sntp_process_result == "failure") {
4038 callback(false);
4039 } else if (paramD.sntp_process_result == "success") {
4040 callback(true);
4041 } else {
4042 setTimeout(checkSyncStatus, 2000);
4043 }
4044 },
4045 error: function () {
4046 callback(false);
4047 }
4048 });
4049 }
4050 }
4051 function addUrlFilterRule(values, callback) {
4052 return stuffMake(arguments, {}, prepare, deal, null, true);
4053 function prepare(values) {
4054 var valueReq = $.extend({}, values);
4055 return valueReq;
4056 }
4057 function deal(paramD) {
4058 if (paramD && paramD.result == "success") {
4059 return paramD;
4060 } else {
4061 return errUnknownObj;
4062 }
4063 }
4064 }
4065 function getUrlFilterList() {
4066 return stuffMake(arguments, {}, prepare, deal, null, false);
4067 function prepare(values, isPost) {
4068 return {
4069 cmd: "websURLFilters"
4070 };
4071 }
4072 function deal(paramD) {
4073 var urlFilterRules = [];
4074 if (paramD) {
4075 if (paramD.websURLFilters.length == 0) {
4076 return {
4077 urlFilterRules: []
4078 };
4079 } else {
4080 var tempArray = paramD.websURLFilters.split(";");
4081 for (var i = 0; i < tempArray.length; i++) {
4082 var aRule = {};
4083 aRule.index = i;
4084 aRule.url = tempArray[i];
4085 urlFilterRules.push(aRule);
4086 }
4087 return {
4088 urlFilterRules: urlFilterRules
4089 };
4090 }
4091 } else {
4092 return errUnknownObj;
4093 }
4094 }
4095 }
4096 function deleteSelectedRules(values, callback) {
4097 return stuffMake(arguments, {}, prepare, deal, null, true);
4098 function prepare(values) {
4099 var valueReq = $.extend({}, values);
4100 return valueReq;
4101 }
4102 function deal(paramD) {
4103 if (paramD && paramD.result == "success") {
4104 return paramD;
4105 } else {
4106 return errUnknownObj;
4107 }
4108 }
4109 }
4110 function getWdsInfo() {
4111 return stuffMake(arguments, {}, prepare, deal, null, false);
4112 function prepare(values, isPost) {
4113 return {
4114 multi_data: "1",
4115 cmd: "wifi_wds_mode,wifi_wds_ssid,wifi_wds_AuthMode,wifi_wds_EncrypType,wifi_wds_WPAPSK1,wifi_cur_state "
4116 };
4117 }
4118 function deal(paramD) {
4119 if (paramD) {
4120 return {
4121 currentMode: paramD.wifi_wds_mode,
4122 wdsSSID: paramD.wifi_wds_ssid,
4123 wdsAuthMode: paramD.wifi_wds_AuthMode,
4124 wdsEncrypType: paramD.wifi_wds_EncrypType,
4125 wdsWPAPSK1: paramD.wifi_wds_WPAPSK1,
4126 RadioOff: paramD.wifi_cur_state == "1" ? "1" : "0"
4127 };
4128 } else {
4129 return errUnknownObj;
4130 }
4131 }
4132 }
4133 function setWDS(values, callback) {
4134 return stuffMake(arguments, {}, prepare, deal, null, true);
4135 function prepare(values) {
4136 var valueReq = $.extend({}, values);
4137 return valueReq;
4138 }
4139 function deal(paramD) {
4140 if (paramD && paramD.result == "success") {
4141 return paramD;
4142 } else {
4143 return errUnknownObj;
4144 }
4145 }
4146 }
4147 function getSyslogInfo() {
4148 return stuffMake(arguments, {}, prepare, deal, null, false);
4149 function prepare(values, isPost) {
4150 return {
4151 multi_data: "1",
4152 cmd: "syslog_mode,debug_level"
4153 };
4154 }
4155 function deal(paramD) {
4156 if (paramD) {
4157 return {
4158 currentMode: paramD.syslog_mode,
4159 debugLevel: paramD.debug_level
4160 };
4161 } else {
4162 return errUnknownObj;
4163 }
4164 }
4165 }
4166 function setSysLog(values, callback) {
4167 return stuffMake(arguments, {}, prepare, deal, null, true);
4168 function prepare(values) {
4169 var valueReq = $.extend({}, values);
4170 return valueReq;
4171 }
4172 function deal(paramD) {
4173 if (paramD && paramD.result == "success") {
4174 return paramD;
4175 } else {
4176 return errUnknownObj;
4177 }
4178 }
4179 }
4180 function getMacFilterInfo() {
4181 return stuffMake(arguments, {}, prepare, deal, null, false);
4182 function prepare(values, isPost) {
4183 return {
4184 multi_data: "1",
4185 cmd: "ACL_mode,wifi_mac_black_list,wifi_hostname_black_list,wifi_cur_state,user_ip_addr,client_mac_address,wifi_mac_white_list"
4186 };
4187 }
4188 function deal(paramD) {
4189 if (paramD) {
4190 return {
4191 ACL_mode: paramD.ACL_mode,
4192 wifi_mac_black_list: paramD.wifi_mac_black_list,
4193 wifi_hostname_black_list: paramD.wifi_hostname_black_list,
4194 RadioOff: paramD.wifi_cur_state == "1" ? "1" : "0",
4195 user_ip_addr: paramD.user_ip_addr,
4196 client_mac_address: paramD.client_mac_address,
4197 wifi_mac_white_list: paramD.wifi_mac_white_list
4198 };
4199 } else {
4200 return errUnknownObj;
4201 }
4202 }
4203 }
4204 function setMacFilter() {
4205 return stuffMake(arguments, {}, prepare, deal, null, true);
4206 function prepare(values) {
4207 var valueReq = $.extend({
4208 goformId: 'WIFI_MAC_FILTER',
4209 }, values);
4210 return valueReq;
4211 }
4212 function deal(paramD) {
4213 if (paramD && paramD.result == "success") {
4214 return paramD;
4215 } else {
4216 return errUnknownObj;
4217 }
4218 }
4219 }
4220 function getFastbootSetting() {
4221 return stuffMake(arguments, {}, prepare, deal, null, false);
4222 function prepare(values) {
4223 return {
4224 cmd: "mgmt_quicken_power_on,need_hard_reboot,need_sim_pin",
4225 multi_data: 1
4226 };
4227 }
4228 function deal(paramD) {
4229 return {
4230 fastbootEnabled: paramD.mgmt_quicken_power_on == '1' ? '1' : '0',
4231 need_hard_reboot: paramD.need_hard_reboot,
4232 need_sim_pin: paramD.need_sim_pin == 'yes' ? 'yes' : 'no'
4233 };
4234 }
4235 }
4236 function setFastbootSetting() {
4237 return stuffMake(arguments, {}, prepare, deal, null, true);
4238 function prepare(values) {
4239 return {
4240 goformId: "MGMT_CONTROL_POWER_ON_SPEED",
4241 mgmt_quicken_power_on: values.fastbootEnabled
4242 };
4243 }
4244 function deal(paramD) {
4245 if (paramD && paramD.result == "success") {
4246 return paramD;
4247 } else {
4248 return errUnknownObj;
4249 }
4250 }
4251 }
4252 function turnOffDevice() {
4253 return stuffMake(arguments, {}, prepare, deal, null, true);
4254 function prepare(values, isPost) {
4255 var valueReq = {};
4256 valueReq.goformId = "TURN_OFF_DEVICE";
4257 return valueReq;
4258 }
4259 function deal(paramD) {
4260 if (paramD) {
4261 return paramD;
4262 } else {
4263 return errUnknownObj;
4264 }
4265 }
4266 }
4267 function restart() {
4268 return stuffMake(arguments, {}, prepare, deal, null, true);
4269 function prepare(values, isPost) {
4270 var valueReq = {};
4271 valueReq.goformId = "REBOOT_DEVICE";
4272 return valueReq;
4273 }
4274 function deal(paramD) {
4275 if (paramD) {
4276 return paramD;
4277 } else {
4278 return errUnknownObj;
4279 }
4280 }
4281 }
4282 function getScheduleSetting() {
4283 return stuffMake(arguments, {}, prepare, deal, null, false);
4284 function prepare(values, isPost) {
4285 var valueReq = {};
4286 valueReq.cmd = "schedule_restart_enable,schedule_restart_hour,schedule_restart_minute";
4287 valueReq.multi_data = 1;
4288 return valueReq;
4289 }
4290 function deal(paramD) {
4291 if (paramD) {
4292 var result = {};
4293 result.scheduleSetting = paramD.schedule_restart_enable == "1" ? "1" : "0";
4294 result.scheduleHour = paramD.schedule_restart_hour;
4295 result.scheduleMinute = paramD.schedule_restart_minute;
4296 return result;
4297 } else {
4298 return errUnknownObj;
4299 }
4300 }
4301 }
4302 function setScheduleSetting() {
4303 return stuffMake(arguments, {}, prepare, deal, null, true);
4304 function prepare(values, isPost) {
4305 var valueReq = {};
4306 valueReq.goformId = "SCHEDULE_SETTING";
4307 valueReq.scheduleEnabled = values.scheduleSetting;
4308 if (valueReq.scheduleEnabled == '1') {
4309 valueReq.scheduleHour = values.scheduleHour;
4310 valueReq.scheduleMinute = values.scheduleMinute;
4311 }
4312 return valueReq;
4313 }
4314 function deal(paramD) {
4315 if (paramD) {
4316 return paramD;
4317 } else {
4318 return errUnknownObj;
4319 }
4320 }
4321 }
4322 function getPingResult() {
4323 return stuffMake(arguments, {}, prepare, deal, null, false);
4324 function prepare(values, isPost) {
4325 var valueReq = {};
4326 valueReq.cmd = "ping_result";
4327 return valueReq;
4328 }
4329 function deal(paramD) {
4330 if (paramD) {
4331 var result = {};
4332 result.pingResult = paramD.ping_result;
4333 return result;
4334 } else {
4335 return errUnknownObj;
4336 }
4337 }
4338 }
4339 function pingResultClear() {
4340 return stuffMake(arguments, {}, prepare, deal, null, true);
4341 function prepare(values, isPost) {
4342 var valueReq = {};
4343 valueReq.goformId = "PING_RESULT_CLEAR";
4344 return valueReq;
4345 }
4346 function deal(paramD) {
4347 if (paramD) {
4348 return paramD;
4349 } else {
4350 return errUnknownObj;
4351 }
4352 }
4353 }
4354 function getPingSetting() {
4355 return stuffMake(arguments, {}, prepare, deal, null, false);
4356 function prepare(values, isPost) {
4357 var valueReq = {};
4358 valueReq.cmd = "ping_repetition_count,ping_diag_addr";
4359 valueReq.multi_data = 1;
4360 return valueReq;
4361 }
4362 function deal(paramD) {
4363 if (paramD) {
4364 var result = {};
4365 result.pingTimes = paramD.ping_repetition_count;
4366 result.pingURL = paramD.ping_diag_addr;
4367 return result;
4368 } else {
4369 return errUnknownObj;
4370 }
4371 }
4372 }
4373 function setPingSettingStart() {
4374 return stuffMake(arguments, {}, prepare, deal, null, true);
4375 function prepare(values, isPost) {
4376 var valueReq = {};
4377 valueReq.goformId = "PINT_DIAGNOSTICS_START";
4378 valueReq.ping_repetition_count = values.pingTimes;
4379 valueReq.ping_diag_addr = values.pingURL;
4380 return valueReq;
4381 }
4382 function deal(paramD) {
4383 if (paramD) {
4384 return paramD;
4385 } else {
4386 return errUnknownObj;
4387 }
4388 }
4389 }
4390 function getNewVersionState() {
4391 return stuffMake(arguments, {}, prepare, deal, null, false);
4392 function prepare(values, isPost) {
4393 var valueReq = {};
4394 valueReq.cmd = "fota_new_version_state,fota_current_upgrade_state,fota_package_already_download";
4395 valueReq.multi_data = 1;
4396 return valueReq;
4397 }
4398 function deal(paramD) {
4399 if (paramD) {
4400 var hasNewVersion = (paramD.fota_new_version_state == 'has_critical' || paramD.fota_new_version_state == 'has_optional' || paramD.fota_new_version_state == 'already_has_pkg');
4401 paramD.hasNewVersion = hasNewVersion;
4402 return paramD;
4403 } else {
4404 return errUnknownObj;
4405 }
4406 }
4407 }
4408 function getMandatory() {
4409 return stuffMake(arguments, {}, prepare, deal, null, false);
4410 function prepare(values, isPost) {
4411 var valueReq = {};
4412 if (config.UPGRADE_TYPE == "OTA") {
4413 valueReq.cmd = "is_mandatory";
4414 } else {
4415 valueReq.cmd = "fota_new_version_state";
4416 }
4417 return valueReq;
4418 }
4419 function deal(paramD) {
4420 if (paramD) {
4421 if (config.UPGRADE_TYPE == "OTA") {
4422 return {
4423 "is_mandatory": paramD.is_mandatory == "1"
4424 };
4425 } else {
4426 return {
4427 "is_mandatory": paramD.fota_new_version_state == "has_critical"
4428 };
4429 }
4430 } else {
4431 return errUnknownObj;
4432 }
4433 }
4434 }
4435 function getUpgradeResult() {
4436 return stuffMake(arguments, {}, prepare, deal, null, false);
4437 function prepare(values, isPost) {
4438 var valueReq = {};
4439 valueReq.cmd = "upgrade_result";
4440 return valueReq;
4441 }
4442 function deal(paramD) {
4443 if (paramD) {
4444 return paramD;
4445 } else {
4446 return errUnknownObj;
4447 }
4448 }
4449 }
4450 function getCurrentUpgradeState() {
4451 return stuffMake(arguments, {}, prepare, deal, null, false);
4452 function prepare(values, isPost) {
4453 var valueReq = {};
4454 valueReq.cmd = "fota_current_upgrade_state";
4455 return valueReq;
4456 }
4457 function deal(paramD) {
4458 if (paramD) {
4459 paramD.current_upgrade_state = paramD.fota_current_upgrade_state;
4460 return paramD;
4461 } else {
4462 return errUnknownObj;
4463 }
4464 }
4465 }
4466 function getPackSizeInfo() {
4467 return stuffMake(arguments, {}, prepare, deal, null, false);
4468 function prepare(values, isPost) {
4469 var valueReq = {};
4470 valueReq.cmd = "fota_pkg_total_size,fota_dl_pkg_size";
4471 valueReq.multi_data = 1;
4472 return valueReq;
4473 }
4474 function deal(paramD) {
4475 if (paramD) {
4476 return paramD;
4477 } else {
4478 return errUnknownObj;
4479 }
4480 }
4481 }
4482 function setUpgradeSelectOp() {
4483 return stuffMake(arguments, {}, prepare, deal, null, true);
4484 function prepare(values, isPost) {
4485 var valueReq = {};
4486 valueReq.goformId = "IF_UPGRADE";
4487 valueReq.select_op = values.selectOp;
4488 if (valueReq.select_op == 'check') {
4489 valueReq.ota_manual_check_roam_state = 1;
4490 }
4491 return valueReq;
4492 }
4493 function deal(paramD) {
4494 if (paramD) {
4495 return paramD;
4496 } else {
4497 return errUnknownObj;
4498 }
4499 }
4500 }
4501 function getOTAUpdateSetting() {
4502 return stuffMake(arguments, {}, prepare, deal, null, false);
4503 function prepare(values, isPost) {
4504 var valueReq = {};
4505 valueReq.cmd = "fota_updateMode,fota_updateIntervalDay,fota_allowRoamingUpdate";
4506 valueReq.multi_data = 1;
4507 return valueReq;
4508 }
4509 function deal(paramD) {
4510 if (paramD) {
4511 return {
4512 updateMode: paramD.fota_updateMode,
4513 updateIntervalDay: paramD.fota_updateIntervalDay,
4514 allowRoamingUpdate: paramD.fota_allowRoamingUpdate
4515 };
4516 } else {
4517 return errUnknownObj;
4518 }
4519 }
4520 }
4521 function setOTAUpdateSetting() {
4522 return stuffMake(arguments, {}, prepare, deal, null, true);
4523 function prepare(values, isPost) {
4524 var valueReq = {};
4525 valueReq.goformId = "SetUpgAutoSetting";
4526 valueReq.UpgMode = values.updateMode;
4527 valueReq.UpgIntervalDay = values.updateIntervalDay;
4528 valueReq.UpgRoamPermission = values.allowRoamingUpdate;
4529 return valueReq;
4530 }
4531 function deal(paramD) {
4532 if (paramD && paramD.result == "success") {
4533 return paramD;
4534 } else {
4535 return errUnknownObj;
4536 }
4537 }
4538 }
w.deng3816b832024-11-01 16:01:30 +08004539 function getManualOTAUpdateSetting() {
4540 return stuffMake(arguments, {}, prepare, deal, null, false);
4541 function prepare(values, isPost) {
4542 var valueReq = {};
4543 valueReq.cmd = "fota_manualUpgradeURL";
4544 valueReq.multi_data = 1;
4545 return valueReq;
4546 }
4547 function deal(paramD) {
4548 if (paramD) {
4549 return {
4550 updateURL: paramD.fota_manualUpgradeURL
4551 };
4552 } else {
4553 return errUnknownObj;
4554 }
4555 }
4556 }
4557 function setManualOTAUpdateSetting() {
4558 return stuffMake(arguments, {}, prepare, deal, null, true);
4559 function prepare(values, isPost) {
4560 var valueReq = {};
4561 valueReq.goformId = "SetUpgManualSetting";
4562 valueReq.UpgURL = values.updateURL;
4563 return valueReq;
4564 }
4565 function deal(paramD) {
4566 if (paramD && paramD.result == "success") {
4567 return paramD;
4568 } else {
4569 return errUnknownObj;
4570 }
4571 }
4572 }
qumengjia1cd76022024-10-31 17:51:04 +08004573 function getOTAlastCheckTime() {
4574 return getParams({
4575 nv: ['dm_last_check_time']
4576 }, arguments[1], arguments[2]);
4577 }
4578 function getSignalStrength() {
4579 return getParams({
4580 nv: ['network_type', 'sub_network_type', 'rssi', 'rscp', 'lte_rsrp']
4581 }, arguments[1], arguments[2]);
4582 }
4583 function clearUpdateResult() {
4584 return stuffMake(arguments, {}, prepare, deal, null, true);
4585 function prepare(values, isPost) {
4586 var valueReq = {};
4587 valueReq.goformId = "RESULT_RESTORE";
4588 return valueReq;
4589 }
4590 function deal(paramD) {
4591 if (paramD && paramD.result == "success") {
4592 return paramD;
4593 } else {
4594 return errUnknownObj;
4595 }
4596 }
4597 }
4598 function childGroupList() {
4599 return stuffMake(arguments, {}, prepare, deal, null, false);
4600 function prepare(values, isPost) {
4601 var valueReq = {
4602 cmd: "childGroupList"
4603 };
4604 return valueReq;
4605 }
4606 function deal(paramD) {
4607 if (paramD && (paramD.childGroupList || paramD.devices)) {
4608 return paramD;
4609 } else {
4610 return {
4611 devices: []
4612 };
4613 }
4614 }
4615 }
4616 function addChildGroup() {
4617 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4618 : {
4619 errorType: 'no_auth'
4620 }, prepare, deal, null, true);
4621 function prepare(values, isPost) {
4622 var valueReq = {
4623 goformId: "ADD_DEVICE",
4624 mac: values.macAddress
4625 };
4626 return valueReq;
4627 }
4628 function deal(paramD) {
4629 if (paramD && paramD.result == 'success') {
4630 return paramD;
4631 } else {
4632 return errUnknownObj;
4633 }
4634 }
4635 }
4636 function removeChildGroup() {
4637 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4638 : {
4639 errorType: 'no_auth'
4640 }, prepare, deal, null, true);
4641 function prepare(values, isPost) {
4642 var valueReq = {
4643 goformId: "DEL_DEVICE",
4644 mac: values.mac
4645 };
4646 return valueReq;
4647 }
4648 function deal(paramD) {
4649 if (paramD && paramD.result == 'success') {
4650 return paramD;
4651 } else {
4652 return errUnknownObj;
4653 }
4654 }
4655 }
4656 function checkCurrentUserInChildGroup(devices) {
4657 if (typeof config.currentUserInChildGroup == "undefined") {
4658 var childGroupDevice = [];
4659 if (typeof devices != "undefined") {
4660 childGroupDevice = devices;
4661 } else {
4662 childGroupDevice = childGroupList({}).devices;
4663 }
4664 var userMacAddr = getUserMacAddr({}).get_user_mac_addr;
4665 var found = _.find(childGroupDevice, function (item) {
4666 return item.mac == userMacAddr;
4667 });
4668 config.currentUserInChildGroup = typeof found != 'undefined';
4669 return {
4670 result: typeof found != 'undefined'
4671 };
4672 }
4673 return {
4674 result: config.currentUserInChildGroup
4675 };
4676 }
4677 function getUserMacAddr() {
4678 return getParams({
4679 nv: 'get_user_mac_addr'
4680 }, arguments[1], arguments[2]);
4681 }
4682 function getHostNameList() {
4683 return stuffMake(arguments, {}, prepare, deal, null, false);
4684 function prepare(values, isPost) {
4685 var valueReq = {
4686 cmd: "hostNameList"
4687 };
4688 return valueReq;
4689 }
4690 function deal(paramD) {
4691 if (paramD && (paramD.hostNameList || paramD.devices)) {
4692 return paramD;
4693 } else {
4694 return {
4695 devices: []
4696 };
4697 }
4698 }
4699 }
4700 function editHostName() {
4701 return stuffMake(arguments, {}, prepare, deal, null, true);
4702 function prepare(values, isPost) {
4703 var valueReq = {
4704 goformId: "EDIT_HOSTNAME",
4705 mac: values.mac,
4706 hostname: values.hostname
4707 };
4708 return valueReq;
4709 }
4710 function deal(paramD) {
4711 if (paramD && paramD.result == 'success') {
4712 return paramD;
4713 } else {
4714 return errUnknownObj;
4715 }
4716 }
4717 }
4718 function getSiteWhiteList() {
4719 return stuffMake(arguments, {}, prepare, deal, null, false);
4720 function prepare(values, isPost) {
4721 var valueReq = {
4722 cmd: "site_white_list"
4723 };
4724 return valueReq;
4725 }
4726 function deal(paramD) {
4727 if (paramD && (paramD.site_white_list || paramD.siteList)) {
4728 return paramD;
4729 } else {
4730 return {
4731 siteList: []
4732 };
4733 }
4734 }
4735 }
4736 function removeSiteWhite() {
4737 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4738 : {
4739 errorType: 'no_auth'
4740 }, prepare, deal, null, true);
4741 function prepare(values, isPost) {
4742 var valueReq = {
4743 goformId: "REMOVE_WHITE_SITE",
4744 ids: values.ids.join(',')
4745 };
4746 return valueReq;
4747 }
4748 function deal(paramD) {
4749 if (paramD && paramD.result == 'success') {
4750 return paramD;
4751 } else {
4752 return errUnknownObj;
4753 }
4754 }
4755 }
4756 function saveSiteWhite() {
4757 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4758 : {
4759 errorType: 'no_auth'
4760 }, prepare, deal, null, true);
4761 function prepare(values, isPost) {
4762 var valueReq = {
4763 goformId: "ADD_WHITE_SITE",
4764 name: values.name,
4765 site: values.site
4766 };
4767 return valueReq;
4768 }
4769 function deal(paramD) {
4770 if (paramD && paramD.result == 'success') {
4771 return paramD;
4772 } else {
4773 return errUnknownObj;
4774 }
4775 }
4776 }
4777 function getTimeLimited() {
4778 var defaultResult = {
4779 '0': [],
4780 '1': [],
4781 '2': [],
4782 '3': [],
4783 '4': [],
4784 '5': [],
4785 '6': []
4786 };
4787 return stuffMake(arguments, {}, prepare, deal, null, false);
4788 function prepare(values, isPost) {
4789 var valueReq = {
4790 cmd: "time_limited"
4791 };
4792 return valueReq;
4793 }
4794 function deal(paramD) {
4795 if (paramD) {
4796 return parseTimeLimited(paramD);
4797 } else {
4798 return defaultResult;
4799 }
4800 }
4801 function parseTimeLimited(paramD) {
4802 if (paramD.time_limited == '') {
4803 return {
4804 time_limited: []
4805 };
4806 }
4807 var weeks = paramD.time_limited.split(';');
4808 _.each(weeks, function (week) {
4809 var weekTime = week.split('+');
4810 if (weekTime.length == 2) {
4811 defaultResult[weekTime[0]] = weekTime[1].split(',');
4812 }
4813 });
4814 return defaultResult;
4815 }
4816 }
4817 function saveTimeLimited() {
4818 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4819 : {
4820 errorType: 'no_auth'
4821 }, prepare, deal, null, true);
4822 function prepare(values, isPost) {
4823 var valueReq = {
4824 goformId: "SAVE_TIME_LIMITED",
4825 time_limited: values.time
4826 };
4827 return valueReq;
4828 }
4829 function deal(paramD) {
4830 if (paramD && paramD.result == 'success') {
4831 return paramD;
4832 } else {
4833 return errUnknownObj;
4834 }
4835 }
4836 }
4837 function getTsw() {
4838 return stuffMake(arguments, {}, prepare, deal, null, false);
4839 function prepare(values, isPost) {
4840 var valueReq = {
4841 cmd: "openEnable,closeEnable,openTime,closeTime",
4842 multi_data: '1'
4843 };
4844 return valueReq;
4845 }
4846 function deal(paramD) {
4847 if (paramD) {
4848 if (paramD.openTime.indexOf(':') != -1) {
4849 var open = paramD.openTime.split(':');
4850 paramD.openH = leftInsert(open[0], 2, '0');
4851 paramD.openM = leftInsert(open[1], 2, '0');
4852 } else {
4853 paramD.openH = '06';
4854 paramD.openM = '00';
4855 }
4856 if (paramD.closeTime.indexOf(':') != -1) {
4857 var close = paramD.closeTime.split(':');
4858 paramD.closeH = leftInsert(close[0], 2, '0');
4859 paramD.closeM = leftInsert(close[1], 2, '0');
4860 } else {
4861 paramD.closeH = '22';
4862 paramD.closeM = '00';
4863 }
4864 return paramD;
4865 } else {
4866 return errUnknownObj;
4867 }
4868 }
4869 }
4870 function saveTsw() {
4871 return stuffMake(arguments, {}, prepare, deal, null, true);
4872 function prepare(values, isPost) {
4873 var valueReq = {
4874 goformId: "SAVE_TSW",
4875 openEnable: values.openEnable,
4876 closeEnable: values.closeEnable
4877 };
4878 if (values.openEnable == '1') {
4879 valueReq.openTime = values.openTime;
4880 valueReq.closeTime = values.closeTime;
4881 }
4882 return valueReq;
4883 }
4884 function deal(paramD) {
4885 if (paramD && paramD.result == 'success') {
4886 return paramD;
4887 } else if (paramD && paramD.result == 'failure') {
4888 return paramD;
4889 } else {
4890 return errUnknownObj;
4891 }
4892 }
4893 }
4894 function trafficCalibration() {
4895 return stuffMake(arguments, {}, prepare, deal, null, true);
4896 function prepare(values, isPost) {
4897 var valueReq = {
4898 goformId: "FLOW_CALIBRATION_MANUAL",
4899 calibration_way: values.way,
4900 time: values.way == 'time' ? values.value : 0,
4901 data: values.way == 'data' ? values.value : 0
4902 };
4903 return valueReq;
4904 }
4905 function deal(paramD) {
4906 if (paramD && paramD.result == 'success') {
4907 return paramD;
4908 } else {
4909 return errUnknownObj;
4910 }
4911 }
4912 }
4913 function getParams() {
4914 return stuffMake(arguments, {}, prepare, deal, null, false);
4915 function prepare(values, isPost) {
4916 var valueReq = {};
4917 if (_.isArray(values.nv)) {
4918 valueReq.cmd = values.nv.join(',');
4919 valueReq.multi_data = 1;
4920 } else {
4921 valueReq.cmd = values.nv;
4922 }
4923 return valueReq;
4924 }
4925 function deal(paramD) {
4926 if (paramD) {
4927 return paramD;
4928 } else {
4929 return errUnknownObj;
4930 }
4931 }
4932 }
4933 function getRedirectData() {
4934 return stuffMake(arguments, {}, prepare, deal, null, false);
4935 function prepare(values, isPost) {
4936 var valueReq = {};
4937 valueReq.cmd = "vwim_mc_state,traffic_overrun,detect_new_version";
4938 valueReq.multi_data = 1;
4939 return valueReq;
4940 }
4941 function deal(paramD) {
4942 if (paramD) {
4943 var result = {};
4944 result.vwim_mc_state = paramD.vwim_mc_state;
4945 result.traffic_overrun = paramD.traffic_overrun;
4946 result.detect_new_version = paramD.detect_new_version;
4947 result.blc_wan_mode = informationAll.blc_wan_mode;
4948 return result;
4949 } else {
4950 return errUnknownObj;
4951 }
4952 }
4953 }
4954 function clearRedirectFlag() {
4955 return stuffMake(arguments, {}, prepare, deal, null, true);
4956 function prepare(values, isPost) {
4957 var valueReq = {};
4958 valueReq.goformId = "CLEAR_REDIRECT_FLAG";
4959 valueReq.flag_id = values.redirectFlags;
4960 return valueReq;
4961 }
4962 function deal(paramD) {
4963 if (paramD) {
4964 return paramD;
4965 } else {
4966 return errUnknownObj;
4967 }
4968 }
4969 }
4970 function getV4Switch() {
4971 return stuffMake(arguments, {}, prepare, deal, null, false);
4972 function prepare(values, isPost) {
4973 var valueReq = {};
4974 valueReq.cmd = "lock_zone_enable,pin_interlock_and_V4_lock";
4975 valueReq.multi_data = 1;
4976 return valueReq;
4977 }
4978 function deal(paramD) {
4979 if (paramD) {
4980 return paramD;
4981 } else {
4982 return errUnknownObj;
4983 }
4984 }
4985 }
4986 function setV4Switch() {
4987 return stuffMake(arguments, {}, prepare, deal, null, true);
4988 function prepare(values, isPost) {
4989 var valueReq = {};
4990 valueReq.goformId = "PIN_LOCK_V4_ENCODE";
4991 valueReq.pin_interlock_and_V4_lock = values.pin_interlock_and_V4_lock;
4992 valueReq.TspLock_key_data = values.TspLock_key_data;
4993 return valueReq;
4994 }
4995 function deal(paramD) {
4996 if (paramD && paramD.result == "success") {
4997 return paramD;
4998 } else {
4999 return errUnknownObj;
5000 }
5001 }
5002 }
5003 function getCellId() {
5004 return stuffMake(arguments, {}, prepare, deal, null, false);
5005 function prepare(values, isPost) {
5006 var valueReq = {};
5007 valueReq.cmd = "cell_id_list,global_cell_id,network_type,sub_network_type,cell_not_correct";
5008 valueReq.multi_data = 1;
5009 return valueReq;
5010 }
5011 function deal(paramD) {
5012 if (paramD) {
5013 return paramD;
5014 } else {
5015 return errUnknownObj;
5016 }
5017 }
5018 }
5019 function setCellIdSwitch() {
5020 return stuffMake(arguments, {}, prepare, deal, null, true);
5021 function prepare(values, isPost) {
5022 var valueReq = {};
5023 valueReq.goformId = "LOCK_ZONE";
5024 valueReq.lock_zone_enable = values.lock_zone_enable;
5025 return valueReq;
5026 }
5027 function deal(paramD) {
5028 if (paramD && paramD.result == "success") {
5029 return paramD;
5030 } else {
5031 return errUnknownObj;
5032 }
5033 }
5034 }
5035 function getUpdateType() {
5036 return stuffMake(arguments, {}, prepare, deal, null, false);
5037 function prepare(values, isPost) {
5038 var valueReq = {
5039 cmd: "update_type"
5040 };
5041 return valueReq;
5042 }
5043 function deal(paramD) {
5044 return {
5045 update_type: paramD.update_type ? paramD.update_type : "mifi_fota"
5046 }
5047 }
5048 }
5049 function getSecurityInfo() {
5050 return stuffMake(arguments, {}, prepare, deal, null, false);
5051 function prepare(values, isPost) {
5052 var valueReq = {};
5053 valueReq.cmd = "AuthMode,passPhrase";
5054 valueReq.multi_data = 1;
5055 return valueReq;
5056 }
5057 function deal(paramD) {
5058 if (paramD) {
5059 var result = {};
5060 result.AuthMode = paramD.AuthMode;
5061 result.passPhrase = config.PASSWORD_ENCODE ? Base64.decode(paramD.passPhrase) : paramD.passPhrase;
5062 return result;
5063 } else {
5064 return errUnknownObj;
5065 }
5066 }
5067 }
5068 //can delete
5069 function setSecurityInfo() {
5070 return stuffMake(arguments, {}, prepare, deal, null, true);
5071 function prepare(values, isPost) {
5072 var valueReq = {};
5073 valueReq.goformId = "SET_WIFI_SECURITY_INFO";
5074 valueReq.AuthMode = values.AuthMode;
5075 if (valueReq.AuthMode == "WPAPSKWPA2PSK") {
5076 valueReq.passPhrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;
5077 }
5078 return valueReq;
5079 }
5080 function deal(paramD) {
5081 if (paramD) {
5082 return paramD;
5083 } else {
5084 return errUnknownObj;
5085 }
5086 }
5087 }
5088 function setWifiBasic() {
5089 stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
5090 function prepare(values) {
5091 var valueReq = {
5092 goformId: "SET_WIFI_SSID1_SETTINGS",
5093 ssid: values.SSID,
5094 broadcastSsidEnabled: values.broadcast,
5095 MAX_Access_num: values.station,
5096 security_mode: values.AuthMode,
5097 cipher: values.cipher,
5098 NoForwarding: values.NoForwarding,
5099 show_qrcode_flag: values.show_qrcode_flag
5100 };
5101 if (config.WIFI_WEP_SUPPORT) {
5102 valueReq.wep_default_key = values.wep_default_key;
5103 valueReq.wep_key_1 = values.wep_key_1;
5104 valueReq.wep_key_2 = values.wep_key_2;
5105 valueReq.wep_key_3 = values.wep_key_3;
5106 valueReq.wep_key_4 = values.wep_key_4;
5107 if (values.wep_default_key == '1') {
5108 valueReq.WEP2Select = values.WEP2Select;
5109 } else if (values.wep_default_key == '2') {
5110 valueReq.WEP3Select = values.WEP3Select;
5111 } else if (values.wep_default_key == '3') {
5112 valueReq.WEP4Select = values.WEP4Select;
5113 } else {
5114 valueReq.WEP1Select = values.WEP1Select;
5115 }
5116 }
5117 if (values.AuthMode == "WPAPSK" || values.AuthMode == "WPA2PSK" || values.AuthMode == "WPAPSKWPA2PSK" || values.AuthMode == "WPA3Personal" || values.AuthMode == "WPA2WPA3") {
5118 valueReq.security_shared_mode = values.cipher;
5119 valueReq.passphrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;
5120 } else if (values.AuthMode == "SHARED") {
5121 valueReq.security_shared_mode = "WEP";
5122 valueReq.security_mode = "SHARED";
5123 } else {
5124 if (values.encryptType == "WEP") {
5125 valueReq.security_shared_mode = "WEP";
5126 valueReq.security_mode = "OPEN";
5127 } else {
5128 valueReq.security_shared_mode = "NONE";
5129 }
5130 }
5131 return valueReq;
5132 }
5133 function deal(paramD) {
5134 if (paramD) {
5135 return paramD;
5136 } else {
5137 return errUnknownObj;
5138 }
5139 }
5140 }
5141 function setWifiBasic4SSID2() {
5142 stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
5143 function prepare(values) {
5144 var valueReq = {
5145 goformId: "SET_WIFI_SSID2_SETTINGS",
5146 m_SSID: values.m_SSID,
5147 m_HideSSID: values.m_broadcast,
5148 m_MAX_Access_num: values.m_station,
5149 m_AuthMode: values.m_AuthMode,
5150 cipher: values.m_cipher,
5151 m_NoForwarding: values.m_NoForwarding,
5152 m_show_qrcode_flag: values.m_show_qrcode_flag
5153 };
5154 if (config.WIFI_WEP_SUPPORT) {
5155 valueReq.m_DefaultKeyID = values.m_wep_default_key;
5156 valueReq.m_Key1Str1 = values.m_wep_key_1;
5157 valueReq.m_Key2Str1 = values.m_wep_key_2;
5158 valueReq.m_Key3Str1 = values.m_wep_key_3;
5159 valueReq.m_Key4Str1 = values.m_wep_key_4;
5160 if (values.m_wep_default_key == '1') {
5161 valueReq.m_Key2Type = values.m_WEP2Select;
5162 } else if (values.m_wep_default_key == '2') {
5163 valueReq.m_Key3Type = values.m_WEP3Select;
5164 } else if (values.m_wep_default_key == '3') {
5165 valueReq.m_Key4Type = values.m_WEP4Select;
5166 } else {
5167 valueReq.m_Key1Type = values.m_WEP1Select;
5168 }
5169 }
5170 if (values.m_AuthMode == "WPAPSK" || values.m_AuthMode == "WPA2PSK" || values.m_AuthMode == "WPAPSKWPA2PSK" || values.m_AuthMode == "WPA3Personal" || values.m_AuthMode == "WPA2WPA3") {
5171 valueReq.m_EncrypType = values.m_cipher;
5172 valueReq.m_WPAPSK1 = config.PASSWORD_ENCODE ? Base64.encode(values.m_passPhrase) : values.m_passPhrase;
5173 } else if (values.m_AuthMode == "SHARED") {
5174 valueReq.m_EncrypType = "WEP";
5175 valueReq.m_security_mode = "SHARED";
5176 } else {
5177 if (values.m_encryptType == "WEP") {
5178 valueReq.m_EncrypType = "WEP";
5179 valueReq.m_security_mode = "OPEN";
5180 } else {
5181 valueReq.m_EncrypType = "NONE";
5182 }
5183 }
5184 return valueReq;
5185 }
5186 function deal(paramD) {
5187 if (paramD) {
5188 return paramD;
5189 } else {
5190 return errUnknownObj;
5191 }
5192 }
5193 }
5194 function getWifiBasic() {
5195 return stuffMake(arguments, {}, prepare, deal, null, false);
5196 function prepare(values, isPost) {
5197 var valueReq = {};
5198 var wpapsk = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "imei,rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";
5199 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";
5200 valueReq.multi_data = 1;
5201 return valueReq;
5202 }
5203 function deal(paramD) {
5204 if (paramD) {
5205 var result = {
5206 wifi_enable: paramD.wifi_cur_state == "1" ? "1" : "0",
5207 multi_ssid_enable: paramD.m_ssid_enable,
5208 MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,
5209 AuthMode: paramD.AuthMode,
5210 SSID: paramD.SSID1,
5211 broadcast: paramD.HideSSID,
5212 apIsolation: paramD.NoForwarding,
5213 passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),
5214 MAX_Access_num: paramD.MAX_Access_num,
5215 cipher: paramD.EncrypType == "TKIP" ? "0" : paramD.EncrypType == "AES" ? 1 : 2,
5216 encryptType: paramD.EncrypType,
5217 show_qrcode_flag: paramD.show_qrcode_flag == "1" ? true : false,
5218 keyID: paramD.DefaultKeyID,
5219 Key1Str1: paramD.Key1Str1,
5220 Key2Str1: paramD.Key2Str1,
5221 Key3Str1: paramD.Key3Str1,
5222 Key4Str1: paramD.Key4Str1,
5223 m_SSID: paramD.m_SSID,
5224 m_broadcast: paramD.m_HideSSID,
5225 m_apIsolation: paramD.m_NoForwarding,
5226 m_MAX_Access_num: paramD.m_MAX_Access_num,
5227 m_AuthMode: paramD.m_AuthMode,
5228 m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),
5229 m_cipher: paramD.m_EncrypType == "TKIP" ? "0" : paramD.m_EncrypType == "AES" ? 1 : 2,
5230 m_show_qrcode_flag: paramD.m_show_qrcode_flag == "1" ? true : false,
5231 m_encryptType: paramD.m_EncrypType,
5232 m_keyID: paramD.m_DefaultKeyID,
5233 m_Key1Str1: paramD.m_Key1Str1,
5234 m_Key2Str1: paramD.m_Key2Str1,
5235 m_Key3Str1: paramD.m_Key3Str1,
5236 m_Key4Str1: paramD.m_Key4Str1,
5237 rotationFlag: paramD.rotationFlag,
5238 ap_station_enable: paramD.wifi_sta_connection
5239 };
5240 return result;
5241 } else {
5242 return errUnknownObj;
5243 }
5244 }
5245 }
5246 function setWifiBasicMultiSSIDSwitch() {
5247 stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
5248 function prepare(values) {
5249 var paraTemp = values;
5250 if (values.wifiEnabled == '0') {
5251 paraTemp = {
5252 wifiEnabled: values.wifiEnabled
5253 }
5254 }
5255 var valueReq = $.extend({
5256 goformId: "SET_WIFI_INFO",
5257 }, paraTemp);
5258 return valueReq;
5259 }
5260 function deal(paramD) {
5261 if (paramD) {
5262 return paramD;
5263 } else {
5264 return errUnknownObj;
5265 }
5266 }
5267 }
5268 function stuffMake(array, result, prepare, dealMethod, errorObject, isPost) {
5269 var values = array[0],
5270 callback = array[1],
5271 errorCallback = array[2];
5272 var objectToReturn;
5273 if (result && typeof result.errorType === 'string') {
5274 objectToReturn = $.extend(errUnknownObj, result);
5275 if (!callback) {
5276 return objectToReturn;
5277 }
5278 doCallback(objectToReturn, callback, errorCallback);
5279 } else {
5280 objectToReturn = $.extend({}, result);
5281 var valueReq;
5282 if (prepare) {
5283 valueReq = prepare(values, isPost);
5284 } else {
5285 valueReq = values;
5286 }
5287 if (!callback) {
5288 if (valueReq && (valueReq.cmd || valueReq.goformId)) {
5289 var r = reqSync(valueReq, isPost);
5290 if (dealMethod) {
5291 objectToReturn = $.extend({}, dealMethod(r));
5292 } else {
5293 objectToReturn = r;
5294 }
5295 }
5296 return objectToReturn;
5297 } else {
5298 if (valueReq && (valueReq.cmd || valueReq.goformId)) {
5299 reqAsync(valueReq, function (paramD) {
5300 if (dealMethod) {
5301 objectToReturn = $.extend({}, dealMethod(paramD));
5302 } else {
5303 objectToReturn = $.extend({}, paramD);
5304 }
5305 if (!valueReq.notCallback) {
5306 doCallback(objectToReturn, callback, errorCallback);
5307 }
5308 }, function () {
5309 if (errorObject) {
5310 objectToReturn = $.extend(errUnknownObj, errorObject);
5311 } else {
5312 objectToReturn = $.extend(errUnknownObj, {
5313 errorType: 'Unknown'
5314 });
5315 }
5316 doCallback(objectToReturn, callback, errorCallback);
5317 }, isPost);
5318 } else {
5319 doCallback(objectToReturn, callback, errorCallback);
5320 }
5321 }
5322 }
5323 function doCallback(resultToReturn, callback, errorCallback) {
5324 errorCallback = errorCallback ? errorCallback : callback;
5325 if (isErrorObject(resultToReturn)) {
5326 switch (resultToReturn.errorType) {
5327 case 'cellularNetworkError':
5328 case 'deviceError':
5329 case 'wifiConnectionError':
5330 window.receivedNonSpecificError(resultToReturn);
5331 break;
5332 default:
5333 errorCallback(resultToReturn);
5334 }
5335 } else {
5336 callback(resultToReturn);
5337 }
5338 }
5339 }
5340 function reqSync(values, isPost) {
5341 return reqAJAX(values, null, null, false, isPost);
5342 }
5343 function reqAsync(values, successCallback, errorCallback, isPost) {
5344 reqAJAX(values, successCallback, errorCallback, true, isPost);
5345 }
5346 function getString(values){
5347 var regexp = /^[A-z0-9]+$/;
5348 var matches = values.match(regexp);
5349 if (matches == null){
5350 return "error";
5351 } else {
5352 return values;
5353 }
5354 }
5355 function reqAJAX(values, successCallback, errorCallback, async, isPost) {
5356 var result = null;
5357 $.ajax({
5358 type: !!isPost ? "POST" : "GET",
5359 url: isPost ? "/reqproc/proc_post" : values.cmd ? "/reqproc/proc_get" : "/reqproc/proc_post",
5360 data: values,
5361 dataType: "json",
5362 async: !!async,
5363 cache: false,
5364 error: function (paramD) {
5365 if (async) {
5366 errorCallback(paramD);
5367 } else if (paramD.status == 200) {
5368 result = jQuery.parseJSON('(' + getString(paramD.responseText) + ')');
5369 }
5370 },
5371 success: function (paramD) {
5372 if (async) {
5373 successCallback(paramD);
5374 } else {
5375 result = paramD;
5376 }
5377 }
5378 });
5379 if (!async) {
5380 return result;
5381 }
5382 }
5383 var informationAll = {
5384 networkType: "",
5385 signalImg: "0",
5386 spn_b1_flag: "1",
5387 spn_name_data: "",
5388 spn_b2_flag: "1",
5389 networkOperator: "China Mobile",
5390 connectStatus: "ppp_disconnected",
5391 rj45ConnectStatus: "rj45_dead",
5392 attachedDevices: [],
5393 ssid1AttachedNum: 0,
5394 ssid2AttachedNum: 0,
5395 data_counter: {
5396 uploadRate: 0,
5397 downloadRate: 0,
5398 totalSent: 0,
5399 totalReceived: 0,
5400 totalConnectedTime: 0,
5401 currentSent: 0,
5402 currentReceived: 0,
5403 currentConnectedTime: 0,
5404 monthlySent: 0,
5405 monthlyReceived: 0,
5406 monthlyConnectedTime: 0,
5407 month: ''
5408 },
5409 newSmsReceived: false,
5410 smsReportReceived: false,
5411 smsUnreadCount: "0",
5412 isLoggedIn: undefined,
5413 limitVolumeEnable: false,
5414 limitVolumeType: '1',
5415 limitVolumePercent: "100",
5416 limitVolumeSize: "0",
5417 allowRoamingUpdate: "0",
5418 blc_wan_mode: "",
5419 ap_station_enable: undefined,
5420 ap_station_mode: undefined,
5421 dialMode: '',
5422 ethWanMode: 'AUTO',
5423 fota_user_selector: '',
5424 defaultWanName: ""
5425 };
5426 var errUnknownObj = {
5427 errorType: 'UnknownError',
5428 errorId: '123',
5429 errorText: 'UnknownError'
5430 };
5431 var updateTimerFlag = true;
5432 return {
5433 clearRedirectFlag: clearRedirectFlag,
5434 connect: connect,
5435 disconnect: disconnect,
5436 getSIMPhoneBookCapacity: getSIMPhoneBookCapacity,
5437 getDevicePhoneBookCapacity: getDevicePhoneBookCapacity,
5438 getDevicePhoneBooks: getDevicePhoneBooks,
5439 getSIMPhoneBooks: getSIMPhoneBooks,
5440 getPhoneBooks: getPhoneBooks,
5441 getPhoneBookReady: getPhoneBookReady,
5442 getPhoneBooksByGroup: getPhoneBooksByGroup,
5443 deletePhoneBooks: deletePhoneBooks,
5444 deleteAllPhoneBooks: deleteAllPhoneBooks,
5445 deleteAllPhoneBooksByGroup: deleteAllPhoneBooksByGroup,
5446 savePhoneBook: savePhoneBook,
5447 deleteAllMessages: deleteAllMessages,
5448 deleteMessage: deleteMessage,
5449 setSmsRead: setSmsRead,
5450 sendSMS: sendSMS,
5451 saveSMS: saveSMS,
5452 getSMSReady: getSMSReady,
5453 getSMSMessages: getSMSMessages,
5454 getSMSDeliveryReport: getSMSDeliveryReport,
5455 getSmsCapability: getSmsCapability,
5456 resetNewSmsReceivedVar: resetNewSmsReceivedVar,
5457 resetSmsReportReceivedVar: resetSmsReportReceivedVar,
5458 getSmsSetting: getSmsSetting,
5459 setSmsSetting: setSmsSetting,
5460 getAttachedCableDevices: getAttachedCableDevices,
5461 getCurrentlyAttachedDevicesInfo: getCurrentlyAttachedDevicesInfo,
5462 getConnectionInfo: getConnectionInfo,
5463 getRedirectData: getRedirectData,
5464 getLanguage: getLanguage,
5465 setLanguage: setLanguage,
5466 getNetSelectInfo: getNetSelectInfo,
5467 getSecurityInfo: getSecurityInfo,
5468 setSecurityInfo: setSecurityInfo,
5469 getStatusInfo: getStatusInfo,
5470 getConnectionMode: getConnectionMode,
5471 setConnectionMode: setConnectionMode,
5472 getWifiBasic: getWifiBasic,
5473 setWifiBasic: setWifiBasic,
5474 setWifiBasic4SSID2: setWifiBasic4SSID2,
5475 setWifiBasicMultiSSIDSwitch: setWifiBasicMultiSSIDSwitch,
5476 getWpsInfo: getWpsInfo,
5477 openWps: openWps,
5478 getSleepMode: getSleepMode,
5479 setSleepMode: setSleepMode,
5480 getWifiAdvance: getWifiAdvance,
5481 setWifiAdvance: setWifiAdvance,
5482 getWifiRange: getWifiRange,
5483 setWifiRange: setWifiRange,
5484
5485 getLoginStatus: getLoginStatus,
5486 getLoginData: getLoginData,
5487 login: login,
5488 logout: logout,
5489 changeManageInfo: changeManageInfo,
5490 getPinData: getPinData,
5491 enablePin: enablePin,
5492 disablePin: disablePin,
5493 changePin: changePin,
5494 enterPIN: enterPIN,
5495 enterPUK: enterPUK,
5496 getLanInfo: getLanInfo,
5497 setLanInfo: setLanInfo,
5498 getApnSettings: getApnSettings,
mj.quca0a6942025-01-06 22:36:07 -08005499 getNetworkStatus: getNetworkStatus,
qumengjia1cd76022024-10-31 17:51:04 +08005500 deleteApn: deleteApn,
5501 setDefaultApn: setDefaultApn,
5502 addOrEditApn: addOrEditApn,
5503 getQuickSettingInfo: getQuickSettingInfo,
5504 setQuickSetting4IPv6: setQuickSetting4IPv6,
5505 scanForNetwork: scanForNetwork,
5506 setBearerPreference: setBearerPreference,
5507 editHostName: editHostName,
5508 getSiteWhiteList: getSiteWhiteList,
5509 removeSiteWhite: removeSiteWhite,
5510 saveSiteWhite: saveSiteWhite,
5511 setNetwork: setNetwork,
5512 getUpnpSetting: getUpnpSetting,
5513 setUpnpSetting: setUpnpSetting,
5514 getDmzSetting: getDmzSetting,
5515 setDmzSetting: setDmzSetting,
5516 getDeviceInfo: getDeviceInfo,
5517 getDeviceInfoLow: getDeviceInfoLow,
5518 getPortForward: getPortForward,
5519 setPortForward: setPortForward,
5520 getPortFilter: getPortFilter,
5521 setPortFilterBasic: setPortFilterBasic,
5522 setPortFilter: setPortFilter,
5523 deleteFilterRules: deleteFilterRules,
5524 getPortMap: getPortMap,
5525 setPortMap: setPortMap,
5526 enablePortMap: enablePortMap,
5527 deleteMapRules: deleteMapRules,
5528 getTrafficAlertInfo: getTrafficAlertInfo,
5529 setTrafficAlertInfo: setTrafficAlertInfo,
5530 getCurrentUpgradeState: getCurrentUpgradeState,
5531 setUpgradeSelectOp: setUpgradeSelectOp,
5532 addTimerThings: addTimerSomething,
5533 removeTimerThings: removeTimerSomething,
5534 getPackSizeInfo: getPackSizeInfo,
5535 getMandatory: getMandatory,
5536 getOTAUpdateSetting: getOTAUpdateSetting,
5537 setOTAUpdateSetting: setOTAUpdateSetting,
w.deng3816b832024-11-01 16:01:30 +08005538 getManualOTAUpdateSetting: getManualOTAUpdateSetting,
5539 setManualOTAUpdateSetting: setManualOTAUpdateSetting,
qumengjia1cd76022024-10-31 17:51:04 +08005540 getSignalStrength: getSignalStrength,
5541 getOTAlastCheckTime: getOTAlastCheckTime,
5542 clearUpdateResult: clearUpdateResult,
5543 refreshAPStationStatus: refreshAPStationStatus,
5544 getSntpParams: getSntpParams,
5545 setSntpSetting: setSntpSetting,
5546 setSNTPDate: setSNTPDate,
5547 restoreFactorySettings: restoreFactorySettings,
5548 checkRestoreStatus: checkRestoreStatus,
5549 getSysSecurity: getSysSecurity,
5550 setSysSecurity: setSysSecurity,
5551 deleteForwardRules: deleteForwardRules,
5552 enableVirtualServer: enableVirtualServer,
5553 getSDConfiguration: getSDConfiguration,
5554 setSdCardMode: setSdCardMode,
5555 checkFileExists: checkFileExists,
5556 getFileList: getFileList,
5557 fileRename: fileRename,
5558 getSdMemorySizes: getSdMemorySizes,
5559 deleteFilesAndFolders: deleteFilesAndFolders,
5560 createFolder: createFolder,
5561 setSdCardSharing: setSdCardSharing,
5562 setUpdateInfoWarning: setUpdateInfoWarning,
5563 getUpdateInfoWarning: getUpdateInfoWarning,
5564 getAPStationBasic: getAPStationBasic,
5565 setAPStationBasic: setAPStationBasic,
5566 getWdsInfo: getWdsInfo,
5567 setWDS: setWDS,
5568 addUrlFilterRule: addUrlFilterRule,
5569 getUrlFilterList: getUrlFilterList,
5570 deleteSelectedRules: deleteSelectedRules,
5571 getMacFilterInfo: getMacFilterInfo,
5572 setMacFilter: setMacFilter,
5573 getFastbootSetting: getFastbootSetting,
5574 setFastbootSetting: setFastbootSetting,
5575 turnOffDevice: turnOffDevice,
5576 restart: restart,
5577 getScheduleSetting: getScheduleSetting,
5578 setScheduleSetting: setScheduleSetting,
5579 getPingResult: getPingResult,
5580 pingResultClear: pingResultClear,
5581 getPingSetting: getPingSetting,
5582 setPingSettingStart: setPingSettingStart,
5583 updateTimerFlag: updateTimerFlag,
5584 childGroupList: childGroupList,
5585 addChildGroup: addChildGroup,
5586 removeChildGroup: removeChildGroup,
5587 checkCurrentUserInChildGroup: checkCurrentUserInChildGroup,
5588 getTimeLimited: getTimeLimited,
5589 saveTimeLimited: saveTimeLimited,
5590 getHostNameList: getHostNameList,
5591 getHotspotList: getHotspotList,
5592 searchHotspot: searchHotspot,
5593 getSearchHotspotList: getSearchHotspotList,
5594 saveHotspot: saveHotspot,
5595 deleteHotspot: deleteHotspot,
5596 connectHotspot: connectHotspot,
5597 disconnectHotspot: disconnectHotspot,
5598 getOpMode: getOpMode,
5599 getRj45PlugState: getRj45PlugState,
5600 SetOperationMode: SetOperationMode,
5601 getPppoeParams: getPppoeParams,
5602 setPppoeDialMode: setPppoeDialMode,
5603 getTsw: getTsw,
5604 saveTsw: saveTsw,
5605 trafficCalibration: trafficCalibration,
5606 getParams: getParams,
5607 getNewVersionState: getNewVersionState,
5608 getUpgradeResult: getUpgradeResult,
5609 getV4Switch: getV4Switch,
5610 setV4Switch: setV4Switch,
5611 getCellId: getCellId,
5612 setCellIdSwitch: setCellIdSwitch,
5613 getDdnsParams: getDdnsParams,
5614 setDDNSForward: setDDNSForward,
5615 getUpdateType: getUpdateType,
5616 getCurretnMAC: getCurretnMAC,
5617 getUSSDResponse: getUSSDResponse,
5618 USSDReplyCancel: USSDReplyCancel,
5619 getNetworkUnlockTimes: getNetworkUnlockTimes,
5620 unlockNetwork: unlockNetwork,
5621 getSyslogInfo: getSyslogInfo,
5622 setSysLog: setSysLog,
5623 };
5624});
5625
5626 // Router����
5627
5628define("adm_lan","jquery knockout set service".split(" "),
5629
5630 function ($, ko, config, service) {
5631
5632 var originfrmLan = "";
5633
5634 // ��ȡ·������������Ϣ
5635 function getLanInfo() {
5636 return service.getLanInfo();
5637 }
5638
5639 function hex(val) {
5640 var h = (val - 0).toString(16);
5641 if (h.length == 1)
5642 h = '0' + h;
5643 return h.toUpperCase();
5644 }
5645
5646 function LanViewModel() {
5647 var target = this;
5648
5649 var info = getLanInfo();
5650
5651 target.dhcpStart = ko.observable(info.dhcpStart);
5652 target.dhcpEnd = ko.observable(info.dhcpEnd);
5653 target.dhcpLease = ko.observable(info.dhcpLease);
5654
5655 target.ipAddress = ko.observable(info.ipAddress);
5656 target.subnetMask = ko.observable(info.subnetMask);
5657 target.dhcpServer = ko.observable(info.dhcpServer);
5658
5659 target.macAddress = ko.observable(info.macAddress);
5660 target.showMacAddress = ko.observable(config.SHOW_MAC_ADDRESS);
5661
5662 target.hasWifi = ko.observable(config.HAS_WIFI);
5663 target.hasUssd = config.HAS_USSD;
5664 target.hasDdns = config.DDNS_SUPPORT;
5665
5666 target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
5667
5668 target.clear = function () {
5669 clearTimer();
5670 init();
5671 clearValidateMsg();
5672 };
5673
5674 target.refreshStatus = function () {
5675 var connInfo = service.getConnectionInfo();
5676 if (connInfo.connectStatus == 'ppp_disconnected') {
5677 $('input', '#frmLan').each(function () {
5678 $(this).attr("disabled", false);
5679 });
5680 } else {
5681 $('input', '#frmLan').each(function () {
5682 $(this).attr("disabled", true);
5683 });
5684
5685 clearValidateMsg();
5686 }
5687 };
5688
5689 // ������Ӧ�������������ñ���
5690 target.saveAct = function () {
5691 showLoading();
5692 var params = {
5693 ipAddress: target.ipAddress(),
5694 subnetMask: target.subnetMask(),
5695 dhcpServer: target.dhcpServer(),
5696 dhcpStart: target.dhcpStart(),
5697 dhcpEnd: target.dhcpEnd(),
5698 dhcpLease: target.dhcpLease()
5699 };
5700
5701 service.setLanInfo(params, function (result) {
5702 if (result.result == "success") {
5703 successOverlay();
5704 target.clear();
5705 } else {
5706 errorOverlay();
5707 }
5708 });
5709 };
5710
5711 // ������Ӧ�������������ñ���
5712 target.save = function () {
5713 var frmLanObj = $('#frmLan').serialize();
5714 if (frmLanObj == originfrmLan) {
5715 showAlert("setting_no_change");
5716 return false;
5717 }
5718 if (config.RJ45_SUPPORT) {
5719 var pppObj = service.getPppoeParams();
5720 if (sf_isValidate_StaticIP(pppObj.static_wan_ipaddr, target.ipAddress(), target.subnetMask())) {
5721 showAlert("lan_tip_staticip_notsame");
5722 return false;
5723 }
5724 }
5725 showConfirm("lan_confirm_reopen", function () {
5726 target.saveAct();
5727 });
5728 };
5729
5730 target.refreshStatus();
5731 // dhcpServer�л���Ӧ����
5732 target.dhcpServerHandler = function () {
5733 $("#txtIpAddress").parent().find(".error").hide();
5734 $("#txtIpAddress").show();
5735 return true;
5736 };
5737 addTimeout(function () {
5738 originfrmLan = $('#frmLan').serialize();
5739 }, 500);
5740 }
5741
5742
5743 function sf_opAnd4Byte(i_v1, i_v2) {
5744 var index;
5745 var var1 = [];
5746 var var2 = [];
5747 var result='0x';
5748
5749 for (index=2,index_tmp=0; index<10; index+=2,index_tmp++) {
5750 var1[index_tmp]='0x'+i_v1.substring(index,index+2);
5751 var2[index_tmp]='0x'+i_v2.substring(index,index+2);
5752 }
5753
5754 for (index=0; index<4; index++) {
5755 result = result + hex(var1[index]&var2[index]);
5756 }
5757
5758 return result - 0;
5759 }
5760
5761 // �������ر���У������
5762 $.validator.addMethod("dhcp_check", function (i_value, i_element, i_parameter) {
5763 var dhcpIp = i_parameter == "start" ? $('#txtDhcpIpPoolStart').val() : $('#txtDhcpIpPoolEnd').val();
5764 var result = sf_isValidate_Gateway($('#txtIpAddress').val(), $('#txtSubnetMask').val(), dhcpIp);
5765 return this.optional(i_element) || result;
5766 });
5767
5768 $.validator.addMethod("dhcpCompare", function (i_value, i_element, i_parameter) {
5769 var result;
5770 if(i_parameter == "#txtDhcpIpPoolStart") {
5771 result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), $(i_parameter).val(), i_value);
5772 }
5773 else {
5774 result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), i_value, $(i_parameter).val());
5775 }
5776 return result != 1;
5777 });
5778
5779 $.validator.addMethod("ipRange", function (i_value, i_element, i_parameter) {
5780 var DHCP_flag = false;
5781 if($('#dhcpEnable').is(':checked')){
5782 DHCP_flag = true;
5783 }
5784 var result = sf_isValidate_StartEndIp(i_value, $('#txtSubnetMask').val(), $('#txtDhcpIpPoolStart').val(), $('#txtDhcpIpPoolEnd').val(), DHCP_flag);
5785 return result != 2;
5786 });
5787
5788 $.validator.addMethod("subnetmask_check", function (i_value, i_element, i_parameter) {
5789 var result = sf_isValidate_Netmask(i_value);
5790 return this.optional(i_element) || result;
5791 });
5792
5793
5794 // ��̬��ЧIPУ�麯��
5795 function sf_isValidate_StaticIP(i_ip, i_lanIp, i_lanMask){
5796 if(!i_ip || !i_lanIp || !i_lanMask){//������������
5797 return false;
5798 }
5799
5800 //������IP����
5801 if (i_ip == i_lanIp) {
5802 return true;
5803 }
5804
5805 var res1 = [];
5806 var res2 = [];
5807
5808 var mask_array = [];
5809
5810 ip_array = i_ip.split(".");
5811 lanIp_array = i_lanIp.split(".");
5812 mask_array = i_lanMask.split(".");
5813 for(var index = 0; index < ip_array.length; index += 1){
5814 res1.push(parseInt(mask_array[index]) & parseInt(ip_array[index]));
5815 res2.push(parseInt(mask_array[index]) & parseInt(lanIp_array[index]));
5816 }
5817 if(res2.join(".") != res1.join(".")){//�ڲ�ͬ����
5818 return false;
5819 }else{//��ͬһ����
5820 return true;
5821 }
5822 }
5823
5824
5825 function sf_isValidate_NetmaskIP(i_ip) {
5826 return (i_ip == 255
5827 || i_ip == 254
5828 || i_ip == 252
5829 || i_ip == 248
5830 || i_ip == 240
5831 || i_ip == 224
5832 || i_ip == 192
5833 || i_ip == 128
5834 || i_ip == 0);
5835 }
5836
5837 function sf_convertIpToString(i_ip)
5838 {
5839 var s_i1 = i_ip.indexOf('.');
5840 var s_i2 = i_ip.indexOf('.', (s_i1 + 1));
5841 var s_i3 = i_ip.indexOf('.', (s_i2 + 1));
5842 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));
5843 o_ip = '0x' + o_ip;
5844
5845 return o_ip;
5846 }
5847
5848 function sf_getIpString_3(i_ip)
5849 {
5850 var i1 = i_ip.indexOf('.');
5851 var i2 = i_ip.indexOf('.', (i1 + 1));
5852 var i3 = i_ip.indexOf('.', (i2 + 1));
5853 var i4 = i_ip.substring((i3+1),i_ip.length)-0;
5854
5855 return i4;
5856 }
5857
5858
5859 // ����У�麯��
5860 function sf_isValidate_Gateway(i_wanIp, i_netmaskIp, i_gatewayIp) {
5861 var s_wanIp = sf_convertIpToString(i_wanIp);
5862 var lan4 = sf_getIpString_3(i_wanIp);
5863
5864 var s_netmaskIp = sf_convertIpToString(i_netmaskIp);
5865 var mask4 = sf_getIpString_3(i_netmaskIp);
5866
5867 var s_gatewayIp = sf_convertIpToString(i_gatewayIp);
5868 var pool4 = sf_getIpString_3(i_gatewayIp);
5869
5870 var net_no;
5871 var lo_broadcast;
5872
5873 if (sf_opAnd4Byte(s_wanIp, s_netmaskIp) != sf_opAnd4Byte(s_gatewayIp, s_netmaskIp)) {
5874 return false;
5875 }
5876
5877 net_no = (lan4 & mask4);
5878 lo_broadcast = (lan4 & mask4) + (255-mask4);
5879
5880 return !(pool4==net_no || pool4==lo_broadcast);
5881
5882 }
5883
5884 // ��������У�麯��
5885 function sf_isValidate_Netmask(i_netmask) {
5886 var addr = i_netmask.split(".");
5887
5888 if ("0.0.0.0" == i_netmask || "255.255.255.255" == i_netmask) {
5889 return false;
5890 }
5891
5892 if (addr.length != 4) {
5893 return false;
5894 }
5895
5896 addr[0] = parseInt(addr[0]);
5897 addr[1] = parseInt(addr[1]);
5898 addr[2] = parseInt(addr[2]);
5899 addr[3] = parseInt(addr[3]);
5900
5901 if (addr[3] != 0) {
5902 if (addr[0] != 255 || addr[1] != 255 || addr[2] != 255) {
5903 return false;
5904 } else {
5905 if (!sf_isValidate_NetmaskIP(addr[3])) {
5906 return false;
5907 }
5908 }
5909 }
5910
5911 if (addr[2] != 0) {
5912 if (addr[0] != 255 || addr[1] != 255) {
5913 return false;
5914 } else {
5915 if (!sf_isValidate_NetmaskIP(addr[2])) {
5916 return false;
5917 }
5918 }
5919 }
5920
5921 if (addr[1] != 0) {
5922 if (addr[0] != 255) {
5923 return false;
5924 } else {
5925 if (!sf_isValidate_NetmaskIP(addr[1])) {
5926 return false;
5927 }
5928 }
5929 }
5930
5931 if (addr[0] != 255) {
5932 return false;
5933 }
5934
5935 return true;
5936 }
5937
5938 // DHCP IP��У�麯��
5939 function sf_isValidate_StartEndIp(i_lanIpaddr, i_netIp, i_startIp, i_endIp, i_DHCPFlag) {
5940 s_startIp = sf_convertIpToString(i_startIp);
5941 s_endIp = sf_convertIpToString(i_endIp);
5942 s_lanIp = sf_convertIpToString(i_lanIpaddr);
5943
5944 if(s_startIp>s_endIp) {
5945 return 1;
5946 }
5947
5948 if(s_lanIp >= s_startIp && s_lanIp <= s_endIp) {
5949 return 2;
5950 }
5951
5952 return 0;
5953 }
5954
5955
5956 function init() {
5957 var container = $('#container');
5958 ko.cleanNode(container[0]);
5959 var fwVm = new LanViewModel();
5960 ko.applyBindings(fwVm, container[0]);
5961
5962 addInterval(fwVm.refreshStatus, 1000);
5963
5964 $('#frmLan').validate({
5965 submitHandler:function () {
5966 fwVm.save();
5967 },
5968
5969 rules:{
5970 txtIpAddress: {
5971 lanip_check: true,
5972 ipRange: true
5973 },
5974 txtSubnetMask: {
5975 ipv4: true,
5976 subnetmask_check: true
5977 },
5978 txtDhcpIpPoolStart: {
5979 lanip_check: true,
5980 dhcp_check: "start",
5981 dhcpCompare: "#txtDhcpIpPoolEnd"
5982 },
5983 txtDhcpIpPoolEnd: {
5984 lanip_check: true,
5985 dhcp_check: "end",
5986 dhcpCompare: "#txtDhcpIpPoolStart"
5987 },
5988 txtDhcpLease: {
5989 range: [1, 65535],
5990 digits: true
5991 }
5992 },
5993
5994 groups: {
5995 lanip_check: "txtDhcpIpPoolStart txtDhcpIpPoolEnd"
5996 },
5997
5998 errorPlacement: function (error, element) {
5999 if (element.attr("name") == "txtDhcpLease") {
6000 error.insertAfter("#errorHolder");
6001 } else if (element.attr("name") == "txtDhcpIpPoolStart") {
6002 error.insertAfter("#txtDhcpIpPoolEnd");
6003 } else {
6004 error.insertAfter(element);
6005 }
6006 }
6007 });
6008
6009 }
6010
6011
6012 return {
6013 init:init
6014 }
6015});
6016
6017// others �����:Fast Boot Settings��Restart and Reset��SNTP��Turn Off Device��PIN Management
6018define("adm_others","jquery knockout set service underscore".split(" "),
6019
6020 function ($, ko, config, service, _) {
6021
6022 var timeSetModes = _.map(config.sntpTimeSetMode, function(item) {
6023 return new Option(item.name, item.value);
6024 });
6025
6026 var timeZones = _.map(config.timeZone, function(item){
6027 return new Option(item.name, item.value);
6028 });
6029
6030 var daylightSave = _.map(config.daylightSave, function(item){
6031 return new Option(item.name, item.value);
6032 });
6033
6034 var sv_sntpYears = [];
6035 var sv_sntpMonths = [];
6036 var sv_sntpDates = []; //���ݴ�С����������
6037 var sv_sntpHours = [];
6038 var sv_sntpMinutes = [];
6039 var sc_startpHours = [];
6040 var sc_startMinutes = [];
6041 var sc_pingTimes = [];
6042
6043 var sf_bigMonth = [1, 3, 5, 7, 8, 10, 12];
6044 var sf_smallMonth = [4, 6, 9, 11];
6045
6046 function sf_produceArray(start, end, arryName) {
6047 var item = {};
6048 for(var i = start; i <= end; i++) {
6049 item.name = i;
6050 item.value = i;
6051 arryName.push(new Option(item.name, item.value));
6052 }
6053 }
6054
6055 //�����ꡢ�¡�ʱ���ֵ�����
mj.qu2d3c2af2025-06-22 23:23:15 -07006056 sf_produceArray(2000, 2037, sv_sntpYears);
qumengjia1cd76022024-10-31 17:51:04 +08006057 sf_produceArray(1, 12, sv_sntpMonths);
6058 sf_produceArray(0, 23, sv_sntpHours);
6059 sf_produceArray(0, 59, sv_sntpMinutes);
6060 sf_produceArray(0, 23, sc_startpHours);
6061 sf_produceArray(0, 59, sc_startMinutes);
6062 sf_produceArray(0, 59, sc_startMinutes);
6063 sf_produceArray(1, 10, sc_pingTimes);
6064
6065 function othersViewModel() {
6066 var target = this;
6067
6068 var inChildGroup = false;
6069 var scheduleInfo = service.getScheduleSetting();
6070 var pingDiagInfo = service.getPingSetting();
6071
6072 target.fastbootSupport = config.FAST_BOOT_SUPPORT;
6073 target.turnOffSupport = config.TURN_OFF_SUPPORT;
6074 target.SNTPSupport = config.HAS_SNTP;
6075 target.hasUssd = config.HAS_USSD;
6076 target.hasDdns = config.DDNS_SUPPORT;
6077 target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
6078 target.scheduleSetting = ko.observable(scheduleInfo.scheduleSetting);
6079 target.scheduleHour = ko.observable(parseInt(scheduleInfo.scheduleHour));
6080 target.scheduleMinute = ko.observable(parseInt(scheduleInfo.scheduleMinute));
6081 target.scr_hours = ko.observableArray(sc_startpHours);
6082 target.scr_minutes = ko.observableArray(sc_startMinutes);
6083 target.src_times = ko.observableArray(sc_pingTimes);
6084 target.pingTimes = ko.observable(pingDiagInfo.pingTimes);
6085 target.pingURL = ko.observable(pingDiagInfo.pingURL);
6086
6087
6088 if (config.HAS_PARENTAL_CONTROL) {
6089 inChildGroup = service.checkCurrentUserInChildGroup().result;
6090 }
6091 target.currentUserInChildGroup = ko.observable(inChildGroup);
6092
6093 var sv_fastbootInfo = service.getFastbootSetting();
6094 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");
6095 target.fastbootSetting = ko.observable(sv_fastbootInfo.fastbootEnabled);
6096
6097
6098 // @method addInterval
6099 addInterval(function(){
6100 target.fastbootEnableFlag(config.RJ45_SUPPORT ? (sv_fastbootInfo.need_sim_pin != "yes" && service.getRj45PlugState().rj45_plug == "wan_lan_off") : sv_fastbootInfo.need_sim_pin != "yes");
6101 }, 1000);
6102
6103 // �ָ���������
6104 // @event restore
6105 target.restore = function () {
6106 showConfirm("restore_confirm", function () {
6107 showLoading("restoring");
6108 service.restoreFactorySettings({}, function (info) {
6109 if (info && info.result == "success") {
6110 successOverlay();
6111 } else {
6112 errorOverlay();
6113 }
6114 }, function (result) {
6115 if (isErrorObject(result) && result.errorType == 'no_auth') {
6116 errorOverlay();
6117 }
6118 });
6119 });
6120 };
6121
6122 target.restart = function () {
6123 showConfirm("restart_confirm", function () {
6124 restartDevice(service);
6125 });
6126 };
6127
6128 target.scheduleRestart = function () {
6129 showLoading();
6130 var params = {};
6131 params.scheduleSetting = target.scheduleSetting();
6132 params.scheduleHour = target.scheduleHour();
6133 params.scheduleMinute = target.scheduleMinute();
6134 service.setScheduleSetting(params, function (result) {
6135 if (result.result != "success") {
6136 errorOverlay();
6137 } else {
6138 successOverlay();
6139 }
6140 });
6141 };
6142
6143 target.pingResult = ko.observable();
6144
6145 target.loadFileContent = function() {
6146 var newPingResInfo = service.getPingResult();
6147 if (newPingResInfo.pingResult !== target.pingResult()) {
6148 target.pingResult(newPingResInfo.pingResult);
6149 }
6150 };
6151
6152 function showinfo(msgObj, minHeight) {
6153 var option = {
6154 title: 'info',
6155 img: 'pic/res_info.png',
6156 msg: msgObj,
6157 minHeight: minHeight
6158 };
6159 popup(option);
mj.qu8dce7222025-01-06 00:52:12 -08006160
qumengjia1cd76022024-10-31 17:51:04 +08006161 $('#yesbtn, #nobtn, #okbtn').hide();
mj.qu8dce7222025-01-06 00:52:12 -08006162
qumengjia1cd76022024-10-31 17:51:04 +08006163 setTimeout(function() {
6164 $.modal.close();
6165 }, 1000);
6166 }
mj.qu8dce7222025-01-06 00:52:12 -08006167
qumengjia1cd76022024-10-31 17:51:04 +08006168 setInterval(target.loadFileContent, 1000);
6169
6170 target.pingStart = function () {
6171 showinfo('ping_starting');
6172 var params = {};
6173 params.pingTimes = target.pingTimes();
6174 params.pingURL = target.pingURL();
6175 service.setPingSettingStart(params, function (result) {
6176 if (result.result != "success") {
6177 errorOverlay();
6178 }
6179 });
6180 };
6181
6182 target.pingClear = function () {
6183 showLoading();
6184 service.pingResultClear({}, function (result) {
6185 if (result.result != "success") {
6186 errorOverlay();
6187 } else {
6188 successOverlay();
6189 }
6190 });
6191 };
6192
6193 // ���ٿ��ػ�����
6194 target.saveFastBoot = function() {
6195 showLoading();
6196 var params = {
6197 fastbootEnabled: target.fastbootSetting(),
6198 need_hard_reboot: sv_fastbootInfo.need_hard_reboot
6199 };
6200 service.setFastbootSetting(params, function(result) {
6201 if (result.result == "success") {
6202 successOverlay();
6203 } else {
6204 errorOverlay();
6205 }
6206 });
6207 };
6208
6209 // �ػ�
6210 target.turnoff = function () {
6211 showConfirm("turnoff_confirm", function () {
6212 showLoading("turnoff");
6213 service.turnOffDevice({}, function (info) {
6214 if (info && info.result == "success") {
6215 successOverlay();
6216 } else {
6217 errorOverlay();
6218 }
6219 }, $.noop);
6220 });
6221 };
6222
6223 //SNTP����serverУ׼ʱ��
6224 service.setSNTPDate({
6225 goformId: "SNTP_Getdatastatic"
6226 });
6227
6228 var target = this;
6229 var sntpInfo = service.getSntpParams();
6230
6231 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));
6232
6233 target.day = ko.observable();
6234 target.localTime = ko.observable();
6235
6236 //��ʼ����ǰ����ʱ��
6237 //target.updateCurrentTime; cov_2
6238 target.timeSetModes = ko.observableArray(timeSetModes);
6239 target.isManualSetTime = ko.observable(false);
6240 target.isAutoSntpTime = ko.observable(false);
6241
6242 target.currentMode = ko.observable(sntpInfo.sntp_time_set_mode);
6243
6244 changeSetTimeMode();
6245 target.changeSetTimeMode = function(){
6246 changeSetTimeMode();
6247 };
6248
6249 target.currentYear = ko.observable(parseInt(sntpInfo.sntp_year, 10));
6250 target.currentMonth = ko.observable(parseInt(sntpInfo.sntp_month, 10));
6251 target.currentDate = ko.observable(parseInt(sntpInfo.sntp_day, 10));
6252 target.currentHour = ko.observable(parseInt(sntpInfo.sntp_hour, 10));
6253 target.currentMinute = ko.observable(parseInt(sntpInfo.sntp_minute, 10));
6254
6255
6256 // ��Ҫ��������ˢ�������б����ݣ�ע��˳��
6257
6258 target.years = ko.observableArray(sv_sntpYears);
6259 target.months = ko.observableArray(sv_sntpMonths);
6260 //���û�ѡ���·ݵ�ʱ���ı�����ѡ������ѡ��
6261 target.initDateList = function(){
6262 initDateList();
6263 target.dates(sv_sntpDates);
6264 }
6265
6266 //��ʼ�������б�
6267 initDateList();
6268 target.dates = ko.observableArray(sv_sntpDates);
6269 target.hours = ko.observableArray(sv_sntpHours);
6270 target.minutes = ko.observableArray(sv_sntpMinutes);
6271
6272 //�Զ�SNTP��ȡʱ�����ݰ󶨴���
6273 var serverArray = _.map(sntpInfo.sntp_servers, function(item) {
6274 return new Option(item.name, item.value)
6275 });
6276
6277 target.serverList = ko.observableArray(serverArray);
6278
6279 // �������ֲ����޸ģ��޸��޷�ˢ����ҳ
6280
6281 target.currentServer0 = ko.observable(sntpInfo.sntp_server0);
6282 target.currentServer1 = ko.observable(sntpInfo.sntp_server1);
6283 target.currentServer2 = ko.observable(sntpInfo.sntp_server2);
6284 target.customServer0 = ko.observable(sntpInfo.sntp_other_server0);
6285 target.customServer1 = ko.observable(sntpInfo.sntp_other_server1);
6286 target.customServer2 = ko.observable(sntpInfo.sntp_other_server2);
6287 target.isOther0 = ko.observable(false);
6288 target.isOther1 = ko.observable(false);
6289 target.isOther2 = ko.observable(false);
6290
6291 initOtherServer();
6292
6293 target.changeServerSelect = function(){
6294 initOtherServer();
6295 }
6296
6297 target.timeZones = ko.observableArray(timeZones);
6298 target.currentTimeZone = ko.observable(sntpInfo.sntp_timezone + "_" + sntpInfo.sntp_timezone_index);
6299 target.daylightSaves = ko.observableArray(daylightSave);
6300 target.currentDaylightSave = ko.observable(sntpInfo.sntp_dst_enable);
6301
6302 //���µ�ǰ��ʾʱ��
6303 target.updateCurrentTime = function() {
6304 var globalDay = globalTime.getDay();
6305
6306 switch(globalDay){
6307 case 6:
6308 target.day($.i18n.prop("saturday"));
6309 break;
6310 case 5:
6311 target.day($.i18n.prop("friday"));
6312 break;
6313 case 4:
6314 target.day($.i18n.prop("thursday"));
6315 break;
6316 case 3:
6317 target.day($.i18n.prop("wednesday"));
6318 break;
6319 case 2:
6320 target.day($.i18n.prop("tuesday"));
6321 break;
6322 case 1:
6323 target.day($.i18n.prop("monday"));
6324 break;
6325 case 0:
6326 target.day($.i18n.prop("sunday"));
6327 break;
6328 default:
6329 break;
6330 }
6331
6332 var localCurrentTime = globalTime.getFullYear() + "-" + getTwoDigit(globalTime.getMonth()+1) + "-" + getTwoDigit(globalTime.getDate()) + " " + getTwoDigit(globalTime.getHours()) + ":" + getTwoDigit(globalTime.getMinutes()) + ":" + getTwoDigit(globalTime.getSeconds());
6333 target.localTime(localCurrentTime);
6334 globalTime.setTime(globalTime.getTime()+1000);
6335 };
6336
6337 // SNTP����
6338 target.apply = function(){
6339 var tmpArray = [];
6340 for(var i=0; i< sntpInfo.sntp_servers.length; i++){
6341 tmpArray.push(sntpInfo.sntp_servers[i].value);
6342 }
6343 var staInfo = service.getStatusInfo();
6344 if(!checkConnectedStatus(staInfo.connectStatus, staInfo.rj45ConnectStatus, staInfo.connectWifiStatus) && target.currentMode() == "auto"){
6345 showAlert("sntp_syn_time_wan_connected");
6346 return;
6347 }
6348
6349 showLoading("");
6350 var requestParams = {
6351 goformId: "SNTP",
6352 manualsettime : target.currentMode(),
6353 sntp_server1_ip : target.currentServer0(),
6354 sntp_server2_ip : target.currentServer1(),
6355 sntp_server3_ip : target.currentServer2(),
6356 sntp_other_server0 : target.customServer0(),
6357 sntp_other_server1 : target.customServer1(),
6358 sntp_other_server2 : target.customServer2(),
6359 timezone : target.currentTimeZone().split("_")[0],
6360 sntp_timezone_index : target.currentTimeZone().split("_")[1],
6361 DaylightEnabled : target.currentDaylightSave(),
6362 time_year : target.currentYear(),
6363 time_month : target.currentMonth(),
6364 time_day : target.currentDate(),
6365 time_hour : target.currentHour(),
6366 time_minute : target.currentMinute()
6367 };
6368
6369 service.setSntpSetting(requestParams, function(data2){
6370 if(data2) {
6371 if(data2.result == "success" && target.currentMode() == "auto"){
6372 successOverlay("sntp_req_success");
6373 //hideLoading();
6374 }else if(data2.result == "processing" && target.currentMode() == "auto"){
6375 successOverlay("sntp_processing");
6376 }else{
6377 //����serverУ׼ʱ��
6378 service.setSNTPDate({
6379 goformId: "SNTP_Getdatastatic"
6380 }, function(result){
6381 var sntpInfo = service.getSntpParams();
6382 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));
6383 successOverlay();
6384 });
6385 }
6386 } else {
6387 errorOverlay();
6388 }
6389 });
6390 }
6391
6392 // �ֶ�/�Զ��л���Ӧ����
6393 function changeSetTimeMode() {
6394 if(target.currentMode() == "manual") {
6395 target.isManualSetTime(true);
6396 target.isAutoSntpTime(false);
6397 } else {
6398 target.isManualSetTime(false);
6399 target.isAutoSntpTime(true);
6400 }
6401 return true;
6402 }
6403
6404 // ��ʼ��ʱ��
6405 function initDateList(){
6406 sv_sntpDates = [];
6407 if($.inArray(parseInt(target.currentMonth(), 10), sf_smallMonth) != -1) {
6408 sf_produceArray(1, 30, sv_sntpDates);
6409 } else if($.inArray(parseInt(target.currentMonth(), 10), sf_bigMonth) != -1) {
6410 sf_produceArray(1, 31, sv_sntpDates);
6411 } else if(parseInt(target.currentYear(), 10)%4 == 0) {
6412 sf_produceArray(1, 29, sv_sntpDates);
6413 } else {
6414 sf_produceArray(1, 28, sv_sntpDates);
6415 }
6416 }
6417
6418 // ��ʼ������������
6419 function initOtherServer(){
6420 target.isOther0(target.currentServer0() == "Other");
6421 target.isOther1(target.currentServer1() == "Other");
6422 target.isOther2(target.currentServer2() == "Other");
6423 !target.isOther0() && $("#sntp_server0").find(".error").hide();
6424 !target.isOther1() && $("#sntp_server1").find(".error").hide();
6425 !target.isOther2() && $("#sntp_server2").find(".error").hide();
6426 }
6427
6428
6429 }
6430
6431 // ��ʼ�� ViewModel����������ͼ����
6432 function init() {
6433 var fwVm = new othersViewModel();
6434 var container = $('#container')[0];
6435 ko.cleanNode(container);
6436 ko.applyBindings(fwVm, container);
6437 fwVm.updateCurrentTime();
6438
6439 addInterval(function(){
6440 fwVm.updateCurrentTime();
6441 }, 1000);
6442
6443 $("#sntpForm").validate({
6444 submitHandler: function(){
6445 fwVm.apply();
6446 },
6447 rules: {
6448 sntp_other_server0 : "sntp_invalid_server_name",
6449 sntp_other_server1 : "sntp_invalid_server_name",
6450 sntp_other_server2 : "sntp_invalid_server_name"
6451 }
6452 });
6453 }
6454
6455 return {
6456 init:init
6457 }
6458 });
w.denged536982025-07-21 10:24:31 +08006459
6460const errorMessages = {
6461 "en": {
6462 txtCurrent: {
6463 manage_info_check: "Please enter a valid password."
6464 },
6465 txtNew: {
6466 manage_info_check: "Please enter a valid password."
6467 },
6468 txtConfirm: {
6469 equalTo: "The new password and the confirmed password do not match or contain illegal characters."
6470 }
6471 },
6472 "zh": {
6473 txtCurrent: {
6474 manage_info_check: "请输入有效的密码"
6475 },
6476 txtNew: {
6477 manage_info_check: "请输入有效的密码"
6478 },
6479 txtConfirm: {
6480 equalTo: "新密码和确认密码不匹配或者包含非法字符"
6481 }
6482 }
6483};
6484
qumengjia1cd76022024-10-31 17:51:04 +08006485// �������� �
6486
6487define("adm_management","jquery knockout set service underscore CryptoJS".split(" "),
6488
6489 function ($, ko, config, service, _, CryptoJS) {
6490
6491 function manageViewModel() {
6492 var target = this;
6493
6494 target.currentValue = ko.observable();
6495 target.newValue = ko.observable();
6496 target.confirmValue = ko.observable();
6497
6498 function sf_changeValue() {
6499 var sv_manageInfo = {};
6500 if (config.PASSWORD_ENCODE) {
6501 sv_manageInfo.oldValue = target.currentValue();
6502 sv_manageInfo.newValue = target.newValue();
6503 } else {
6504 var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
6505
6506 if (!pwdRegex.test(target.newValue())) {
6507 showConfirm("password_note_too_low", function () {
6508
6509 var kparam = service.getDeviceInfoLow();
6510 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
6511 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
6512 var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
6513 iv: tiv,
6514 mode: CryptoJS.mode.CBC,
6515 padding: CryptoJS.pad.ZeroPadding
6516 }).toString();
6517 var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
6518 iv: tiv,
6519 mode: CryptoJS.mode.CBC,
6520 padding: CryptoJS.pad.ZeroPadding
6521 }).toString();
6522
6523 sv_manageInfo.oldValue = cipherold;
6524 sv_manageInfo.newValue = ciphernew;
6525
6526 showLoading();
6527
6528 service.changeManageInfo(sv_manageInfo, function (resultInfo) {
6529 target.cancel();
6530 if (resultInfo && resultInfo.result == true) {
6531 successOverlay();
6532 } else {
6533 if (resultInfo && resultInfo.errorType == "badPassword") {
6534 hideLoading();
6535 showAlert("current_password_error",function(){
6536 $("#txtCurrent").focus();
6537 });
6538 } else {
6539 errorOverlay();
6540 }
6541 }
6542 });
6543 });
6544 return;
6545 }
6546 var kparam = service.getDeviceInfoLow();
6547 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
6548 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
6549 var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
6550 iv: tiv,
6551 mode: CryptoJS.mode.CBC,
6552 padding: CryptoJS.pad.ZeroPadding
6553 }).toString();
6554 var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
6555 iv: tiv,
6556 mode: CryptoJS.mode.CBC,
6557 padding: CryptoJS.pad.ZeroPadding
6558 }).toString();
6559
6560 sv_manageInfo.oldValue = cipherold;
6561 sv_manageInfo.newValue = ciphernew;
6562 }
6563
6564 showLoading();
6565
6566 service.changeManageInfo(sv_manageInfo, function (resultInfo) {
6567 target.cancel();
6568 if (resultInfo && resultInfo.result == true) {
6569 successOverlay();
6570 } else {
6571 if (resultInfo && resultInfo.errorType == "badPassword") {
6572 hideLoading();
6573 showAlert("current_password_error",function(){
6574 $("#txtCurrent").focus();
6575 });
6576 } else {
6577 errorOverlay();
6578 }
6579 }
6580 });
6581 }
6582
6583 // ��������������
6584 function sf_cancel() {
6585 target.currentValue("");
6586 target.newValue("");
6587 target.confirmValue("");
6588 }
6589
6590 target.cancel = sf_cancel;
6591
6592 // �޸�����
6593 target.changeValue = sf_changeValue;
6594 }
6595
6596 function init() {
6597 var container = $('#container');
6598 ko.cleanNode(container[0]);
6599 var fwVm = new manageViewModel();
6600 ko.applyBindings(fwVm, container[0]);
6601
mj.qu7af1f5b2025-07-31 19:31:40 -07006602 const langObj = service.getLanguage();
6603 const langCode = (langObj && langObj.Language || 'en').split('-')[0];
6604 const messages = errorMessages[langCode] || errorMessages['en'];
6605 console.log('langCode =', langCode);
w.denged536982025-07-21 10:24:31 +08006606
qumengjia1cd76022024-10-31 17:51:04 +08006607 $('#frmPassword').validate({
6608 submitHandler:function () {
6609 fwVm.changeValue();
6610 },
6611 rules:{
6612 txtCurrent:"manage_info_check",
6613 txtNew:"manage_info_check",
6614 txtConfirm:{ equalTo:"#txtNew"}
w.denged536982025-07-21 10:24:31 +08006615 },
6616 messages: messages
qumengjia1cd76022024-10-31 17:51:04 +08006617 });
6618 }
6619
6620 return {
6621 init:init
6622 }
6623 }
6624);
6625// PIN�����
6626
6627define("adm_pin","jquery knockout set service".split(" "),
6628
6629 function ($, ko, config, service) {
6630 var pageState = {common:0, requirePin:1, modifyPin:2, requirePuk:3, destroyed:4};
6631 var pinStatus = {enable:"1", disable:"0"};
6632
6633
6634 function pinViewModel() {
6635 var target = this;
6636 var sv_currentPinData = service.getPinData();
6637
6638 target.isDataCard = config.PRODUCT_TYPE == 'DATACARD';
6639 target.originPinStatus = ko.observable(sv_currentPinData.pin_status);
6640
6641 target.pinStatus = ko.observable(sv_currentPinData.pin_status);
6642 target.pinNumber = ko.observable(sv_currentPinData.pinnumber);
6643 target.pukNumber = ko.observable(sv_currentPinData.puknumber);
6644
6645 target.currentPin = ko.observable();
6646 target.newPin = ko.observable();
6647 target.confirmPin = ko.observable();
6648
6649 target.puk = ko.observable();
6650
6651 target.pageState = ko.observable();
6652 // �����������ɹ���־λ
6653 target.operateSuccessFlag = true;
6654
6655 target.callback = sf_callback;
6656
6657 function sf_callback(info) {
6658 if (info && info.result == true) {
6659 target.operateSuccessFlag = true;
6660 successOverlay();
6661 } else {
6662 target.operateSuccessFlag = false;
6663
6664 // ����һ��ǰҪ������ʾ
6665 if(target.pinNumber() == 2){
6666 showAlert("last_enter_pin");
6667 } else if(target.pukNumber() == 2){
6668 showAlert("last_enter_puk");
6669 }
6670 else{
6671 errorOverlay();
6672 }
6673 }
6674 init(target);
6675 }
6676
6677
6678 // ȷ����ť�¼������������޸�PIN������PUK����PIN������PIN��ʹ��״̬
6679
6680 function sf_changePin() {
6681 if (target.isConnectedNetWork()) {
6682 showAlert("cannot_operate_when_connected");
6683 return;
6684 }
6685
6686 if (target.pageState() == pageState.common) {
6687 return;
6688 }
6689
6690 var sv_pinPara = {
6691 oldPin:target.currentPin(),
6692 newPin:target.newPin()
6693 };
6694 showLoading();
6695
6696 if (target.pageState() == pageState.modifyPin) {
6697 service.changePin(sv_pinPara, target.callback);
6698 } else if (target.pageState() == pageState.requirePuk) {
6699 sv_pinPara = {
6700 PinNumber:target.newPin(),
6701 PUKNumber:target.puk()
6702 };
6703 service.enterPUK(sv_pinPara, target.callback);
6704 } else {
6705 if (target.pinStatus() == pinStatus.enable) {
6706 service.enablePin(sv_pinPara, target.callback);
6707 } else {
6708 service.disablePin(sv_pinPara, target.callback);
6709 }
6710 }
6711 }
6712
6713
6714 // ȡ���¼�����
6715 function sf_cancel() {
6716 target.pageState(pageState.common);
6717 target.pinStatus(target.originPinStatus());
6718 target.clear();
6719 }
6720
6721 // ����ҳ�������ͼ�����Ϣ
6722 function sf_clear() {
6723 target.confirmPin("");
6724 target.currentPin("");
6725 target.newPin("");
6726 target.puk("");
6727 clearValidateMsg();
6728 }
6729
6730 // �������ݣ����õ�ǰ��ҳ��״̬
6731 function sf_computePageState(i_pinData) {
6732 if (i_pinData.pinnumber > 0) {
6733 //�����ɹ�ҳ���ص���ʼ״̬������ʧ�ܲ���pinnumber>0,ҳ�治��ת
6734 if (target.operateSuccessFlag) {
6735 target.cancel();
6736 } else {
6737 target.clear();
6738 }
6739 } else {
6740 target.clear();
6741 if (i_pinData.puknumber > 0) {
6742 target.pageState(pageState.requirePuk);
6743 } else {
6744 target.pageState(pageState.destroyed);
6745 }
6746 }
6747 }
6748
6749 // ����PIN�޸�״̬�¼�����
6750 function sf_displayModifyPinPage() {
6751 if (target.isConnectedNetWork()) {
6752 showAlert("cannot_operate_when_connected");
6753 return;
6754 }
6755 target.pinStatus(target.originPinStatus());
6756 target.pageState(pageState.modifyPin);
6757 target.clear();
6758 }
6759
6760 // ����ҳ��Ԫ�ص�ʹ��״̬
6761 function sf_fixPageEnable() {
6762 if (target.isConnectedNetWork()) {
6763 $('#frmPin :input').each(function () {
6764 disableBtn($(this));
6765 });
6766 clearValidateMsg();
6767 } else {
6768 $('#frmPin :input').each(function () {
6769 if (this.id == "txtPin" || this.id == "btnPinApply") {
6770 if (target.pageState() == pageState.common) {
6771 disableBtn($(this));
6772 return;
6773 }
6774 }
6775 if (this.id == "btnModifyPin") {
6776 if (target.originPinStatus() != pinStatus.enable) {
6777 disableBtn($(this));
6778 return;
6779 }
6780 }
6781 if (this.id == "pinEnable" || this.id == "pinDisable") {
6782 if (target.pageState() == pageState.modifyPin) {
6783 disableBtn($(this));
6784 return;
6785 }
6786 }
6787 enableBtn($(this));
6788 });
6789
6790 }
6791 }
6792
6793 // �Ƿ�������
6794 function sf_isConnectedNetWork() {
6795 var info = service.getConnectionInfo();
6796 return info.connectStatus == "ppp_connected";
6797 }
6798
6799 // PINʹ�ܸı�ʱ�¼�����
6800 function sf_pinStatusChangeEvent() {
6801 if (target.pinStatus() == target.originPinStatus()) {
6802 target.pageState(pageState.common);
6803 } else {
6804 target.pageState(pageState.requirePin);
6805 }
6806 target.clear();
6807 }
6808
6809 target.changePin = sf_changePin;
6810 target.cancel = sf_cancel;
6811 target.clear = sf_clear;
6812 target.computePageState = sf_computePageState;
6813
6814 target.computePageState(sv_currentPinData);
6815
6816 target.displayModifyPinPage = sf_displayModifyPinPage;
6817 target.fixPageEnable = sf_fixPageEnable;
6818 target.isConnectedNetWork = sf_isConnectedNetWork;
6819
6820 target.pinStatusChangeEvent = ko.dependentObservable(sf_pinStatusChangeEvent, this);
6821 }
6822
6823 function init(oldViewModel) {
6824
6825 var fwVm = oldViewModel;
6826
6827 if (fwVm) {
6828 var sv_currentPinData = service.getPinData();
6829 fwVm.originPinStatus(sv_currentPinData.pin_status);
6830 fwVm.pinNumber(sv_currentPinData.pinnumber);
6831 fwVm.pukNumber(sv_currentPinData.puknumber);
6832 fwVm.computePageState(sv_currentPinData);
6833 } else {
6834 fwVm = new pinViewModel();
6835 addInterval(function () {
6836 fwVm.fixPageEnable();
6837 }, 1000);
6838 }
6839
6840 var container = $('#container')[0];
6841 ko.cleanNode(container);
6842 ko.applyBindings(fwVm, container);
6843 fwVm.fixPageEnable();
6844
6845 $('#frmPin').validate({
6846 submitHandler:function () {
6847 fwVm.changePin();
6848 },
6849 rules:{
6850 txtPuk:"puk_check",
6851 txtPin:"pin_check",
6852 txtNewPin:"pin_check",
6853 txtConfirmPin:{equalToPin:"#txtNewPin"}
6854 }
6855 });
6856 }
6857
6858 return {
6859 init:init
6860 }
6861 }
6862);
6863
6864// ��������
6865define("adm_quick_set","jquery knockout set service underscore CryptoJS".split(" "),
6866
6867 function ($, ko, config, service, _, CryptoJS) {
6868
6869 var sv_wifiState = {ok:0, wps_on:1, wifi_off:2};
6870 var sv_apnMode = {auto:"auto", manual:"manual"};
6871 var sv_minStep = 1;
6872 var sv_maxStep = 5;
6873
6874 // ��ȡ��Ȩ��ʽ
6875 function sf_fetchAuthenticationModes() {
6876 return _.map(config.APN_AUTH_MODES, function (item) {
6877 return new Option(item.name, item.value);
6878 });
6879 }
6880
6881 // WIFI��ȫģʽѡ��
6882 var sv_securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
6883 return new Option(item.name, item.value);
6884 });
6885
6886
6887 function quickSettingViewModel() {
6888 var target = this;
6889
6890 var sv_quickSettingInfo = service.getQuickSettingInfo();
6891
6892 target.currentStep = ko.observable(sv_minStep);
6893 target.ipType = ko.observable(sv_quickSettingInfo.pdp_type == "IP" ? "IP" : sv_quickSettingInfo.ipv6_pdp_type);
6894 target.supportIPv6 = config.IPV6_SUPPORT;
6895 target.supportIpv4AndIpv6 = config.IPV4_AND_V6_SUPPORT;
6896
6897 target.wpsFlag = ko.observable(sv_quickSettingInfo.WscModeOption);
6898
6899 function sf_apnDisabled() {
6900 return (sv_quickSettingInfo.apn_index < config.defaultApnSize || sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting");
6901 }
6902
6903 function sf_apnModeDisabled() {
6904 return (sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting" || (!target.profileName() && target.apnMode() == sv_apnMode.auto));//ѡ��Ϊ�ջ��������ӻ�������
6905 }
6906
6907 function sf_currAPN() {
6908 var sv_APNText = sv_quickSettingInfo["APN_configtmp" + sv_quickSettingInfo.apn_index];
6909 var strIPv6APN = sv_quickSettingInfo["ipv6_APN_configtmp" + sv_quickSettingInfo.apn_index];
6910
6911 var sv_apn = [];
6912 var sv_ipv6APNItems = [];
6913
6914 if (sv_APNText) {
6915 sv_apn = sv_APNText.split("($)");
6916 }
6917
6918 if (strIPv6APN) {
6919 sv_ipv6APNItems = strIPv6APN.split("($)");
6920 }
6921
6922 return {
6923 m_profile_name:sv_apn[0],
6924 wan_apn:sv_apn[1],
6925 ppp_auth_mode: sv_apn[4] == "" || typeof(sv_apn[4]) == "undefined" ? "" : sv_apn[4].toLowerCase(),
6926 ppp_username:sv_apn[5],
6927 ppp_passtmp:sv_apn[6],
mj.que145fd02025-06-05 00:13:13 -07006928 pdp_type: sv_apn[7] == "" || typeof(sv_apn[7]) == "undefined" ? sv_ipv6APNItems[7] : sv_apn[7],
qumengjia1cd76022024-10-31 17:51:04 +08006929 ipv6_wan_apn:sv_ipv6APNItems[1],
6930 ipv6_ppp_auth_mode:typeof(sv_ipv6APNItems[4]) == "undefined" || sv_ipv6APNItems[4] == ""? "" : sv_ipv6APNItems[4].toLowerCase(),
6931 ipv6_ppp_username:sv_ipv6APNItems[5],
6932 ipv6_ppp_passtmp:sv_ipv6APNItems[6],
6933 ipv6_pdp_type:sv_ipv6APNItems[7]
6934 }
6935 }
6936
6937 // ��ǰAPN����
6938 target.currAPN = ko.computed(sf_currAPN);
6939
6940 target.apn = ko.observable(target.currAPN().wan_apn);
mj.que145fd02025-06-05 00:13:13 -07006941 target.ipType = ko.observable(target.currAPN().pdp_type);
qumengjia1cd76022024-10-31 17:51:04 +08006942 target.ipv6_apn = ko.observable(target.currAPN().ipv6_wan_apn);
6943 target.ipv6_selectedAuthMode = ko.observable(target.currAPN().ipv6_ppp_auth_mode);
6944 target.ipv6_username = ko.observable(target.currAPN().ipv6_ppp_username);
6945 target.ipv6_password = ko.observable(target.currAPN().ipv6_ppp_passtmp);
6946 target.profileName = ko.observable(target.currAPN().m_profile_name);
6947 target.selectedAuthMode = ko.observable(target.currAPN().ppp_auth_mode);
6948 target.username = ko.observable(target.currAPN().ppp_username);
6949 target.password = ko.observable(target.currAPN().ppp_passtmp);
6950
6951 target.transAPN = ko.observable("apn_ipv4_apn");
6952 target.transAPNIPv6 = ko.observable("apn_ipv6_apn");
6953 target.transAuthMode = ko.observable("apn_authentication_ipv4");
6954 target.transAuthModeIPv6 = ko.observable("apn_authentication_ipv6");
6955 target.transUserName = ko.observable("apn_user_name_ipv4");
6956 target.transPassword = ko.observable("apn_password_ipv4");
6957 target.transUserNameIPv6 = ko.observable("apn_user_name_ipv6");
6958 target.transPasswordIPv6 = ko.observable("apn_password_ipv6");
6959
6960
6961
6962 target.apnDisabled = ko.computed(sf_apnDisabled);
6963 target.apnMode = ko.observable(sv_quickSettingInfo.apn_mode);
6964 target.apnModeDisabled = ko.computed(sf_apnModeDisabled);
6965 target.authModes = ko.observableArray(sf_fetchAuthenticationModes());
6966
6967 if (target.ipType() == "IPv6") {
6968 target.showIPv4 = false;
6969 target.showIPv6 = true;
6970 target.transAPNIPv6("apn");
6971 target.transAuthModeIPv6("apn_authentication");
6972 target.transUserNameIPv6("apn_user_name");
6973 target.transPasswordIPv6("apn_password");
6974 } else if (config.IPV4_AND_V6_SUPPORT && target.ipType() == "IPv4v6") {
6975 target.showIPv4 = true;
6976 target.showIPv6 = true;
6977 //ʹ��Ĭ��
6978 } else if (target.ipType() == "IP" || target.ipType() == "IPv4") {
6979 target.showIPv4 = true;
6980 target.showIPv6 = false;
6981 target.transAPN("apn");
6982 target.transAuthMode("apn_authentication");
6983 target.transUserName("apn_user_name");
6984 target.transPassword("apn_password");
6985 } else { //pdp_type == "IPv4v6" && config.IPV4V6_SUPPORT
6986 target.showIPv4 = true;
6987 target.showIPv6 = false;
6988 target.transAPN("apn");
6989 target.transAuthMode("apn_authentication");
6990 target.transUserName("apn_user_name");
6991 target.transPassword("apn_password");
6992 }
6993
6994 target.wifiDisabled = (sv_quickSettingInfo.wifi_cur_state != "1");
6995 target.ssid = ko.observable(sv_quickSettingInfo.SSID1);
6996 target.broadcast = ko.observable(sv_quickSettingInfo.HideSSID);
6997 target.hasWifiWep = config.WIFI_WEP_SUPPORT;
6998 target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
6999 target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
7000
7001 target.securityModes = ko.observableArray(sv_securityModes);
7002 target.selectedSecurityMode = ko.observable(sv_quickSettingInfo.AuthMode);
7003 target.WPAKey = ko.observable(sv_quickSettingInfo.WPAPSK1);
7004
7005 target.apnMode_display = ko.observable("");
7006
7007 target.apnMode_trans = ko.computed(sf_apnMode_trans);
7008 target.selectedAuthMode_display = ko.computed(sf_selectedAuthMode_display);
7009 target.ipv6_selectedAuthMode_display = ko.computed(sf_ipv6_selectedAuthMode_display);
7010
7011 target.showWifiPassword = ko.observable(false);
7012 target.showWifiPasswordHandler = sf_showWifiPasswordHandler;
7013
7014 //�ж��Ƿ���802 n only��
7015 var sv_adInfo = service.getWifiAdvance();
7016 target.adBand = ko.observable(sv_adInfo.wifiBand);
7017 target.adMode = ko.observable(sv_adInfo.mode);
7018
7019 target.encryptType = ko.observable(sv_quickSettingInfo.EncrypType);
7020 target.keyID = ko.observable(sv_quickSettingInfo.DefaultKeyID);
7021 target.wepPassword = ko.observable("");
7022
7023 target.getWepPassword = sf_getWepPassword;
7024 target.wepPassword(target.getWepPassword());
7025 target.profileChangeHandler = sf_profileChangeHandler;
7026
7027 target.broadcast_display = ko.observable("");
7028 target.broadcast_trans = ko.computed(sf_broadcast_trans);
7029
7030 target.selectedSecurityMode_display = ko.observable();
7031 target.selectedSecurityMode_trans = ko.computed(sf_selectedSecurityMode_trans);
7032
7033
7034 target.callback = sf_callback;
7035 target.next = sf_button_next;
7036 target.previous = sf_button_previous;
7037 target.save = sf_button_save;
7038
7039 function sf_apnMode_trans() {
7040 if (sv_apnMode.auto == target.apnMode()) {
7041 target.apnMode_display($.i18n.prop("apn_auto_apn"));
7042 return "apn_auto_apn";
7043 } else {
7044 target.apnMode_display($.i18n.prop("apn_manual_apn"));
7045 return "apn_manual_apn";
7046 }
7047 }
7048
7049 function sf_broadcast_trans() {
7050 if ("0" == target.broadcast()) {
7051 target.broadcast_display($.i18n.prop("enable"));
7052 return "enable";
7053 } else {
7054 target.broadcast_display($.i18n.prop("disable"));
7055 return "disable";
7056 }
7057 }
7058
7059 function sf_button_next() {
7060 var currentStep = target.currentStep();
7061 var toStep = target.currentStep() + 1;
7062 sf_changeStep(toStep);
7063
7064 if (currentStep == 1 && target.apnMode() == sv_apnMode.auto) {
7065 toStep = target.currentStep() + 1;
7066 sf_changeStep(toStep);
7067 }
7068 }
7069
7070 function sf_button_previous() {
7071
7072 var currentStep = target.currentStep();
7073 var toStep = target.currentStep() - 1;
7074
7075 sf_changeStep(toStep);
7076
7077 if (currentStep == 3 && target.apnMode() == sv_apnMode.auto) {
7078 toStep = target.currentStep() - 1;
7079 sf_changeStep(toStep);
7080 }
7081 }
7082 function sf_button_save() {
7083 var submit = function () {
7084 sf_quickSetting4IPv6();
7085 };
7086 var result = sf_isDisabled_Wifi();
7087 if(result == sv_wifiState.wifi_off){
7088 showConfirm("quick_setting_wifi_disable_confirm", submit);
7089 } else if (result == sv_wifiState.wps_on) {
7090 showAlert("wps_on_info");
7091 } else{
7092 showConfirm("quick_setting_param_changed_confirm", submit);//submit();
7093 }
7094 }
7095 // ���������ύ���Ļص�����
7096 function sf_callback(data) {
7097 if (data.result == "success") {
7098 successOverlay();
mj.qu7b3dd3a2025-07-10 01:31:18 -07007099 location.hash = "#main";
w.dengf2f56832025-08-06 14:49:13 +08007100 location.reload();
qumengjia1cd76022024-10-31 17:51:04 +08007101 }
7102 else {
7103 errorOverlay();
7104 }
7105 }
7106
7107 // �任����ʱ����
7108 function sf_changeStep(i_step) {
7109 if (i_step > sv_maxStep) {
7110 i_step = sv_maxStep;
7111 } else if (i_step < sv_minStep) {
7112 i_step = sv_minStep;
7113 }
7114
7115 target.currentStep(i_step);
7116 return true;
7117 }
7118
7119 function sf_ipv6_selectedAuthMode_display() {
7120 var mode = target.ipv6_selectedAuthMode();
7121 return sf_getAuthModeNameByValue(mode);
7122 }
7123 // ���ݼ�Ȩģʽ��ֵ��������
7124 function sf_getAuthModeNameByValue(authMode) {
7125 for (var i = 0; i < config.APN_AUTH_MODES.length; i++) {
7126 if (authMode == config.APN_AUTH_MODES[i].value) {
7127 return config.APN_AUTH_MODES[i].name;
7128 }
7129 }
7130 }
7131
7132 function sf_getWepPassword(){
7133 return target.keyID() == '3' ? sv_quickSettingInfo.Key4Str1 : (target.keyID() == '2' ? sv_quickSettingInfo.Key3Str1 : target.keyID() == '1' ? sv_quickSettingInfo.Key2Str1 : sv_quickSettingInfo.Key1Str1);
7134 }
7135
7136 function sf_isDisabled_Wifi() {
7137 var s_wpsInfo = service.getWpsInfo();
7138 if(s_wpsInfo.radioFlag == "0"){
7139 return sv_wifiState.wifi_off;
7140 }else if (s_wpsInfo.wpsFlag == '1') {
7141 return sv_wifiState.wps_on;
7142 }
7143 return sv_wifiState.ok;
7144 }
7145 function sf_profileChangeHandler(i_data, i_event) {
7146 $("#pwdWepKey").parent().find("label[class='error']").hide();
7147 target.wepPassword(target.getWepPassword());
7148 return true;
7149 }
7150
7151 // ���������ύ(֧��IPv6��
7152 function sf_quickSetting4IPv6() {
7153 showLoading();
7154 var useIPv4ForV6 = config.IPV4V6_SUPPORT && target.currAPN().pdp_type == "IPv4v6";
7155
7156 var ciphertext = "";
7157 if (config.PASSWORD_ENCODE) {
7158 ciphertext = target.WPAKey();
7159 } else {
7160 var kparam = service.getDeviceInfoLow();
7161 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
7162 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
7163 ciphertext = CryptoJS.AES.encrypt(target.WPAKey(), tkey, {
7164 iv: tiv,
7165 mode: CryptoJS.mode.CBC,
7166 padding: CryptoJS.pad.ZeroPadding
7167 }).toString();
7168 }
7169
7170 var s_quickSettingParameters = {
7171 apn_index: sv_quickSettingInfo.apn_index,
7172 apnMode: target.apnMode(),
7173 Encryption_Mode_hid: target.selectedSecurityMode(),
7174 ipv6_ppp_auth_mode: useIPv4ForV6 ? target.selectedAuthMode() : target.ipv6_selectedAuthMode(),
7175 ipv6_ppp_username: useIPv4ForV6 ? target.username() : target.ipv6_username(),
7176 ipv6_ppp_passtmp: useIPv4ForV6 ? target.password() : target.ipv6_password(),
7177 ipv6_wan_apn: useIPv4ForV6 ? target.apn() : target.ipv6_apn(),
7178 pdp_type: target.ipType(),
7179 ppp_auth_mode: target.selectedAuthMode(),
7180 ppp_username: target.username(),
7181 ppp_passtmp: target.password(),
7182 profile_name: target.profileName(),
7183 //Ŀǰ����ģʽֻ��2�֣�����3������Ϊ�̶�ֵ
7184 //������Ҫ����Ϊ5�֣�����ֵ��Ҫ����
7185 security_shared_mode: "NONE",
7186 SSID_Broadcast: target.broadcast(),
7187 SSID_name: target.ssid(),
7188 wan_apn: target.apn(),
7189 wep_default_key: 0,
7190 WPA_ENCRYPTION_hid: target.selectedSecurityMode() == "OPEN" ? "NONE" : target.selectedSecurityMode() == "WPA2PSK" ? 1 : 2,
7191 WPA_PreShared_Key: ciphertext
7192 }
7193
7194 s_quickSettingParameters.wep_default_key = target.keyID();
7195
7196 if(target.encryptType() == "SHARED" || target.selectedSecurityMode() == "WEP") {
7197
7198 s_quickSettingParameters.security_shared_mode = "WEP";
7199
7200 s_quickSettingParameters.wep_key_1 = sv_quickSettingInfo.Key1Str1;
7201 s_quickSettingParameters.wep_key_2 = sv_quickSettingInfo.Key2Str1;
7202 s_quickSettingParameters.wep_key_3 = sv_quickSettingInfo.Key3Str1;
7203 s_quickSettingParameters.wep_key_4 = sv_quickSettingInfo.Key4Str1;
7204
7205 var WEPSelectTmp = '0';
7206
7207 if(target.wepPassword().length =='5' ||target.wepPassword().length =='13'){
7208 WEPSelectTmp = '1';
7209 }else{
7210 WEPSelectTmp = '0';
7211 }
7212
7213 if(target.keyID() =='3'){
7214 s_quickSettingParameters.wep_key_4 = target.wepPassword();
7215 s_quickSettingParameters.WEP4Select = WEPSelectTmp;
7216 }else if(target.keyID() =='2'){
7217 s_quickSettingParameters.wep_key_3 = target.wepPassword();
7218 s_quickSettingParameters.WEP3Select = WEPSelectTmp;
7219 }else if(target.keyID() =='1'){
7220 s_quickSettingParameters.wep_key_2 = target.wepPassword();
7221 s_quickSettingParameters.WEP2Select = WEPSelectTmp;
7222 }else{
7223 s_quickSettingParameters.wep_key_1 = target.wepPassword();
7224 s_quickSettingParameters.WEP1Select = WEPSelectTmp;
7225 }
7226 }else if(target.encryptType() == "WPAPSKWPA2PSK") {
7227 s_quickSettingParameters.security_shared_mode = "NONE";
7228 }else {
7229 s_quickSettingParameters.security_shared_mode = "NONE";
7230 }
7231
7232 service.setQuickSetting4IPv6(s_quickSettingParameters, target.callback);
7233 }
7234
7235 function sf_selectedAuthMode_display() {
7236 var mode = target.selectedAuthMode();
7237 return sf_getAuthModeNameByValue(mode);
7238 }
7239
7240 function sf_selectedSecurityMode_trans() {
7241 var mode = target.selectedSecurityMode();
7242 var modesOption = config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES;
7243 for (var i = 0; i < modesOption.length; i++) {
7244 if (mode == modesOption[i].value) {
7245 target.selectedSecurityMode_display($.i18n.prop("security_mode_" + modesOption[i].value));
7246 return "security_mode_" + modesOption[i].value;
7247 }
7248 }
7249 }
7250
7251 function sf_showWifiPasswordHandler(){
7252 $("#pwdWepKey").parent().find(".error").hide();
7253 $("#codeWPAKey").parent().find(".error").hide();
7254 var checkbox = $("#showWifiPassword:checked");
7255 if(checkbox && checkbox.length == 0){
7256 target.showWifiPassword(true);
7257 }else{
7258 target.showWifiPassword(false);
7259 }
7260 }
7261
7262 }
7263
7264 function init() {
7265 var container = $('#container');
7266 ko.cleanNode(container[0]);
7267 var fwVm = new quickSettingViewModel();
7268 ko.applyBindings(fwVm, container[0]);
7269
7270 $('#quickSettingForm').validate({
7271 submitHandler:function () {
7272 if (fwVm.currentStep() < 5) {
7273 fwVm.next();
7274 } else {
7275 fwVm.save();
7276 }
7277 },
7278 rules:{
7279 txtAPN:"apn_check",
7280 txtIPv6APN:"apn_check",
7281 txtSSID:'ssid',
7282 pwdWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
7283 txtWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
7284 txtWPAKey:'wifi_password_check',
7285 codeWPAKey:'wifi_password_check',
7286 txtUserName:'ppp_username_check',
7287 txtIPv6UserName:'ppp_username_check',
7288 txtSecretCode:"ppp_secretcode_check",
7289 txtIPv6SecretCode:"ppp_secretcode_check"
7290 },
7291 errorPlacement:function (error, element) {
7292 var id = element.attr("id");
7293 if (id == "pwdWepKey" || id == "txtWepKey"){
7294 error.insertAfter("#lblShowWepPassword");
7295 } else if (id == "txtWPAKey" || id == "codeWPAKey") {
7296 error.insertAfter("#lblShowWifiPassword");
7297 } else {
7298 error.insertAfter(element);
7299 }
7300 }
7301 });
7302 }
7303
7304 return {
7305 init:init
7306 };
7307 }
7308);
7309
7310define("main","set service knockout underscore jquery statusBar echarts".split(" "), function (set, fnc, libko, libus, libjq, barStat, echarts) {
7311
7312 var chartOptions = {
7313 color: ['red', 'red', 'red', 'red', 'red'],
7314 series: [{
7315 name: '��������',
7316 type: 'pie',
7317 radius: ['0', '72'],
7318 itemStyle: {
7319 normal: {
7320 label: {
7321 show: false
7322 },
7323 labelLine: {
7324 show: false
7325 }
7326 }
7327 },
7328 data: [],
7329 selectedOffset: 3
7330 }
7331 ],
7332 animation: false,
7333 title: {
7334 text: '',
7335 x: 'center',
7336 y: 'center',
7337 itemGap: 0,
7338 textStyle: {
7339 color: '#FFF',
7340 fontFamily: '΢���ź�',
7341 fontSize: 20,
7342 fontWeight: 'bolder'
7343 },
7344 subtextStyle: {
7345 color: '#FFF',
7346 fontFamily: '΢���ź�',
7347 fontSize: 16,
7348 fontWeight: 'bolder'
7349 }
7350 },
7351 tooltip: {
7352 formatter: "{b}"
7353 },
7354 };
7355 var languageOld = window.language;
7356 var num_refresh = 0;
7357 var traffic_graphic_chart = null;
7358 var connStat = {
7359 CONNECTED: 1,
7360 DISCONNECTED: 2,
7361 CONNECTING: 3,
7362 DISCONNECTING: 4
7363 };
7364 function init() {
7365 num_refresh = 0;
7366 homeUtil.oldUsedData = null;
7367 homeUtil.oldAlarmData = null;
7368 traffic_graphic_chart = echarts.init(libjq("#traffic_graphic")[0]);
7369 var container = libjq('#container')[0];
7370 libko.cleanNode(container);
7371 var tmp = new VmHome();
7372 libko.applyBindings(tmp, container);
7373 var data = fnc.getLoginData();
7374 var psw_flg = data.psw_changed;
7375 if (psw_flg != "1") {
7376 showConfirm("password_note_first_change", function () {
7377 window.location.hash = '#pwd_mode';
7378 });
7379 return;
7380 }
7381 }
7382
7383 var homeUtil = {
7384 initStatus: null,
7385 initShownStatus: function (data) {
7386 this.initStatus = {};
7387 var ipv6Mode = data.ipv6PdpType.toLowerCase().indexOf("v6") > 0;
7388 if (set.RJ45_SUPPORT) {
7389 var mode = checkCableMode(data.blc_wan_mode);
7390 if (mode) {
7391 this.initStatus.showIpv6WanIpAddr = false;
7392 this.initStatus.showIpv4WanIpAddr = true;
7393 } else if (set.IPV6_SUPPORT) {
7394 if (data.pdpType == "IP") {
7395 this.initStatus.showIpv6WanIpAddr = false;
7396 this.initStatus.showIpv4WanIpAddr = true;
7397 } else if (ipv6Mode) {
7398 if (data.ipv6PdpType == "IPv6") {
7399 this.initStatus.showIpv6WanIpAddr = true;
7400 this.initStatus.showIpv4WanIpAddr = false;
7401 } else {
7402 this.initStatus.showIpv6WanIpAddr = true;
7403 this.initStatus.showIpv4WanIpAddr = true;
7404 }
7405 }
7406 } else {
7407 this.initStatus.showIpv6WanIpAddr = false;
7408 this.initStatus.showIpv4WanIpAddr = true;
7409 }
7410 } else {
7411 if (set.IPV6_SUPPORT) {
7412 if (data.pdpType == "IP") {
7413 this.initStatus.showIpv6WanIpAddr = false;
7414 this.initStatus.showIpv4WanIpAddr = true;
7415 } else if (ipv6Mode) {
7416 if (data.ipv6PdpType == "IPv6") {
7417 this.initStatus.showIpv6WanIpAddr = true;
7418 this.initStatus.showIpv4WanIpAddr = false;
7419 } else {
7420 this.initStatus.showIpv6WanIpAddr = true;
7421 this.initStatus.showIpv4WanIpAddr = true;
7422 }
7423 }
7424 } else {
7425 this.initStatus.showIpv6WanIpAddr = false;
7426 this.initStatus.showIpv4WanIpAddr = true;
7427 }
7428 }
7429 },
7430 wanIpGet: function (data) {
7431 var addrInfo = {
7432 wanIpAddress: '',
7433 ipv6WanIpAddress: ''
7434 };
7435 addrInfo.wanIpAddress = verifyDeviceInfo(data.wanIpAddress);
7436 addrInfo.ipv6WanIpAddress = verifyDeviceInfo(data.ipv6WanIpAddress);
7437 return addrInfo;
7438 },
7439 cachedAPStationBasic: null,
7440 cachedConnectionMode: null,
7441 getCanConnectNetWork: function (param) {
7442 var status = fnc.getStatusInfo();
7443 if (status.simStatus != "modem_init_complete") {
7444 return false;
7445 }
7446 var typeNetworkTmp = status.networkType.toLowerCase();
7447 if (typeNetworkTmp == 'searching') {
7448 return false;
7449 }
7450 if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
7451 typeNetworkTmp = 'limited_service';
7452 }
7453 if (typeNetworkTmp == 'no service') {
7454 typeNetworkTmp = 'no_service';
7455 }
7456 if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
7457 if (param.cStatus() != connStat.CONNECTED) {
7458 return false;
7459 }
7460 }
7461 if (set.AP_STATION_SUPPORT) {
7462 if (status.connectWifiStatus == "connect") {
7463 if (status.ap_station_mode == "wifi_pref") {
7464 return false;
7465 }
7466 }
7467 }
7468 return true;
7469 },
7470 doConnect: function () {
7471 showLoading('connecting');
7472 fnc.connect({}, function (data) {
7473 if (data.result) {
7474 successOverlay();
7475 } else {
7476 errorOverlay();
7477 }
7478 });
7479 },
7480 refreshHomeData: function (param) {
7481 var info = fnc.getConnectionInfo();
7482 param.connectStatus(info.connectStatus);
7483 param.canConnect(this.getCanConnectNetWork(param));
7484 param.networkType(homeUtil.getNetworkType(info.networkType));
7485 if (info.connectStatus == "ppp_connected") {
7486 param.current_Flux(transUnit(parseInt(info.data_counter.currentReceived, 10) + parseInt(info.data_counter.currentSent, 10), false));
7487 param.connected_Time(transSecond2Time(info.data_counter.currentConnectedTime));
7488 param.up_Speed(transUnit(info.data_counter.uploadRate, true));
7489 param.down_Speed(transUnit(info.data_counter.downloadRate, true));
7490 } else {
7491 param.current_Flux(transUnit(0, false));
7492 param.connected_Time(transSecond2Time(0));
7493 param.up_Speed(transUnit(0, true));
7494 param.down_Speed(transUnit(0, true));
7495 }
7496 param.trafficAlertEnable(info.limitVolumeEnable);
7497 if (info.limitVolumeEnable) {
7498 if (info.limitVolumeType == '1') {
7499 param.trafficUsed(transUnit(parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10), false));
7500 param.trafficLimited(transUnit(info.limitDataMonth, false));
7501 } else {
7502 param.trafficUsed(transSecond2Time(info.data_counter.monthlyConnectedTime));
7503 param.trafficLimited(transSecond2Time(info.limitTimeMonth));
7504 }
7505 }
7506 if (languageOld != window.language) {
7507 languageOld = window.language;
7508 num_refresh = 1;
7509 }
7510 if (param.showTraffic()) {
7511 homeUtil.updateEcharts(info);
7512 } else {
7513 homeUtil.allFreeEcharts();
7514 }
7515 homeUtil.refreshStationInfo(param);
7516 },
7517 allFreeEcharts: function () {
7518 var usedData = homeUtil.data.free;
7519 usedData.value = 1;
7520 usedData.selected = false;
7521 usedData.name = libjq.i18n.prop("echarts_no");
7522 chartOptions.series[0].data = [usedData];
7523 chartOptions.title.text = '';
7524 homeUtil.setEcharts(chartOptions, libjq.i18n.prop("echarts_no"));
7525 },
7526 getNetworkType: function (networkType) {
7527 var typeNetworkTmp = networkType.toLowerCase();
7528 if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
7529 typeNetworkTmp = 'limited_service';
7530 }
7531 if (typeNetworkTmp == 'no service') {
7532 typeNetworkTmp = 'no_service';
7533 }
7534 if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
7535 return libjq.i18n.prop("network_type_" + typeNetworkTmp);
7536 } else {
7537 return networkType;
7538 }
7539 },
7540 data: {
7541 full: {
7542 value: 30,
7543 name: '��������',
7544 itemStyle: {
7545 normal: {
7546 color: '#DF4313'
7547 }
7548 }
7549 },
7550 used: {
7551 value: 30,
7552 name: '��ʹ��',
7553 itemStyle: {
7554 normal: {
7555 color: '#8CC916'
7556 }
7557 }
7558 },
7559 left1: {
7560 value: 50,
7561 name: '����ֵ��δʹ��',
7562 itemStyle: {
7563 normal: {
7564 color: '#D8D8D8'
7565 }
7566 }
7567 },
7568 free: {
7569 value: 50,
7570 name: 'δʹ��',
7571 itemStyle: {
7572 normal: {
7573 color: '#D8D8D8'
7574 }
7575 }
7576 },
7577 alert: {
7578 value: 1,
7579 name: '����ֵ',
7580 itemStyle: {
7581 normal: {
7582 color: '#FF5500'
7583 }
7584 }
7585 },
7586 alarm: {
7587 value: 19.7,
7588 name: '������',
7589 itemStyle: {
7590 normal: {
7591 color: '#8CC916'
7592 }
7593 }
7594 },
7595 start: {
7596 value: 50,
7597 name: '����ֵ��δʹ��',
7598 itemStyle: {
7599 normal: {
7600 color: '#D8D8D8'
7601 }
7602 }
7603 },
7604 },
7605 getDataInfo: function (value) {
7606 return {
7607 data: /\d+(.\d+)?/.exec(value)[0],
7608 unit: /[A-Z]{1,2}/.exec(value)[0]
7609 }
7610 },
7611 oldAlarmData: null,
7612 oldUsedData: null,
7613 updateEcharts: function (info) {
7614 var startName = libjq.i18n.prop("echarts_no");
7615 num_refresh++;
7616 if (num_refresh % 10 != 2) {
7617 return false;
7618 }
7619 var total = 0,
7620 used = 0,
7621 reach = 0,
7622 left = 0,
7623 alarm = 0,
7624 left1 = 0;
7625 if (info.limitVolumeEnable) {
7626 startName = libjq.i18n.prop("echarts_used");
7627 chartOptions.series[0].data = [];
7628 if (info.limitVolumeType == '1') {
7629 var limitedDataFormatted = transUnit(info.limitDataMonth, false);
7630 chartOptions.series[0].data = [];
7631 if (info.limitDataMonth == 0) {
7632 var usedData = homeUtil.data.used;
7633 usedData.value = 1;
7634 usedData.selected = false;
7635 usedData.name = libjq.i18n.prop("echarts_used");
7636 chartOptions.series[0].data.push(usedData);
7637 } else {
7638 var dataInfo = homeUtil.getDataInfo(limitedDataFormatted);
7639 total = dataInfo.data * homeUtil.getUnitValue(dataInfo.unit) * 1048576;
7640 used = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
7641 reach = total * info.limitVolumePercent / 100;
7642 if (used >= total) {
7643 var fullData = homeUtil.data.full;
7644 fullData.value = 100;
7645 fullData.name = libjq.i18n.prop("echarts_full");
7646 chartOptions.series[0].data.push(fullData);
7647 startName = libjq.i18n.prop("echarts_full");
7648 } else {
7649 if (reach - used > 0) {
7650 left1 = reach - used;
7651 left = total - reach;
7652 } else {
7653 alarm = used - reach;
7654 left = total - used;
7655 }
7656 var usedData = homeUtil.data.used;
7657 if (reach - used > 0) {
7658 usedData.value = used;
7659 } else {
7660 usedData.value = reach;
7661 }
7662 usedData.name = libjq.i18n.prop("echarts_used");
7663 chartOptions.series[0].data.push(usedData);
7664 if (left1 > 0) {
7665 var left1Data = homeUtil.data.left1;
7666 left1Data.value = left1;
7667 left1Data.name = libjq.i18n.prop("echarts_left1");
7668 chartOptions.series[0].data.push(left1Data);
7669 }
7670 var alertData = homeUtil.data.alert;
7671 alertData.value = total / 200;
7672 alertData.name = libjq.i18n.prop("echarts_alert");
7673 chartOptions.series[0].data.push(alertData);
7674 if (alarm > 0) {
7675 var alarmData = homeUtil.data.alarm;
7676 alarmData.value = alarm;
7677 alarmData.name = libjq.i18n.prop("echarts_alarm");
7678 chartOptions.series[0].data.push(alarmData);
7679 }
7680 var freeData = homeUtil.data.free;
7681 freeData.value = left;
7682 freeData.name = libjq.i18n.prop("echarts_free");
7683 chartOptions.series[0].data.push(freeData);
7684 }
7685 }
7686 } else {
7687 chartOptions.series[0].data = [];
7688 if (info.limitTimeMonth == 0) {
7689 var usedData = homeUtil.data.used;
7690 usedData.value = 1;
7691 usedData.selected = false;
7692 usedData.name = libjq.i18n.prop("echarts_used");
7693 chartOptions.series[0].data.push(usedData);
7694 } else {
7695 total = info.limitTimeMonth;
7696 used = info.data_counter.monthlyConnectedTime;
7697 reach = total * info.limitVolumePercent / 100;
7698 if (used >= total) {
7699 var fullTime = homeUtil.data.full;
7700 fullTime.value = 100;
7701 fullTime.name = libjq.i18n.prop("echarts_full");
7702 chartOptions.series[0].data.push(fullTime);
7703 startName = libjq.i18n.prop("echarts_full");
7704 } else {
7705 if (reach - used > 0) {
7706 left1 = reach - used;
7707 left = total - reach;
7708 } else {
7709 alarm = used - reach;
7710 left = total - used;
7711 }
7712 var usedTime = homeUtil.data.used;
7713 if (reach - used > 0) {
7714 usedTime.value = used;
7715 } else {
7716 usedTime.value = reach;
7717 }
7718 usedTime.name = libjq.i18n.prop("echarts_used");
7719 chartOptions.series[0].data.push(usedTime);
7720 if (left1 > 0) {
7721 var left1Time = homeUtil.data.left1;
7722 left1Time.value = left1;
7723 left1Time.name = libjq.i18n.prop("echarts_left1");
7724 chartOptions.series[0].data.push(left1Time);
7725 }
7726 var alertTime = homeUtil.data.alert;
7727 alertTime.value = total / 200;
7728 alertTime.name = libjq.i18n.prop("echarts_alert");
7729 chartOptions.series[0].data.push(alertTime);
7730 if (alarm > 0) {
7731 var alarmTime = homeUtil.data.alarm;
7732 alarmTime.value = alarm;
7733 alarmTime.name = libjq.i18n.prop("echarts_alarm");
7734 chartOptions.series[0].data.push(alarmTime);
7735 }
7736 var freeTime = homeUtil.data.free;
7737 freeTime.value = left;
7738 freeTime.name = libjq.i18n.prop("echarts_free");
7739 chartOptions.series[0].data.push(freeTime);
7740 }
7741 }
7742 }
7743 } else {
7744 var usedData = homeUtil.data.used;
7745 usedData.value = 1;
7746 usedData.selected = false;
7747 usedData.name = libjq.i18n.prop("echarts_no");
7748 chartOptions.series[0].data = [usedData];
7749 chartOptions.title.text = '';
7750 }
7751 var firstEle = libus.find(chartOptions.series[0].data, function (n) {
7752 return n.name == libjq.i18n.prop("echarts_used");
7753 });
7754 var alarmEle = libus.find(chartOptions.series[0].data, function (n) {
7755 return n.name == libjq.i18n.prop("echarts_alarm");
7756 });
7757 if (!alarmEle) {
7758 alarmEle = {
7759 value: 0
7760 };
7761 }
7762 if (typeof firstEle == "undefined") {
7763 homeUtil.setEcharts(chartOptions, startName);
7764 } else if (homeUtil.oldUsedData != firstEle.value || homeUtil.oldAlarmData != alarmEle.value) {
7765 homeUtil.oldUsedData = firstEle.value;
7766 homeUtil.oldAlarmData = alarmEle.value;
7767 homeUtil.setEcharts(chartOptions, startName);
7768 }
7769 },
7770 getUnitValue: function (unit) {
7771 unit = unit.toUpperCase();
7772 if (unit == 'GB') {
7773 return '1024';
7774 } else if (unit == 'TB') {
7775 return '1048576';
7776 } else {
7777 return '1';
7778 }
7779 },
7780 setEcharts: function (options, startName) {
7781 var startPart = homeUtil.data.start;
7782 startPart.value = 0;
7783 startPart.name = startName;
7784 startPart.selected = false;
7785 var arr = [startPart].concat(options.series[0].data);
7786 options.series[0].data = arr;
7787 traffic_graphic_chart.setOption(options, true);
7788 addTimeout(function () {
7789 traffic_graphic_chart.resize();
7790 }, 1000);
7791 },
7792 refreshStationInfo: function (param) {
7793 param.wirelessDeviceNum(fnc.getStatusInfo().wirelessDeviceNum);
7794 if (num_refresh % 10 == 2) {
7795 fnc.getAttachedCableDevices({}, function (data) {
7796 param.wireDeviceNum(data.attachedDevices.length);
7797 });
7798 }
7799 },
7800 getUnit: function (val) {
7801 if (val == '1024') {
7802 return 'GB';
7803 } else if (val == '1048576') {
7804 return 'TB';
7805 } else {
7806 return 'MB';
7807 }
7808 },
7809 refreshOpmodeInfo: function (param) {
7810 var obj = fnc.getOpMode();
7811 param.isLoggedIn(obj.loginfo == "ok");
7812 var currentMode = checkCableMode(obj.blc_wan_mode);
7813 if (param.opCurMode() && !currentMode) {
7814 var data = fnc.getLoginData();
7815 var state = data.modem_main_state;
7816 if (state == "modem_sim_undetected" || state == "modem_undetected" || state == "modem_sim_destroy" || state == "modem_waitpin" || state == "modem_waitpuk" || state == "modem_imsi_waitnck") {
7817 window.location.reload();
7818 return;
7819 }
7820 }
7821 param.opCurMode(currentMode);
7822 if (currentMode && obj.ethwan_mode == "DHCP") {
7823 param.enableFlag(false);
7824 } else if ((!currentMode && obj.ppp_status != "ppp_disconnected") || (currentMode && obj.rj45_state != "idle" && obj.rj45_state != "dead")) {
7825 param.enableFlag(true);
7826 } else {
7827 param.enableFlag(false);
7828 }
7829 var mode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;
7830 var currentOpMode = "";
7831 switch (mode) {
7832 case "AUTO":
7833 currentOpMode = "opmode_auto";
7834 break;
7835 case "PPPOE":
7836 currentOpMode = "opmode_cable";
7837 break;
7838 case "PPP":
7839 currentOpMode = "opmode_gateway";
7840 break;
7841 default:
7842 break;
7843 }
7844 libjq("#opmode").attr("data-trans", currentOpMode).text(libjq.i18n.prop(currentOpMode));
7845 param.isShowHomeConnect(!currentMode);
7846 param.showTraffic(set.TRAFFIC_SUPPORT && !currentMode);
7847 param.isSupportQuicksetting(set.HAS_QUICK_SETTING && !currentMode);
7848 }
7849 };
7850 function VmHome() {
7851 var target = this;
7852 target.hasSms = set.HAS_SMS;
7853 target.hasPhonebook = set.HAS_PHONEBOOK;
7854 target.isSupportSD = set.SD_CARD_SUPPORT;
7855 target.isCPE = set.PRODUCT_TYPE == 'CPE';
7856 target.hasRj45 = set.RJ45_SUPPORT;
7857 target.notDataCard = set.PRODUCT_TYPE != 'DATACARD';
7858 target.hasParentalControl = set.HAS_PARENTAL_CONTROL;
mj.qu8dce7222025-01-06 00:52:12 -08007859 target.hasUssd = set.HAS_USSD;
qumengjia1cd76022024-10-31 17:51:04 +08007860 var wifiInfo = fnc.getWifiBasic();
7861 if (set.WIFI_SUPPORT_QR_SWITCH) {
7862 target.showQRCode = set.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;
7863 } else {
7864 target.showQRCode = set.WIFI_SUPPORT_QR_CODE;
7865 }
7866 if(set.WIFI_SUPPORT_QR_CODE){
7867 target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + libjq.now();
7868 } else {
7869 target.qrcodeSrc = './pic/res_blacktrans.png';
7870 }
7871 if (target.hasRj45) {
7872 var opModeObj = checkCableMode(fnc.getOpMode().blc_wan_mode);
7873 target.opCurMode = libko.observable(opModeObj);
7874 target.isShowHomeConnect = libko.observable(!opModeObj);
7875 target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT && !opModeObj);
7876 target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING && !opModeObj);
7877 } else {
7878 target.isShowHomeConnect = libko.observable(true);
7879 target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT);
7880 target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING);
7881 }
7882 if (set.PRODUCT_TYPE == 'DATACARD') {
7883 libjq('#home_image').addClass('data-card');
7884 }
7885 var info = fnc.getConnectionInfo();
7886 target.networkType = libko.observable(homeUtil.getNetworkType(info.networkType));
7887 target.connectStatus = libko.observable(info.connectStatus);
7888 target.canConnect = libko.observable(false);
7889 target.cStatus = libko.computed(function () {
7890 if (target.connectStatus().indexOf('_connected') != -1) {
7891 return connStat.CONNECTED;
7892 } else if (target.connectStatus().indexOf('_disconnecting') != -1) {
7893 return connStat.DISCONNECTING;
7894 } else if (target.connectStatus().indexOf('_connecting') != -1) {
7895 return connStat.CONNECTING;
7896 } else {
7897 return connStat.DISCONNECTED;
7898 }
7899 });
7900 target.current_Flux = libko.observable(transUnit(0, false));
7901 target.connected_Time = libko.observable(transSecond2Time(0));
7902 target.up_Speed = libko.observable(transUnit(0, true));
7903 target.down_Speed = libko.observable(transUnit(0, true));
7904 target.isLoggedIn = libko.observable(false);
7905 target.enableFlag = libko.observable(true);
7906 target.simSerialNumber = libko.observable('');
7907 target.imei = libko.observable('');
7908 target.imsi = libko.observable('');
mj.qu39da3602025-01-06 01:36:47 -08007909 target.iccid = libko.observable('');
mj.qu457a30a2025-01-06 18:02:38 -08007910 target.cellid = libko.observable('');
qumengjia1cd76022024-10-31 17:51:04 +08007911 target.ssid = libko.observable('');
7912 target.hasWifi = set.HAS_WIFI;
7913 target.showMultiSsid = libko.observable(set.HAS_MULTI_SSID && wifiInfo.multi_ssid_enable == "1");
7914 target.trafficAlertEnable = libko.observable(false);
7915 target.trafficUsed = libko.observable('');
7916 target.trafficLimited = libko.observable('');
7917 target.wireDeviceNum = libko.observable(fnc.getAttachedCableDevices().attachedDevices.length);
7918 target.wirelessDeviceNum = libko.observable(fnc.getStatusInfo().wirelessDeviceNum);
7919 target.showOpModeWindow = function () {
7920 if (target.enableFlag()) {
7921 return;
7922 }
7923 showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});
7924 };
7925 target.currentOpMode = libko.observable("0");
7926 var popoverShown = false;
7927 libjq('#showDetailInfo').popover({
7928 html: true,
7929 placement: 'top',
7930 trigger: 'focus',
7931 title: function () {
7932 return libjq.i18n.prop('device_info')
7933 },
7934 content: function () {
7935 return getDetailInfoContent();
7936 }
7937 }).on('shown.bs.popover', function () {
7938 popoverShown = true;
7939 }).on('hidden.bs.popover', function () {
7940 popoverShown = false;
7941 });
7942 function fetchDeviceInfo() {
7943 var data = fnc.getDeviceInfo();
7944 target.simSerialNumber(verifyDeviceInfo(data.simSerialNumber));
7945 target.imei(verifyDeviceInfo(data.imei));
7946 target.imsi(verifyDeviceInfo(data.imsi));
mj.qu39da3602025-01-06 01:36:47 -08007947 target.iccid(verifyDeviceInfo(data.iccid));
mj.qu457a30a2025-01-06 18:02:38 -08007948 target.cellid(verifyDeviceInfo(data.cellid));
qumengjia1cd76022024-10-31 17:51:04 +08007949 target.ssid(verifyDeviceInfo(data.ssid));
7950 target.showMultiSsid(set.HAS_MULTI_SSID && data.multi_ssid_enable == "1");
7951 return data;
7952 }
7953 fetchDeviceInfo();
7954 function getDetailInfoContent() {
7955 var data = fetchDeviceInfo();
7956 homeUtil.initShownStatus(data);
7957 var addrInfo = homeUtil.wanIpGet(data);
7958 var compiled = libus.template(libjq("#detailInfoTmpl").html());
7959 var tmpl = compiled({
7960 simSerialNumber: verifyDeviceInfo(data.simSerialNumber),
7961 imei: verifyDeviceInfo(data.imei),
7962 imsi: verifyDeviceInfo(data.imsi),
mj.qu39da3602025-01-06 01:36:47 -08007963 iccid : verifyDeviceInfo(data.iccid),
mj.qu457a30a2025-01-06 18:02:38 -08007964 cellid: verifyDeviceInfo(data.cellid),
qumengjia1cd76022024-10-31 17:51:04 +08007965 signal: signalFormat(data.signal),
7966 hasWifi: set.HAS_WIFI,
7967 isCPE: set.PRODUCT_TYPE == 'CPE',
7968 hasRj45: set.RJ45_SUPPORT,
7969 showMultiSsid: set.HAS_MULTI_SSID && data.multi_ssid_enable == "1",
7970 ssid: verifyDeviceInfo(data.ssid),
7971 max_access_num: verifyDeviceInfo(data.max_access_num),
7972 m_ssid: verifyDeviceInfo(data.m_ssid),
7973 m_max_access_num: verifyDeviceInfo(data.m_max_access_num),
7974 wifi_long_mode: "wifi_des_" + data.wifiRange,
7975 lanDomain: verifyDeviceInfo(data.lanDomain),
7976 ipAddress: verifyDeviceInfo(data.ipAddress),
7977 showMacAddress: set.SHOW_MAC_ADDRESS,
7978 macAddress: verifyDeviceInfo(data.macAddress),
7979 showIpv4WanIpAddr: homeUtil.initStatus.showIpv4WanIpAddr,
7980 wanIpAddress: addrInfo.wanIpAddress,
7981 showIpv6WanIpAddr: homeUtil.initStatus.showIpv6WanIpAddr,
7982 ipv6WanIpAddress: addrInfo.ipv6WanIpAddress,
7983 sw_version: verifyDeviceInfo(data.sw_version),
7984 hw_version: verifyDeviceInfo(data.hw_version)
7985 });
7986 return libjq(tmpl).translate();
7987 }
7988 target.connectHandler = function () {
7989 if (target.connectStatus() == "ppp_connected") {
7990 showLoading('disconnecting');
7991 fnc.disconnect({}, function (data) {
7992 if (data.result) {
7993 successOverlay();
7994 } else {
7995 errorOverlay();
7996 }
7997 });
7998 } else {
7999 if (fnc.getStatusInfo().roamingStatus) {
8000 showConfirm('dial_roaming_connect', function () {
8001 target.connect();
8002 });
8003 } else {
8004 target.connect();
8005 }
8006 }
8007 };
8008 target.connect = function () {
8009 var statusInfo = fnc.getStatusInfo();
8010 var trafficResult = barStat.getTrafficResult(statusInfo);
8011 if (statusInfo.limitVolumeEnable && trafficResult.showConfirm) {
8012 var confirmMsg = null;
8013 if (trafficResult.usedPercent > 100) {
8014 confirmMsg = {
8015 msg: 'traffic_beyond_connect_msg'
8016 };
8017 barStat.setTrafficAlertPopuped(true);
8018 } else {
8019 confirmMsg = {
8020 msg: 'traffic_limit_connect_msg',
8021 params: [trafficResult.limitPercent]
8022 };
8023 barStat.setTrafficAlert100Popuped(false);
8024 }
8025 showConfirm(confirmMsg, function () {
8026 homeUtil.doConnect();
8027 });
8028 } else {
8029 homeUtil.doConnect();
8030 }
8031 };
8032 fnc.getSignalStrength({}, function (data) {
8033 var signalTxt = signalFormat(convertSignal(data));
8034 libjq("#fresh_signal_strength").text(signalTxt);
8035 if (popoverShown) {
8036 libjq("#popoverSignalTxt").text(signalTxt);
8037 }
8038 });
8039 homeUtil.refreshHomeData(target);
8040 addInterval(function () {
8041 fnc.getSignalStrength({}, function (data) {
8042 var signalTxt = signalFormat(convertSignal(data));
8043 libjq("#fresh_signal_strength").text(signalTxt);
8044 if (popoverShown) {
8045 libjq("#popoverSignalTxt").text(signalTxt);
8046 }
8047 });
8048 homeUtil.refreshHomeData(target);
8049 }, 1000);
8050 if (target.hasRj45) {
8051 homeUtil.refreshOpmodeInfo(target);
8052 addInterval(function () {
8053 homeUtil.refreshOpmodeInfo(target);
8054 }, 1000);
8055 }
8056 target.showNetworkSettingsWindow = function () {
8057 if (target.hasRj45) {
8058 fnc.getOpMode({}, function (data) {
8059 var mode = checkCableMode(data.blc_wan_mode);
8060 if (mode) {
8061 window.location.hash = '#network_set';
8062 } else {
8063 window.location.hash = '#conn_set';
8064 }
8065 });
8066 } else {
8067 window.location.hash = '#conn_set';
8068 }
8069 }
8070 };
8071 return {
8072 init: init
8073 };
8074});
8075
8076
8077define("language","knockout service jquery set underscore".split(" "),
8078 function(ko, service, $, config, _) {
8079
8080 // ��ȡ��ǰ������
8081 function getCurrentLanguage() {
8082 return service.getLanguage();
8083 }
8084
8085 // ��������������������Դ������ҳ���ϵ�body����
8086 // @param {String} current ������:zh-cn
8087 function loadLanguageAndRefresh(current){
8088 window.CURRENT_LANGUAGE = current;
8089 $("body").attr('lang', current);
8090 $.i18n.properties({
8091 name:'Messages',
8092 path:'i18n/',
8093 mode:'map',
8094 cache: true,
8095 language:current,
8096 callback: function() {
8097 jQuery.validator.messages = $.i18n.map;
8098 $('body').translate();
8099 }
8100 });
8101 }
8102
8103 window.language = null;
8104
8105
8106 function LanguageViewModel() {
8107 var target = this;
8108 var currentLan = getCurrentLanguage();
8109 var languages = _.map(config.LANGUAGES, function(item) {
8110 return new Option(item.name, item.value);
8111 });
8112
8113 document.title = config.WEBUI_TITLE;
8114 if($('#webui_title')[0]) {
8115 $('#webui_title').html(config.WEBUI_TITLE);
8116 }
8117
8118 target.languages = ko.observableArray(languages);
8119 target.currentLan = ko.observable(currentLan.Language);
8120 window.language = target.currentLan();
8121
8122 // �л������¼�����
8123 // @event langChangeHandler
8124 target.langChangeHandler = function(info, event) {
8125 clearValidateMsg();
8126
8127 service.setLanguage({Language: target.currentLan()}, function() {
8128 loadLanguageAndRefresh(target.currentLan());
8129 window.language = target.currentLan();
8130 });
8131 };
8132
8133 // ���������б���ˢ�½���
8134 loadLanguageAndRefresh(target.currentLan());
8135 }
8136
8137 // ��ʼ������VM������
8138 function init() {
8139 ko.applyBindings(new LanguageViewModel(), $('#language')[0]);
8140 }
8141
8142 return {
8143 init: init
8144 };
8145});
8146
8147
8148// ��½ ģ��
8149define("entry","jquery knockout set service underscore menu logout CryptoJS".split(" "),
8150 function($, ko,config, service, _, menu, logout, CryptoJS) {
8151
8152
8153 var pageState = {LOGIN:0, WAIT_PIN:1, WAIT_PUK:2, PUK_LOCKED:3, LOGGEDIN:4, LOADING:5};
8154 var timer = loginStatusCheckingTimer();
8155 var loginLockTimer = 0;
8156 var lastLoginStatus = "0";
8157
8158 function loginViewModel() {
8159 var target = this;
8160 var data = service.getLoginData();
8161 var loginStatus = service.getLoginStatus();
8162
8163 target.confirmPIN = ko.observable();
8164 target.leftSeconds = ko.observable(0);
8165 target.loginCount = ko.observable(0);
8166 target.loginSecuritySupport = ko.observable(config.LOGIN_SECURITY_SUPPORT);
8167 target.newPIN = ko.observable();
8168 target.password = ko.observable();
8169 target.PIN = ko.observable();
8170 target.pinNumber = ko.observable(data.pinnumber);
8171 target.PUK = ko.observable();
8172 target.pukNumber = ko.observable(data.puknumber);
8173 target.showEntrance = ko.observable(false);
8174 target.sharePathInvalid = ko.observable(false);
8175 target.uiLoginTimer = ko.observable(300);
8176
8177 // ע��˳�򣬵���ǰ�����޷�ˢ�³�����
8178 target.accountLocked = ko.computed(function () {
8179 return target.loginCount() == config.MAX_LOGIN_COUNT && target.leftSeconds() != '-1';
8180 });
8181
8182 target.leftUnlockTime = ko.computed(function () {
8183 target.leftSeconds();
8184 var formatted = transSecond2Time(target.uiLoginTimer());
8185 return formatted.substring(formatted.indexOf(':') + 1, formatted.length);
8186 });
8187
8188
8189 if(config.SD_CARD_SUPPORT){
8190 service.getSDConfiguration({}, function (data) {
8191 target.showEntrance(data.sd_status == "1" && data.share_status == "1" && data.sd_mode == "0");
8192 if(target.showEntrance()){
8193 service.checkFileExists({
8194 path: data.share_file
8195 }, function (data1) {
8196 if (data1.status == 'exist' || data1.status == 'processing') {
8197 target.sharePathInvalid(false);
8198 } else {
8199 target.sharePathInvalid(true);
8200 }
8201 });
8202 }
8203 });
8204 }
8205
8206 var state = computePageState(loginStatus, data);
8207 target.pageState = ko.observable(state);
8208 if (state == pageState.LOADING) {
8209 addTimeout(refreshPage, 500);
8210 }
8211 setFocus();
8212
8213
8214 // login �¼�����
8215
8216 target.login = function () {
8217 if(config.LOGIN_SECURITY_SUPPORT && target.accountLocked()){
8218 showAlert("password_error_account_lock_time", function () {
8219 setFocus();
8220 });
8221 return false;
8222 }
8223 target.pageState(pageState.LOADING);
8224 window.clearInterval(timer);
8225 var ciphertext = "";
8226 if (config.PASSWORD_ENCODE) {
8227 ciphertext = target.password();
8228 } else {
8229 var kparam = service.getDeviceInfoLow();
8230 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
8231 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
8232 ciphertext = CryptoJS.AES.encrypt(target.password(), tkey, {
8233 iv: tiv,
8234 mode: CryptoJS.mode.CBC,
8235 padding: CryptoJS.pad.ZeroPadding
8236 }).toString();
8237 }
8238 service.login({
8239 password:ciphertext
8240 }, function (info) {
8241 setTimeout(function () {
8242 timer = loginStatusCheckingTimer();
8243 }, 1300);
8244 if (info.result) {
8245 target.pageState(pageState.LOGGEDIN);
8246 if(config.LOGIN_SECURITY_SUPPORT){
8247 target.loginCount(0);
8248 target.uiLoginTimer(300);
8249 clearInterval(loginLockTimer);
8250 }
8251 $("#container").empty();
8252 window.location.hash = "#main";
8253 logout.init();
8254 } else {
8255 target.password("");
8256 if(config.LOGIN_SECURITY_SUPPORT){
8257 target.checkLoginData(function(){
8258 if (target.loginCount() == config.MAX_LOGIN_COUNT) {
8259 showAlert("password_error_five_times", function () {
8260 setFocus();
8261 });
8262 target.startLoginLockInterval();
8263 } else {
8264 showAlert({msg: 'password_error_left', params: [config.MAX_LOGIN_COUNT - target.loginCount()]}, function () {
8265 setFocus();
8266 });
8267 }
8268 });
8269 }else {
8270 showAlert("password_error", function () {
8271 setFocus();
8272 });
8273 }
8274 target.pageState(pageState.LOGIN);
8275 }
8276 });
8277 };
8278
8279
8280
8281
8282 // ��ȡ��¼������Ϣ
8283 target.checkLoginData = function(cb){
8284 service.getLoginData({}, function(r){
8285 var failTimes = parseInt(r.psw_fail_num_str, 10);
8286 target.loginCount(config.MAX_LOGIN_COUNT - failTimes);
8287 target.leftSeconds(r.login_lock_time);
8288 target.uiLoginTimer(r.login_lock_time);
8289 if($.isFunction(cb)){
8290 cb();
8291 } else if (target.loginCount() == config.MAX_LOGIN_COUNT) {
8292 target.startLoginLockInterval();
8293 }
8294 });
8295 };
8296
8297 // ��������ʱ��ʱ����
8298 target.startLoginLockInterval = function () {
8299 loginLockTimer = setInterval(function () {
8300 service.getLoginData({}, function (data) {
8301 if (data.login_lock_time <= 0 || data.psw_fail_num_str == 5) {
8302 target.loginCount(0);
8303 clearInterval(loginLockTimer);
8304 }
8305 if(target.leftSeconds() != data.login_lock_time){
8306 target.leftSeconds(data.login_lock_time);
8307 target.uiLoginTimer(data.login_lock_time);
8308 } else {
8309 target.uiLoginTimer(target.uiLoginTimer() > 0 ? target.uiLoginTimer() - 1 : 0);
8310 }
8311 });
8312 }, 1000);
8313 };
8314
8315 target.checkLoginData();
8316
8317
8318
8319 // ��֤����PIN�¼�����
8320 target.enterPIN = function () {
8321 target.pageState(pageState.LOADING);
8322 var pin = target.PIN();
8323 service.enterPIN({
8324 PinNumber:pin
8325 }, function (data) {
8326 if (!data.result) {
8327 showAlert("pin_error", function () {
8328 refreshPage();
8329 });
8330 target.PIN('');
8331 } else {
8332 refreshPage();
8333 }
8334 });
8335 };
8336
8337 function setFocus(){
8338 setTimeout(function () {
8339 var txtAdmin = $('#txtAdmin:visible');
8340 var txtPIN = $('#txtPIN:visible');
8341 var txtPUK = $('#txtPUK:visible');
8342 if (txtAdmin.length > 0) {
8343 txtAdmin.focus();
8344 } else if (txtPIN.length > 0) {
8345 txtPIN.focus();
8346 } else if (txtPUK.length > 0) {
8347 txtPUK.focus();
8348 }
8349 }, 100);
8350 }
8351
8352
8353 // ˢ��ҳ��״̬
8354 function refreshPage() {
8355 var data = service.getLoginData();
8356 var loginStatus = service.getLoginStatus();
8357 var state = computePageState(loginStatus, data);
8358 if (state == pageState.LOADING) {
8359 addTimeout(refreshPage, 500);
8360 } else {
8361 target.pageState(state);
8362 target.pinNumber(data.pinnumber);
8363 target.pukNumber(data.puknumber);
8364 }
8365 setFocus();
8366 }
8367
8368 // ����PUK������PIN�¼�����
8369 target.enterPUK = function () {
8370 target.pageState(pageState.LOADING);
8371 var newPIN = target.newPIN();
8372 var confirmPIN = target.confirmPIN();
8373 var params = {};
8374 params.PinNumber = newPIN;
8375 params.PUKNumber = target.PUK();
8376 service.enterPUK(params, function (data) {
8377 if (!data.result) {
8378 showAlert("puk_error", function () {
8379 refreshPage();
8380 });
8381 target.PUK('');
8382 target.newPIN('');
8383 target.confirmPIN('');
8384 } else {
8385 refreshPage();
8386 }
8387 });
8388 };
8389
8390
8391
8392 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8393 function checkPinAfterLogin(loginStatus, data) {
8394 if (loginStatus.status == "loggedIn") {
8395 var currentState = data.modem_main_state; // cov_2
8396 if (currentState == "modem_waitpin") {
8397 return pageState.WAIT_PIN;
8398 } else if ((currentState == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {
8399 return pageState.WAIT_PUK;
8400 } else if ((data.puknumber == 0 || currentState == "modem_sim_destroy")
8401 && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
8402 return pageState.PUK_LOCKED;
8403 } else {
8404 return pageState.LOGGEDIN;
8405 }
8406 } else {
8407 var currentState = data.modem_main_state;
8408 if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8409 return pageState.LOADING;
8410 } else {
8411 return pageState.LOGIN;
8412 }
8413 }
8414 }
8415
8416 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8417 function computePageState(loginStatus, data) {
8418 //PX-880 �ȵ�¼�ٽ���PIN��֤������router����ԭ�򣬵�¼����PIN��֤���ڵ�¼ҳ�����У������ݿ�����֤����һ�¡�
8419 if (config.LOGIN_THEN_CHECK_PIN) {
8420 return checkPinAfterLogin(loginStatus, data);
8421 } else {
8422 return loginAfterCheckPin(loginStatus, data);
8423 }
8424 }
8425
8426 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8427 function loginAfterCheckPin(loginStatus, data) {
8428 if (loginStatus.status == "loggedIn") {
8429 return pageState.LOGGEDIN;
8430 } else {
8431 var currentState = data.modem_main_state;
8432 if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8433 return pageState.LOADING;
8434 } else if (currentState == "modem_waitpin") {
8435 return pageState.WAIT_PIN;
8436 } else if ((currentState == "modem_waitpuk" || parseInt(data.pinnumber) === 0) && (parseInt(data.puknumber) != 0)) {
8437 return pageState.WAIT_PUK;
8438 } else if ((parseInt(data.puknumber) === 0 || currentState == "modem_sim_destroy") && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
8439 return pageState.PUK_LOCKED;
8440 } else {
8441 return pageState.LOGIN;
8442 }
8443 }
8444 }
8445 }
8446
8447
8448 // ���鵱ǰwindow.location.hash���쳣����ת��index.html
8449 function gotoLogin() {
8450 if (window.location.hash != config.defaultRoute && _.indexOf(config.GUEST_HASH, window.location.hash) == -1) {
8451 if (!manualLogout && lastLoginStatus == "1") {
8452 manualLogout = false;
8453 lastLoginStatus = 'UNREAL';
8454 showAlert('need_login_again', function () {
8455 window.location = "index.html";
8456 });
8457 } else if (lastLoginStatus == 'UNREAL') {
8458 //do nothing, only popup need_login_again alert one time
8459 return;
8460 } else {
8461 window.location = "index.html";
8462 }
8463 }
8464 }
8465
8466 // ��ʱ������¼״̬
8467 function loginStatusCheckingTimer() {
8468 return setInterval(function () {
8469 var info = service.getStatusInfo();
8470 if (!info.isLoggedIn) {
8471 gotoLogin();
8472 return;
8473 }
8474 lastLoginStatus = service.getStatusInfo().isLoggedIn ? "1" : "0";
8475 }, 1000);
8476 }
8477
8478 function init() {
8479 var info = service.getStatusInfo();
8480 if (info.isLoggedIn) {
8481 window.location.hash = '#main';
8482 return;
8483 }
8484
8485 var container = $('#container')[0];
8486 ko.cleanNode(container);
8487 var fwVm = new loginViewModel();
8488 ko.applyBindings(fwVm, container);
8489
8490 $('#frmLogin').validate({
8491 submitHandler:function () {
8492 fwVm.login();
8493 },
8494 rules: {
8495 txtAdmin: 'login_password_length_check'
8496 }
8497 });
8498 $('#frmPIN').validate({
8499 submitHandler:function () {
8500 fwVm.enterPIN();
8501 },
8502 rules:{
8503 txtPIN:"pin_check"
8504 }
8505 });
8506 $('#frmPUK').validate({
8507 submitHandler:function () {
8508 fwVm.enterPUK();
8509 },
8510 rules:{
8511 txtNewPIN:"pin_check",
8512 txtConfirmPIN:{equalToPin:"#txtNewPIN"},
8513 txtPUK:"puk_check"
8514 }
8515 });
8516 }
8517
8518
8519 return {
8520 init:init,
8521 gotoLogin:gotoLogin
8522 };
8523 });
8524
8525
8526// Logout �
8527define("logout","set service knockout underscore jquery".split(" "),
8528 function (config, service, ko, _, $) {
8529
8530 function logoutViewModel() {
8531 var target = this;
8532 // ��ȡ�Ƿ���¼
8533 var loginFlag = function () {
8534 var loginInfo = service.getLoginStatus();
8535 return (loginInfo.status == "loggedIn");
8536 }
8537 ();
8538 target.loggedIn = ko.observable(loginFlag);
8539
8540 // �˳�ϵͳ
8541 target.logout = function () {
8542 showConfirm("confirm_logout", function () {
8543 manualLogout = true;
8544 service.logout({}, setLocation());
8545 });
8546 };
8547
8548 // �Ƿ���ʾ�˳���ť
8549 target.showLogout = function () {
8550 if (config.HAS_LOGIN) {
8551 return target.loggedIn();
8552 } else {
8553 return false;
8554 }
8555 };
8556 }
8557 function setLocation() {
8558 window.location = 'index.html';
8559 }
8560 function initialize() {
8561 var fwVm = new logoutViewModel();
8562 bindContainer(fwVm);
8563 }
8564 function bindContainer(fwVm) {
8565 var con = $('#logout')[0];
8566 ko.cleanNode(con);
8567 ko.applyBindings(fwVm, con);
8568 }
8569 return {
8570 init: initialize
8571 };
8572});
8573
8574// operation mode �
8575define("opmode","knockout service jquery set underscore".split(" "),
8576
8577 function (ko, service, $, config, _) {
8578
8579 function currentOperationModeViewMode(){
8580 var target = this;
8581 target.isLoggedIn = ko.observable(false);
8582 target.enableFlag = ko.observable(false);
8583
8584 target.showOpModeWindow = function () {
8585 showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {
8586 });
8587 };
8588 target.currentOpMode = ko.observable("0");
8589
8590 service.getOpMode({}, function(info){
8591 target.isLoggedIn(info.loginfo == "ok");
8592 if (info.opms_wan_mode != "PPP" && info.rj45_state != "idle" && info.rj45_state != "dead") {
8593 target.enableFlag(false);
8594 } else if (info.opms_wan_mode == "PPP" && info.ppp_status != "ppp_disconnected") {
8595 target.enableFlag(false);
8596 } else if(info.opms_wan_mode == "DHCP"){
8597 target.enableFlag(true);
8598 } else {
8599 target.enableFlag(true);
8600 }
8601
8602 var opmsWanMode = (info.opms_wan_mode == "DHCP" || info.opms_wan_mode == "STATIC") ? "PPPOE" : info.opms_wan_mode;
8603
8604 var currentOperationMode = "";
8605 switch(opmsWanMode){
8606 case "BRIDGE":
8607 currentOperationMode = "opmode_bridge";
8608 break;
8609 case "PPP":
8610 currentOperationMode = "opmode_gateway";
8611 break;
8612 case "PPPOE":
8613 currentOperationMode = "opmode_cable";
8614 break;
8615 default:
8616 break;
8617 }
8618 $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
8619 });
8620 // ��ʱ��ѯ����ģʽ����״̬�����ý���״̬
8621 setInterval(function(){
8622 var object = service.getConnectionInfo();
8623 if(object.opms_wan_mode == "DHCP") {
8624 target.enableFlag(true);
8625 } 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")) {
8626 target.enableFlag(false);
8627 } else {
8628 target.enableFlag(true);
8629 }
8630 }, 1000);
8631 }
8632
8633 function init() {
8634 var container = $('#currentOpMode')[0];
8635 ko.cleanNode(container);
8636 var fwVm = new currentOperationModeViewMode();
8637 ko.applyBindings(fwVm, container);
8638 }
8639
8640 return {
8641 init:init
8642 };
8643});
8644
8645// operation mode popup�
8646
8647define("opmode_popup","knockout service jquery set underscore".split(" "),
8648
8649 function (ko, service, $, config, _) {
8650
8651 function operationModeViewMode() {
8652 var target = this;
8653 var currentSelectedOperationMode = "";
8654 target.selectedMode = ko.observable("0");
8655
8656 // ��ʼ������ģʽ��ʾ
8657 service.getOpMode({}, function(info){
8658 if(info.blc_wan_mode == "AUTO_PPP"){
8659 currentSelectedOperationMode = "AUTO";
8660 }else if(info.blc_wan_mode == "AUTO_PPPOE"){
8661 currentSelectedOperationMode = "AUTO";
8662 }else if(info.blc_wan_mode == "PPPOE"){
8663 currentSelectedOperationMode = "PPPOE";
8664 }else{
8665 currentSelectedOperationMode = info.blc_wan_mode;
8666 }
8667 target.selectedMode(currentSelectedOperationMode);
8668 });
8669
8670 // ģʽ����/�л�
8671 target.changeOpMode = function(){
8672 var userSelectedOperationMode = $('input:radio[name="opMode"]:checked').val();
8673 var messageText = "";
8674 if(userSelectedOperationMode == currentSelectedOperationMode) {
8675 hidePopupSettingWindow();
8676 return;
8677 }
8678 if(userSelectedOperationMode == "LTE_BRIDGE"){
8679 messageText = "opmode_msg3";
8680 }else{
8681 messageText = "opmode_msg2";
8682 }
8683 showConfirm(messageText, function(){
8684 showLoading();
8685 service.SetOperationMode({
8686 opMode: userSelectedOperationMode
8687 },function(info){
8688 if (info && info.result == "success") {
8689 var currentOperationMode = "";
8690 switch(userSelectedOperationMode){
8691 case "AUTO":
8692 currentOperationMode = "opmode_auto"
8693 break;
8694 case "PPP":
8695 currentOperationMode = "opmode_gateway";
8696 break;
8697 case "PPPOE":
8698 currentOperationMode = "opmode_cable";
8699 break;
8700 default:
8701 break;
8702 }
8703 $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
8704 successOverlay();
8705 } else {
8706 errorOverlay();
8707 }
8708 });
8709 });
8710
8711 }
8712
8713 }
8714
8715 function init() {
8716 var fwVm = new operationModeViewMode();
8717 ko.applyBindings(fwVm, $('#popupSettingWindow')[0]);
8718
8719 $("#opmode_form").validate({
8720 submitHandler: function(){
8721 fwVm.changeOpMode();
8722 }
8723 });
8724 }
8725
8726 return {
8727 init:init
8728 };
8729});
8730
8731define("router","underscore jquery menu set service".split(" "),
8732 function (_, $, menu, config, service) {
8733 var currentHash = '';
8734 var container = $('#container');
8735
8736 //�뿪����ʱ�����Ƿ��������޸ģ�����������ʾ
8737 checkFormContentModify = function (href) {
8738 if (config.CONTENT_MODIFIED.modified && window.location.hash != href) {
8739 if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {
8740 config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
8741 config.resetContentModifyValue();
8742 window.location.hash = href;
8743 } else {
8744 showConfirm(config.CONTENT_MODIFIED.message, {
8745 ok: function () {
8746 config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
8747 config.resetContentModifyValue();
8748 window.location.hash = href;
8749 },
8750 no: function () {
8751 var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);
8752 if (!result) {
8753 window.location.hash = href;
8754 config.resetContentModifyValue();
8755 }
8756 }
8757 });
8758 }
8759 return false;
8760 } else {
8761 return true;
8762 }
8763 };
8764
8765 //��ʱ�鿴SIM����״̬������ǰSIM��״̬��Ϊ����״̬��δ��ʾnosimcardҳ�棬����ʾnosimcardҳ��,�Ա��ⲻ�ر�webui�����²����豸�󣬲����ж�SIM��״̬������
8766 function checkSimCardStatus() {
8767 setInterval(function () {
8768 var data = service.getStatusInfo();
8769 var match = menu.findMenu();
8770 if (match.length == 0) {
8771 return false;
8772 }
8773 var requirePinHash = ["phonebook", "sms_list"];
8774 var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
8775 if (match[0].checkSIMStatus === true) {
8776 var simstatus = data.simStatus == "modem_sim_undetected"
8777 || data.simStatus == "modem_sim_destroy" || data.simStatus == "modem_waitpin"
8778 || data.simStatus == "modem_waitpuk";
8779 var netlockstatus = data.simStatus == "modem_imsi_waitnck";
8780 if (data.isLoggedIn && (
8781 ($('#div-nosimcard')[0] == undefined && simstatus)
8782 || ($('#div-network-lock')[0] == undefined && netlockstatus)
8783 || (($('#div-nosimcard')[0] != undefined || $('#div-network-lock')[0] != undefined) && data.simStatus == "modem_init_complete"))) {
8784 fixedLoadResources(match[0], data.simStatus, isRequirePin);
8785 }
8786 }
8787 }, 1000);
8788 }
8789
8790 //������¼ҳ�汳��
8791 function checkLoginPageBg() {
8792 var h = window.location.hash;
8793 if (h == '#entry' || _.indexOf(config.GUEST_HASH, h) != -1) {
8794 $("#manageContainer").attr("style", "margin-top:-36px;");
8795 } else {
8796 $("#manageContainer").attr("style", "margin-top:0px;");
8797 }
8798
8799 if (window.location.hash == '#entry') {
8800 $("#mainContainer").addClass('loginBackgroundBlue');
8801 } else {
8802 var mainContainer = $("#mainContainer");
8803 if (mainContainer.hasClass('loginBackgroundBlue')) {
8804 $("#container").css({
8805 margin: 0
8806 });
8807 mainContainer.removeClass('loginBackgroundBlue').height('auto');
8808 }
8809 }
8810 }
8811
8812 function fixedLoadResources(menuItem, simStatus, isRequirePin) {
8813 var item = {};
8814 $.extend(item, menuItem);
8815 //û��SIM��ʱ������homeҳ�治��������
8816 //���类��ʱ��homeҳ����ʾ����ҳ��
8817 if (simStatus == "modem_sim_undetected" || simStatus == "modem_sim_destroy") {
8818 if (!isRequirePin) {
8819 item.path = "sim_abnormal";
8820 }
8821 } else if (simStatus == "modem_waitpin" || simStatus == "modem_waitpuk") {
8822 item.path = "sim_abnormal";
8823 } else if (simStatus == "modem_imsi_waitnck") {
8824 item.path = "locknet";
8825 }
8826 //load tmpl and controller js
8827 loadResources(item);
8828 }
8829
8830 //���ݲ˵�����item���ض�Ӧ����Դ
8831 function loadResources(item) {
8832 var pId = item.path.replace(/\//g, '_');
8833 var $body = $('body').removeClass();
8834 if (pId != 'entry' && pId != 'main') {
8835 $body.addClass('beautiful_bg page_' + pId);
8836 } else {
8837 $body.addClass('page_' + pId);
8838 }
8839 clearTimer();
8840 hideLoading();
8841 var tmplPath = 'text!tmpl/' + item.path + '.html';
8842 //TODO: prevent first menu click cover the second menu content, need test with device
8843 require([tmplPath, item.path], function (tmpl, viewModel) {
8844 container.stop(true, true);
8845 container.hide();
8846 container.html(tmpl);
8847 viewModel.init();
8848 //support backward/forward
8849 menu.refreshMenu();
8850 $('#container').translate();
8851 menu.activeSubMenu();
8852
8853 $("form").attr("autocomplete", "off");
8854 container.fadeIn();
8855 });
8856 }
8857 //�ȶ�hash״̬, �����仯�������µ�hashƥ���˵�����,ƥ�䲻��ʱ��ת��homeҳ��, ƥ����ʱ��¼hashֵ����̬���ض�Ӧ����Դ�ļ�
8858 function hashCheck() {
8859 if (window.location.hash != currentHash) {
8860 //������½����������, ��½�û����ʷǵ�¼�û�ʱҳ�治��ת
8861 var info = service.getStatusInfo();
8862 if (window.location.hash == config.defaultRoute || _.indexOf(config.GUEST_HASH, window.location.hash) != -1) {
8863 if (info.isLoggedIn) {
8864 window.location.hash = currentHash == "" ? "#main" : currentHash;
8865 return;
8866 }
8867 }
8868
8869 var match = menu.findMenu();
8870
8871 if (match.length == 0) {
8872 window.location.hash = config.defaultRoute;
8873 } else {
8874 //��¼ʱ���鹤��ģʽ������ģʽ������������Ҫ����SIM��״̬�����¼���,����ģʽ�������治��Ҫ����SIM��״̬�����¼���
8875 if (config.RJ45_SUPPORT && window.location.hash == "#main") {
8876 if ((match[0].checkSIMStatus && checkCableMode(info.blc_wan_mode)) || (!match[0].checkSIMStatus && !checkCableMode(info.blc_wan_mode))) {
8877 window.location.reload();
8878 return;
8879 }
8880 }
8881 //TODO: �����˵�����Ӧ�����˵���һ����л�ʱ�����¼�������, ��TODO: click the same menu ʵ�ַ�ʽ����
8882 var oldMenu = menu.findMenu(currentHash);
8883 currentHash = match[0].hash;
8884 if (currentHash == "#entry") {
8885 $('#indexContainer').addClass('login-page-bg');
8886 menu.rebuild();
8887 } else {
8888 $('#indexContainer').removeClass('login-page-bg');
8889 }
8890
8891 if (oldMenu.length != 0 && match[0].path == oldMenu[0].path && match[0].level != oldMenu[0].level && match[0].level != '1' && oldMenu[0].level != '1') {
8892 return;
8893 }
8894
8895 checkLoginPageBg();
8896 var requirePinHash = ["phonebook", "sms_list"];
8897 var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
8898 if (match[0].checkSIMStatus === true || isRequirePin) {
8899 //simStatus is undefined when refreshing page
8900 if (info.simStatus == undefined) {
8901 showLoading('waiting');
8902 function checkSIM() {
8903 var data = service.getStatusInfo();
8904 if (data.simStatus == undefined || $.inArray(data.simStatus, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8905 addTimeout(checkSIM, 500);
8906 } else {
8907 fixedLoadResources(match[0], data.simStatus, isRequirePin);
8908 hideLoading();
8909 }
8910 }
8911 checkSIM();
8912 } else {
8913 fixedLoadResources(match[0], info.simStatus, isRequirePin);
8914 }
8915 } else {
8916 loadResources(match[0]);
8917 }
8918 }
8919 }
8920 }
8921
8922 //Ĭ������ҳ��Ϊ#main, ��ʱ����hash״̬
8923 function init() {
8924 checkSimCardStatus();
8925 window.location.hash = window.location.hash || "#main";
8926 //if support onhashchange then use. If ie8 in ie7 mode, it doesn't trigger onhashchange.
8927 if (('onhashchange' in window) && ((typeof document.documentMode === 'undefined') || document.documentMode == 8)) {
8928 window.onhashchange = hashCheck;
8929 hashCheck();
8930 } else {
8931 setInterval(hashCheck, 200);
8932 }
8933
8934 //�����޸���ҳ������, �뿪ʱ������ʾ
8935 $("a[href^='#']").die('click').live('click', function () {
8936 var $this = $(this);
8937 config.CONTENT_MODIFIED.checkChangMethod();
8938 return checkFormContentModify($this.attr('href'));
8939 });
8940 }
8941
8942 return {
8943 init: init
8944 };
8945});
8946
8947// statusBar �
8948
8949define("statusBar", "knockout jquery underscore service set menu tooltip".split(" "),
8950
8951 function (ko, $, _, service, config, menu, tooltip) {
8952
8953 var sv__hasCheckedSMSCapacity = false;
8954 var sv__initSMSCompleted = false;
8955 var sv_newSMSMessageInDealing = false;
8956 var sv_fotaUpdateCancel = null;
8957 var sv_batteryCheckTimer = 0;
8958 var sv_dbMessageIds = [];
8959 var sv_fotaResultAlertPopuped = false;
8960 var sv_isFirstLoadNewMessage = true;
8961 var isLoggedIn = true;
8962 var sv_messagePopStack = {};
8963 var sv_newMessagePopTemplate = null;
8964 var sv_resetTrafficAlertPopuped = false;
8965 var sv_simMessageListTemplate = null;
8966 var sv_smsListTemplate = null;
8967 var sv_trafficAlertPopuped_100 = false;
8968 var sv_trafficAlertPopuped = false;
8969 var sv_timer = 0;
8970
8971 // ��ȡ״̬��Ϣ�������硢SIM��WIFI��
8972 var getCurrentStatusInfo = function () {
8973 return service.getStatusInfo();
8974 };
8975
8976 function statusViewModel() {
8977 var target = this;
8978 var info = getCurrentStatusInfo();
8979 var roamStatus = info.roamingStatus ? true : false;
8980 var $langLogoBar = $("#langLogoBar");
8981
8982
8983 // �������������¼�����
8984 function sf_connect() {
8985 showLoading("connecting");
8986 service.connect({}, function (data) {
8987 if (data.result) {
8988 refreshWifiConnectStatus(target, data.status);
8989 }
8990 successOverlay();
8991 }, function (data) {
8992 errorOverlay();
8993 });
8994 }
8995 // �Ͽ������¼�����
8996 function sf_disconnect() {
8997 showLoading("disconnecting");
8998 service.disconnect({}, function (data) {
8999 if (data.result) {
9000 refreshWifiConnectStatus(target, data.status);
9001 }
9002 successOverlay();
9003 }, function (data) {
9004 errorOverlay();
9005 });
9006 }
9007
9008 if(info.isLoggedIn){
9009 if(!$langLogoBar.hasClass("langborderBg")){
9010 $langLogoBar.addClass("langborderBg");
9011 }
9012 $("#statusBar:hidden").show();
9013 } else {
9014 if($langLogoBar.hasClass("langborderBg")){
9015 $langLogoBar.removeClass("langborderBg");
9016 }
9017 $("#statusBar:visible").hide();
9018 }
9019
9020
9021 //target.attachedDevices = ko.observable(info.attachedDevices);
9022 target.batteryLevel = ko.observable(info.batteryLevel + '%');
9023 target.batteryPers = ko.observable(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
9024 target.batteryStatus = ko.observable(info.batteryStatus);
9025 target.connectionCssClass = ko.observable("");
9026 target.connectStatus = ko.observable(info.connectStatus);
9027 target.connectStatusText = ko.observable();
9028 target.connectStatusTrans = ko.observable();
9029 target.hasWifi = ko.observable(config.HAS_WIFI);
9030 target.hasBattery = ko.observable(config.HAS_BATTERY);
9031 target.isLoggedIn = ko.observable(info.isLoggedIn);
9032 target.isShowConnectionIcon = ko.observable(false);
9033 target.isShowFotaNewversionIcon = ko.observable(info.new_version_state && info.fota_package_already_download != "yes" && !config.isShowFotaIcon);
9034 target.isShowRj45ConnectionIcon = ko.observable(false);
9035 target.networkOperator = ko.observable(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,roamStatus));
9036 target.networkType = ko.observable(getNetworkType(info.networkType));
9037 target.pinStatus = ko.observable(info.pinStatus);
9038 target.pinStatusText = ko.observable();
9039 target.rj45ConnectionCssClass = ko.observable("");
9040 target.roamingStatus = ko.observable(info.roamingStatus ? "R" : "");
9041 target.showAttachedDevices = ko.observable(info.wifiStatus);
9042 target.showSmsDeleteConfirm = ko.observable(false);
9043 target.smsUnreadCount = ko.observable(0);
9044 target.simStatus = ko.observable(sf_convertSimStatusToImage(info.simStatus));
9045 target.signalCssClass = ko.observable(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
9046 target.updateType = ko.observable(service.getUpdateType().update_type);
9047 target.wifiStatusCssClass = ko.observable(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
9048 target.wifiStatusImg = ko.observable(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
9049
9050 sf_getConnectionCssClass(target, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
9051
9052 target.connect = sf_connect;
9053 target.disconnect = sf_disconnect;
9054 }
9055
9056 function sf_gotoSmsList(){
9057 var s_href = '#msg_main';
9058 if(window.location.hash == '#msg_main'){
9059 s_href = '#msg_list';
9060 }
9061 config.CONTENT_MODIFIED.checkChangMethod();
9062 if(checkFormContentModify(s_href)){
9063 window.location.hash = s_href;
9064 }
9065 }
9066
9067 gotoSmsList = sf_gotoSmsList;
9068
9069 function sf_getNetWorkProvider(i_spnB1Flag, i_spnNameData, i_spnB2Flag, i_networkProvider, i_roamStatus) {
9070 if (i_spnNameData == "") {
9071 return i_networkProvider;
9072 } else {
9073 i_spnNameData = decodeMessage(i_spnNameData);
9074 if (i_spnB1Flag == "0" && i_spnB2Flag == "0") {
9075 if (i_roamStatus) {//����
9076 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9077 } else {//������
9078 return i_spnNameData;
9079 }
9080 }else if (i_spnB1Flag == "1" && i_spnB2Flag == "1") {
9081 if (i_roamStatus) {//����
9082 return i_networkProvider;
9083 } else {//������
9084 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9085 }
9086 } else if (i_spnB1Flag == "1") {
9087 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9088 } else if (i_spnB2Flag == "1") {
9089 if (i_roamStatus) {//����
9090 return i_networkProvider;
9091 } else {//������
9092 return i_spnNameData;
9093 }
9094 }
9095 return "";
9096 }
9097 }
9098
9099 // �����¶���Ϣ��ʾ����������������
9100 function sf_addNewMessage(i_message, i_isUpdate, i_type){
9101 config.smsMaxId = i_message.id;
9102 var now = $.now();
9103 sv_messagePopStack["m" + now] = now;
9104 var name = i_message.number;
9105 if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
9106 sv_isFirstLoadNewMessage = false;
9107 if(config.HAS_PHONEBOOK){
9108 sf_getPhoneBooks();
9109 }else{
9110 config.phonebook = [];
9111 }
9112 }
9113 for(i in config.phonebook){
9114 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9115 name = config.phonebook[i].pbm_name;
9116 break;
9117 }
9118 }
9119 var s_newMsg = {
9120 mark : "m" + now,
9121 name: name,
9122 title: $.i18n.prop("sms"),
9123 titleTrans: "sms",
9124 tag: i_message.tag,
9125 content : i_message.content,
9126 datetime : i_message.time
9127 };
9128 if(sv_newMessagePopTemplate == null){
9129 sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
9130 }
9131 $(".bubbleItem:not(.report)", "#buttom-bubble").remove();
9132 $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
9133 if((window.location.hash == "#msg_main" || window.location.hash == "#msg_list") && i_type == "1"){
9134 //sf_dealChosenNumber(s_newMsg.name, i_message.number);
9135 var s_inChating = config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
9136 var s_itemId = getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
9137 var item = $("#smslist-item-" + s_itemId);
9138 if(item && item.length > 0){
9139 // �Ѵ������ݣ��������ݵ���˳��
9140 for(var i = 0; config.listMsgs && i < config.listMsgs.length; i++){
9141 if(getLastNumber(config.listMsgs[i].number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9142 config.listMsgs[i].id = i_message.id;
9143 config.listMsgs[i].latestId = i_message.id;
9144 config.listMsgs[i].latestSms = i_message.content;
9145 config.listMsgs[i].latestTime = i_message.time;
9146 if(!i_isUpdate){
9147 config.listMsgs[i].newCount++;
9148 config.listMsgs[i].totalCount++;
9149 }
9150 break;
9151 }
9152 }
9153 item.find(".smslist-item-checkbox p.checkbox").attr("id", i_message.id);
9154 item.find(".smslist-item-checkbox input:checkbox").val(i_message.id).attr("id", "checkbox" + i_message.id);
9155 if(!i_isUpdate){
9156 var s_itemCount = item.find(".smslist-item-total-count").text();
9157 s_itemCount = Number(s_itemCount.substring(1, s_itemCount.length - 1));
9158 item.find(".smslist-item-total-count").text("(" + (s_itemCount + 1) + ")");
9159 if(!config.currentChatObject || config.currentChatObject != getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9160 var s_newNum = item.find(".smslist-item-new-count").removeClass("hide");
9161 if(s_newNum && s_newNum.text().length > 0){
9162 s_newNum.text(Number(s_newNum.text()) + 1);
9163 }else{
9164 s_newNum.text(1);
9165 }
9166 }
9167 }
9168 if(item.find(".smslist-item-draft-flag").length > 0){
9169 if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
9170 item.find(" td:nth-child(2)").removeClass("font-weight-bold");
9171 } else {
9172 item.find(" td:nth-child(2)").addClass("font-weight-bold");
9173 }
9174 }else{
9175 var msgContent = item.find(".smslist-item-msg").text(i_message.content);
9176 msgContent.closest('td').prop('title', i_message.content);
9177 item.find("span.clock-time").text(i_message.time);
9178 if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
9179 msgContent.closest('tr').removeClass("font-weight-bold");
9180 } else {
9181 msgContent.closest('tr').addClass("font-weight-bold");
9182 }
9183 }
9184 item.find(".smslist-item-repeat span").die().click(function() {
9185 forwardClickHandler(i_message.id);
9186 });
9187
9188 var s_tmpItem = item;
9189 item.hide().remove();
9190 $("#smslist-table").prepend(s_tmpItem.show());
9191 } else {
9192 // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
9193 var s_theName = "";
9194 if(config.phonebook && config.phonebook.length > 0) {
9195 for(i in config.phonebook){
9196 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9197 s_theName = config.phonebook[i].pbm_name;
9198 break;
9199 }
9200 }
9201 }
9202 var s_theNewMessage = {
9203 id : i_message.id,
9204 name : s_theName,
9205 number : i_message.number,
9206 latestId :i_message.id,
9207 totalCount : 1,
9208 newCount : s_inChating ? 0 : 1,
9209 latestSms : i_message.content,
9210 latestTime : i_message.time,
9211 checked : false,
9212 hasDraft : false,
9213 itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
9214 };
9215 if(sv_smsListTemplate == null){
9216 sv_smsListTemplate = $.template("smsTableTmpl", $("#smsTableTmpl"));
9217 }
9218 $.tmpl("smsTableTmpl", {data: [s_theNewMessage]}).prependTo("#smslist-table");
9219 }
9220 if(config.HAS_PHONEBOOK){
9221 $(".sms-add-contact-icon").removeClass("hide");
9222 }else{
9223 $(".sms-add-contact-icon").addClass("hide");
9224 }
9225 if(s_inChating){
9226 var talkItem = $("#talk-item-" + i_message.id, "#chatlist");
9227 if (talkItem && talkItem.length > 0) {// ���¼�����������
9228 $(".J_content pre", talkItem).html(dealContent(i_message.content));
9229 $(".time .smslist-item-time", talkItem).text(i_message.time);
9230 $(".smslist-item-repeat", talkItem).die().click(
9231 function() {
9232 forwardClickHandler(i_message.id);
9233 });
9234 $(".smslist-item-delete", talkItem).die().click(
9235 function() {
9236 deleteSingleItemClickHandler(i_message.id);
9237 });
9238 } else {// �����µĻظ�����
9239 $("#smsOtherTmpl").tmpl(i_message).appendTo("#chatlist");
9240 $(".clear-container", "#chatpanel").animate({
9241 scrollTop : $("#chatlist").height()
9242 });
9243 }
9244 if (!config.SMS_SET_READ_WHEN_COMPLETE) {
9245 service.setSmsRead({ids: [i_message.id]}, $.noop);
9246 } else if (config.SMS_SET_READ_WHEN_COMPLETE && i_message.receivedAll) {
9247 service.setSmsRead({ids: [i_message.id]}, $.noop);
9248 }
9249 }
9250 enableCheckbox($("#smslist-checkAll"));
9251 }
9252 if(window.location.hash == "#msg_sim" && i_type == "0"){
9253 // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
9254 var s_theName = "";
9255 if(config.phonebook && config.phonebook.length > 0) {
9256 for(i in config.phonebook){
9257 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9258 s_theName = config.phonebook[i].pbm_name;
9259 break;
9260 }
9261 }
9262 }
9263 var s_theNewMessage = {
9264 id : i_message.id,
9265 name : s_theName,
9266 number : i_message.number,
9267 content : i_message.content,
9268 time : i_message.time,
9269 tag: i_message.tag,
9270 checked : false,
9271 itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
9272 };
9273 if(i_isUpdate){
9274 var s_item = $(".simMsgList-item-class-" + s_theNewMessage.id);
9275 s_item.hide().remove();
9276 }
9277 if(sv_simMessageListTemplate == null){
9278 sv_simMessageListTemplate = $.template("ssimMessageListTemplate", $("#simMessageListTemplate"));
9279 }
9280 $.tmpl("simMessageListTemplate", {data: [s_theNewMessage]}).prependTo("#simMsgList_container");
9281 }
9282 }
9283
9284 function sf_checkBatteryStatusForFota(){
9285 var s_state = service.getCurrentUpgradeState();
9286 if(s_state.current_upgrade_state == 'low_battery'){
9287 showInfo('ota_low_battery');
9288 clearInterval(sv_batteryCheckTimer);
9289 }
9290 }
9291
9292 // ��SIM��״̬ת��Ϊ��Ӧ����������
9293 function sf_convertSimStatusToImage(i_status) {
9294 var s_image;
9295 switch (i_status) {
9296 case "modem_destroy":
9297 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
9298 break;
9299 case "modem_imsi_waitnck":
9300 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitnck");
9301 break;
9302 case "modem_init_complete":
9303 s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
9304 break;
9305 case "modem_sim_destroy":
9306 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
9307 break;
9308 case "modem_sim_undetected":
9309 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_undetected");
9310 break;
9311 case "modem_undetected":
9312 s_image = "./pic/simcard_undetected.png";
9313 break;
9314 case "modem_waitpin":
9315 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpin");
9316 break;
9317 case "modem_waitpuk":
9318 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpuk");
9319 break;
9320
9321 default:
9322 s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
9323 break;
9324 }
9325 return s_image;
9326 }
9327
9328 function sf_dealChosenNumber(i_choosenName, i_choosenNum) {
9329 setTimeout(function () {
9330 var s_choosen = $("#chosenUserSelect");
9331 var s_options = $("option", s_choosen);
9332 for (var index = 0; index < s_options.length; index++) {
9333 if (getLastNumber(i_choosenNum, config.SMS_MATCH_LENGTH) == s_options[index].value) {
9334
9335 s_options[index].text = i_choosenName + '/' + i_choosenNum;
9336 s_options[index].value = i_choosenNum;
9337
9338 break;
9339 }
9340 }
9341 s_choosen.trigger("liszt:updated");
9342 }, 0);
9343 }
9344
9345 // ˫�첽��ȡ�豸����sim�����ö���Ϣ���������ϲ�
9346 function sf_dealPhoneBooksResult(i_books){
9347 if($.isArray(i_books.pbm_data) && i_books.pbm_data.length > 0){
9348 config.phonebook = i_books.pbm_data;
9349 }
9350 }
9351
9352 // �������µ�5������Ϣ����δ���ӵ������б��еĵ�����ʾ
9353 function sf_filterNewMessage(i_messages, i_type){
9354 if(!config.dbMsgs){
9355 config.dbMsgs = [];
9356 }
9357 if(sv_dbMessageIds.length == 0){
9358 $.each(config.dbMsgs, function(index_1, i_element){
9359 sv_dbMessageIds.push(i_element.id);
9360 });
9361 }
9362 $.each(i_messages, function(index_2, i_element){
9363 if($.inArray(i_element.id, sv_dbMessageIds) == -1){//�����¶���
9364 sv_dbMessageIds.push(i_element.id);
9365 config.dbMsgs.push(i_element);
9366 if(i_element.tag == '1'){
9367 sf_addNewMessage(i_element, false, i_type);
9368 }
9369 }else{
9370 for(var index = 0; index < config.dbMsgs.length; index++){//���¼�������
9371 if(config.dbMsgs[index].id == i_element.id && config.dbMsgs[index].content != i_element.content && i_element.tag == '1'){
9372 config.dbMsgs[index].content = i_element.content;
9373 sf_addNewMessage(i_element, true, i_type);
9374 break;
9375 }
9376 }
9377 }
9378 });
9379 }
9380
9381 // ������ת��Ϊ��ӦͼƬ
9382 function sf_getBatteryLevelImage(pers, i_status) {
9383 var s_Image = null;
9384 if ("0" == i_status) {
9385 if ("1" == pers) {
9386 s_Image = "pic/power_one.png";
9387 } else if ("2" == pers) {
9388 s_Image = "pic/power_two.png";
9389 } else if ("3" == pers) {
9390 s_Image = "pic/power_three.png";
9391 } else if ("4" == pers) {
9392 s_Image = "pic/power_full.png";
9393 } else { //"5" == pers || "0" == pers
9394 s_Image = "pic/power_out.png";
9395 }
9396 } else {
9397 s_Image = "pic/power_charging.gif";
9398 }
9399 return s_Image;
9400 }
9401
9402 // ��ȡ����״̬��CSS��ʽ
9403 function sf_getConnectionCssClass(i_fwVm, i_status, i_data_counter, i_wifiSSID, i_wifiStatus, i_rj45Status) {
9404
9405 var s_rj45ConnectionStatus = "icon_connection ";
9406 var s_connectionStatus = "icon_connection ";
9407
9408 if(i_rj45Status == "connect"){
9409 s_rj45ConnectionStatus += "connecting";
9410 }else if(i_rj45Status == "working"){
9411 s_rj45ConnectionStatus += "rj45_connected";
9412 }else{
9413 s_rj45ConnectionStatus += "disconnect";
9414 }
9415
9416 if (i_status == "ppp_connecting" || i_status == "wifi_connecting") {
9417 s_connectionStatus += "connecting";
9418 } else if(i_status == "ppp_connected") {//CPE ppp_statusΪnone ready��ֵ
9419 if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate != '0') {
9420 s_connectionStatus += "connectionBoth";
9421 } else if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate == '0') {
9422 s_connectionStatus += "connectionUp";
9423 } else if (i_data_counter.uploadRate == '0' && i_data_counter.downloadRate != '0') {
9424 s_connectionStatus += "connectionDown";
9425 } else {
9426 s_connectionStatus += "connectionNone";
9427 }
9428 } else if (i_status == "ppp_disconnected") {
9429 if (i_wifiSSID && i_wifiStatus == "connect") {
9430 service.getHotspotList({}, function (data) {
9431 var s_cssName = "icon_connection ";
9432 var s_css = "connecting ";
9433 for (var i = 0, len = data.hotspotList.length; i < len; i++) {
9434 if (data.hotspotList[i].connectStatus == "1") {
9435 s_css = "wifi_connected";
9436 break;
9437 }
9438 }
9439 s_cssName += s_css;
9440 i_fwVm.connectionCssClass(s_cssName);
9441 });
9442 i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
9443 return;
9444 } else if (i_wifiSSID && (i_wifiStatus == "connecting" || i_wifiStatus =="dhcping")) {
9445 s_connectionStatus += "connecting";
9446 } else {
9447 s_connectionStatus += "disconnect";
9448 }
9449 } else {
9450 s_connectionStatus += "disconnect";
9451 }
9452
9453 i_fwVm.connectionCssClass(s_connectionStatus);
9454 i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
9455 }
9456
9457 // ��ȡ�绰����Ϣ
9458 function sf_getPhoneBooks() {
9459 var s_books = service.getPhoneBooks({
9460 page : 0,
9461 data_per_page : 2000,
9462 orderBy : "id",
9463 isAsc : false
9464 });
9465 sf_dealPhoneBooksResult(s_books);
9466 }
9467
9468 // ��ȡ�ź�����CSS��ʽ
9469 function sf_getSignalCssClass(siganl, networkType, simStatus) {
9470 networkType = networkType.toLowerCase();
9471 simStatus = simStatus ? simStatus.toLowerCase() : '';
9472 if(networkType == '' || networkType == 'limited_service' || networkType == 'no_service' || networkType == 'limited service' || networkType == 'no service'
9473 || simStatus != 'modem_init_complete'){
9474 siganl = '_none';
9475 }
9476 return "signal signal" + siganl;
9477 }
9478
9479 function sf_getWifiStatusCssClass(i_status, i_deviceSize) {
9480 if (i_status) {
9481 if (i_deviceSize == 0) {
9482 return "wifi_status0";
9483 } else {
9484 return "wifi_status" + i_deviceSize;
9485 }
9486 } else {
9487 return "wifi_status_off";
9488 }
9489 }
9490
9491 // ����wifi״̬��ȡwifi��ͼƬ��Դ
9492 function sf_getWifiStatusImage(i_status, i_deviceSize) {
9493 if (i_status) {
9494 if (i_deviceSize == 0) {
9495 return "./pic/wlan0.png";
9496 } else {
9497 return "./pic/wlan" + i_deviceSize + ".png";
9498 }
9499 } else {
9500 return "./pic/wlan_off.png";
9501 }
9502 }
9503
9504 // ��ȡ��������������С���������ؽ���
9505 function sf_refreshFotaDownloadProgress(){
9506 service.getPackSizeInfo({}, function (data) {
9507 var percents;
9508 if (parseInt(data.fota_pkg_total_size) == 0) {
9509 percents = 0;
9510 } else {
9511 percents = parseInt(parseInt(data.fota_dl_pkg_size) * 100 / parseInt(data.fota_pkg_total_size));
9512 }
9513 if (percents > 100) {
9514 percents = 100;
9515 }
9516 if (percents >= 0) {
9517 if (percents > 95) {
9518 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
9519 }
9520 setProgressBar(percents);
9521 }
9522 });
9523 }
9524
9525 // �������ŷ��ͱ���
9526 function sf_responseSmsReport(){
9527 if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
9528
9529 sv_isFirstLoadNewMessage = false;
9530
9531 if(config.HAS_PHONEBOOK){
9532 sf_getPhoneBooks();
9533 }else{
9534 config.phonebook = [];
9535 }
9536 }
9537 service.getSMSDeliveryReport({
9538 page: 0,
9539 smsCount: 10
9540 }, function(data){
9541 var s_messages = data.messages;
9542 var s_nums = [];
9543 $.each(s_messages, function(i, i_message){
9544 if($.inArray(i_message.number, s_nums) == -1){
9545 s_nums.push(i_message.number);
9546 window.setTimeout(function(){
9547 var s_now = $.now();
9548 sv_messagePopStack["m" + s_now] = s_now;
9549 i_message.name = i_message.number;
9550 for(i in config.phonebook){
9551 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9552 i_message.name = config.phonebook[i].pbm_name;
9553 break;
9554 }
9555 }
9556 var s_msgContent = $.i18n.prop("sms_delivery_report_" + i_message.content);
9557
9558 var s_newMsg = {
9559 mark : "m" + s_now,
9560 name: i_message.name,
9561 title: $.i18n.prop("sms_report"),
9562 titleTrans: "sms_report",
9563 content : s_msgContent,
9564 datetime : i_message.time,
9565 report : 'report'
9566 };
9567
9568 if(sv_newMessagePopTemplate == null){
9569 sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
9570 }
9571
9572 $(".report", "#buttom-bubble").remove();
9573 $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
9574 }, 100);
9575 }
9576 });
9577 }, function(){
9578 //No Deal
9579 });
9580 }
9581
9582 function sf_simStatusInvalid(simStatus){
9583 return simStatus == 'modem_sim_undetected' || simStatus == 'modem_undetected' || simStatus == 'modem_sim_destroy'
9584 || simStatus == 'modem_waitpin' || simStatus == 'modem_waitpuk' || simStatus == 'modem_imsi_waitnck';
9585 }
9586
9587 // ��ʾFOTA������ǰ״̬
9588 function sf_showFotaCurrentStatus() {
9589 sv_fotaUpdateCancel = true;
9590 var r = service.getNewVersionState();
9591
9592 function showProgress() {
9593 var upgradingState = ["downloading"];
9594 var info = service.getCurrentUpgradeState();
9595 if(info.current_upgrade_state.toLowerCase() == "idle") {
9596 addTimeout(showProgress, 1000);
9597 } else if(($.inArray(info.current_upgrade_state, upgradingState) != -1)&&(r.fota_new_version_state != "already_has_pkg")) {
9598 hideLoading();
9599 sf_showFotaUpgradeStatus();
9600 }
9601 }
9602 if (!($("#progress").is(":visible"))) {
9603 showProgress();
9604 }
9605 var times = 0;
9606 var getOTAUpgradeState = function () {
9607 var data = null;
9608 if (times <= 3) {
9609 times = times + 1;
9610 data = service.getCurrentUpgradeState();
9611 } else {
9612 data = getCurrentStatusInfo();
9613 }
9614 var state = data.current_upgrade_state;
9615 if(sv_fotaUpdateCancel && isLoggedIn == true){
9616
9617 if(r.fota_new_version_state == "already_has_pkg"){
9618 if(state == 'low_battery'){
9619 hideProgressBar();
9620 sv_fotaUpdateCancel = false;
9621 service.removeTimerThings('fota_current_upgrade_state',function(){});
9622 showInfo('ota_pkg_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_pkg_download_success');
9630 window.clearTimeout(sv_timer);
9631 sv_batteryCheckTimer = setInterval(function () {
9632 sf_checkBatteryStatusForFota();
9633 }, 1000);
9634 return;
9635 }
9636 }else if(state == 'downloading') {
9637 sf_refreshFotaDownloadProgress();
9638 }else if(state == 'download_failed') {
9639 hideProgressBar();
9640 sv_fotaUpdateCancel = false;
9641 showAlert('ota_download_failed');
9642 window.clearTimeout(sv_timer);
9643 return;
9644 }else if(state == 'low_battery'){
9645 hideProgressBar();
9646 sv_fotaUpdateCancel = false;
9647 service.removeTimerThings('fota_current_upgrade_state',function(){});
9648 showInfo('ota_low_battery');
9649 window.clearTimeout(sv_timer);
9650 return;
9651 }else if(state == 'prepare_install'){
9652 hideProgressBar();
9653 sv_fotaUpdateCancel = false;
9654 service.removeTimerThings('fota_current_upgrade_state',function(){});
9655 showInfo('ota_download_success');
9656 window.clearTimeout(sv_timer);
9657 sv_batteryCheckTimer = setInterval(function () {
9658 sf_checkBatteryStatusForFota();
9659 }, 1000);
9660 return;
9661 }else{
9662 sv_fotaUpdateCancel = false;
9663 hideProgressBar();
9664 window.clearTimeout(sv_timer);
9665 return;
9666 }
9667 sv_timer = window.setTimeout(getOTAUpgradeState , 1000);
9668 }
9669 };
9670
9671 if(sv_fotaUpdateCancel && isLoggedIn == true){
9672 sv_timer = window.setTimeout(getOTAUpgradeState , 100);
9673 }else{
9674 window.clearTimeout(sv_timer);
9675 }
9676 }
9677
9678 // ��ʾFota��������
9679 function sf_showFotaUpdateResult(i_otaResult) {
9680 if ((!($("#loading").is(":visible"))) && (!($("#confirm").is(":visible")))) {
9681 var s_message = i_otaResult ? "ota_update_success" : "ota_update_failed";
9682 sv_fotaResultAlertPopuped = true;
9683 showAlert(s_message, function () {
9684 sv_fotaResultAlertPopuped = false;
9685 if (config.UPGRADE_TYPE == "OTA") {
9686 service.clearUpdateResult({}, $.noop());
9687 }
9688 });
9689 } else {
9690 window.setTimeout(function () {
9691 sf_showFotaUpdateResult(i_otaResult)
9692 }, 1000);
9693 }
9694 }
9695
9696 // ��ʾ��ǰ����״̬
9697 function sf_showFotaUpgradeStatus() {
9698 var s_data = service.getMandatory();
9699 var s_isMandatory = s_data.is_mandatory;
9700 var s_sizeInfo =service.getPackSizeInfo();
9701 var s_percents;
9702
9703 if (parseInt(s_sizeInfo.fota_pkg_total_size) == 0) {
9704 s_percents = 0;
9705 } else {
9706 s_percents = parseInt(parseInt(s_sizeInfo.fota_dl_pkg_size) * 100 / parseInt(s_sizeInfo.fota_pkg_total_size));
9707 }
9708 if (s_percents > 100) {
9709 s_percents = 100;
9710 }
9711
9712 if (s_isMandatory) {
9713 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
9714 } else {
9715 var cancelHtml = "";
9716 if (config.UPGRADE_TYPE == "OTA") {
9717 cancelHtml = "<br/><br/><button id='btnStopUpgrade' onclick='stopOTAUpgrade();' class='btn-1 btn-primary'>" + $.i18n.prop("cancel") + "</button>";
9718 }
9719 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning") + cancelHtml);
9720 }
9721
9722 //setProgressBar(0);
9723 if (s_percents >= 0) {
9724 setProgressBar(s_percents);
9725 }
9726 }
9727
9728
9729
9730
9731
9732 function sf_startFotaUpgrade(){
9733 service.setUpgradeSelectOp({selectOp:'1'},function(result){
9734 if (result.result == "success"){
9735 sf_showFotaCurrentStatus();
9736 }});
9737 }
9738
9739 function cancelFotaUpgrade(){
9740 service.setUpgradeSelectOp({selectOp:'0'},function(result){ });
9741 }
9742
9743
9744 function refreshFotaStatusForUserSelector(choice){
9745 var info = getCurrentStatusInfo();
9746 if(choice){
9747 var modeData = service.getOpMode();
9748 if (!checkConnectedStatus(info.connectStatus, modeData.rj45_state, info.connectWifiStatus)) {
9749 showAlert("ota_network_disconnected");
9750 return;
9751 }
9752
9753 if(info.fota_user_selector == 'none'){
9754 sf_startFotaUpgrade();
9755 }else if(info.fota_user_selector == 'accept'){
9756 sf_showFotaCurrentStatus();
9757 }else if(info.fota_user_selector == 'cancel'){
9758 showAlert("ota_have_cancel");
9759 }else if(info.fota_user_selector == 'downloading_cancel'){
9760 showAlert("ota_have_cancel");
9761 }
9762 }else{
9763 if(info.fota_user_selector == 'none'){
9764 cancelFotaUpgrade();
9765 }else if(info.fota_user_selector == 'accept'){
9766 sf_showFotaCurrentStatus();
9767 }else if(info.fota_user_selector == 'cancel'){
9768 // todo:
9769 }else if(info.fota_user_selector == 'downloading_cancel'){
9770 // todo:
9771 }
9772 }
9773 }
9774
9775
9776 // ��ʾ���°汾�������ж��Ƿ�������ʾ
9777 function showFotaStatusForUserToConfirm(upgradeState) {
9778 var upgState = upgradeState.current_upgrade_state;
9779 if (upgState == 'upgrade_pack_redownload') {
9780 showConfirm("ota_interrupted", {ok: function () {
9781 refreshFotaStatusForUserSelector(1);
9782 }, no: function () {
9783 refreshFotaStatusForUserSelector(0);
9784 }});
9785 } else {
9786 var upgradingState = ["prepare_install", "low_battery",
9787 "connecting_server", "connect_server_success", "downloading", "accept"];
9788 if ($.inArray(upgState, upgradingState) != -1) {
9789 sf_showFotaCurrentStatus();
9790 } else {
9791
9792 showConfirm($.i18n.prop('ota_new_version'), {ok: function () {
9793 refreshFotaStatusForUserSelector(1);
9794 config.ISNOW_NOTICE = false;
9795 }, no: function () {
9796 refreshFotaStatusForUserSelector(0);
9797 config.ISNOW_NOTICE = false;
9798 }});
9799 }
9800 }
9801 }
9802
9803 showOTAAlert = function () {
9804 config.ISNOW_NOTICE = true;
9805 var is_mandatory = service.getMandatory().is_mandatory;
9806 if (is_mandatory) {
9807 sf_showFotaCurrentStatus();
9808 } else {
9809 var upgradeState = {};
9810 upgradeState = service.getCurrentUpgradeState();
9811 showFotaStatusForUserToConfirm(upgradeState);
9812 }
9813 };
9814
9815 // ��ֹFota����
9816 stopOTAUpgrade = function () {
9817 service.setUpgradeSelectOp({selectOp:'2'},function(result){ });
9818 sv_fotaUpdateCancel = false;
9819 window.clearTimeout(sv_timer);
9820 hideLoading();
9821 showAlert('ota_cancel');
9822 };
9823
9824 // �������������Ƿ����ѹ�
9825 function setTrafficAlertPopuped(val){
9826 sv_trafficAlertPopuped = !!val;
9827 sv_trafficAlertPopuped_100 = !!val;
9828 if(!val){
9829 sv_resetTrafficAlertPopuped = true;
9830 }
9831 }
9832
9833 function setTrafficAlert100Popuped(val){
9834 sv_trafficAlertPopuped_100 = !!val;
9835 if(!val){
9836 sv_resetTrafficAlertPopuped = true;
9837 }
9838 }
9839
9840 // ���������ṹ
9841 function getTrafficResult(info){
9842 var s_trafficResult = {
9843 showConfirm : false,
9844 limitPercent : info.limitVolumePercent
9845 };
9846 if(info.limitVolumeType == '1'){
9847 var monthlyTraffic = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
9848 s_trafficResult.usedPercent = monthlyTraffic / info.limitVolumeSize * 100;
9849 if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
9850 s_trafficResult.showConfirm = true;
9851 s_trafficResult.type = 'data';
9852 }
9853 }else{
9854 s_trafficResult.usedPercent = info.data_counter.monthlyConnectedTime / info.limitVolumeSize * 100;
9855 if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
9856 s_trafficResult.showConfirm = true;
9857 s_trafficResult.type = 'time';
9858 }
9859 }
9860 return s_trafficResult;
9861 }
9862
9863 // ��ʼ�� ViewModel����������ͼ����
9864 function init() {
9865 if(config.PRODUCT_TYPE == 'DATACARD') {
9866 $('#statusBar').addClass('padding-right-90');
9867 $('#language').addClass('data-card-language');
9868 }
9869 //preload img
9870 var imgAlert = $('<img />').attr('src', 'pic/res_alert.png');
9871 var imgConfirm = $('<img />').attr('src', 'pic/res_confirm.png');
9872 var imgInfo = $('<img />').attr('src', 'pic/res_info.png');
9873
9874 window.setTimeout(function () {
9875
9876 var fwVm = new statusViewModel();
9877
9878 ko.applyBindings(fwVm, $('#statusBar')[0]);
9879
9880 window.setInterval(function () {
9881 var info = getCurrentStatusInfo();
9882 var s_roamStatus = info.roamingStatus ? true : false;
9883 var $langLogoBar = $("#langLogoBar");
9884 isLoggedIn = info.isLoggedIn;
9885
9886
9887 //fwVm.attachedDevices(info.attachedDevices);
9888 fwVm.batteryLevel(info.batteryLevel + '%');
9889 fwVm.batteryPers(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
9890 fwVm.batteryStatus(info.batteryStatus);
9891 fwVm.isShowFotaNewversionIcon(info.new_version_state && info.fota_user_selector && info.fota_package_already_download != "yes" && config.ISNOW_NOTICE && fwVm.updateType() == 'mifi_fota');
9892 fwVm.isShowRj45ConnectionIcon(config.RJ45_SUPPORT);
9893 fwVm.networkOperator(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,s_roamStatus));
9894 fwVm.networkType(getNetworkType(info.networkType));
9895 fwVm.pinStatus(info.pinStatus);
9896 fwVm.roamingStatus(info.roamingStatus ? "R" : "");
9897 fwVm.showAttachedDevices(info.wifiStatus);
9898 fwVm.simStatus(sf_convertSimStatusToImage(info.simStatus));
9899 fwVm.signalCssClass(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
9900 fwVm.isLoggedIn(info.isLoggedIn);
9901 fwVm.wifiStatusCssClass(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
9902 fwVm.wifiStatusImg(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
9903
9904 if(config.HAS_SMS ){
9905 if(!sv__hasCheckedSMSCapacity && info.isLoggedIn){
9906 checkSMSCapacity(info.smsUnreadCount);
9907 } else {
9908 fwVm.smsUnreadCount(info.smsUnreadCount);
9909 }
9910 }
9911
9912 sf_getConnectionCssClass(fwVm, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
9913 refreshWifiConnectStatus(fwVm, info.connectStatus,info.connectWifiSSID,info.connectWifiStatus);
9914 checkTrafficLimitAlert(fwVm, info);
9915 updateStatusBarTrans({simStatus: info.simStatus, wifiStatus: info.wifiStatus, deviceSize: info.wirelessDeviceNum, networkType: info.networkType});
9916
9917 if(info.isLoggedIn){
9918 $("#statusBar:hidden").show();
9919 } else {
9920 $("#statusBar:visible").hide();
9921 }
9922 }, 500);
9923
9924 if(config.HAS_SMS){
9925 window.setInterval(function(){
9926 if(fwVm.isLoggedIn()){
9927 checkSMSCapacity();
9928 }
9929 }, 10000);
9930 checkSmsModelReady();
9931 }
9932
9933 window.setInterval(function() {
9934 var data = getCurrentStatusInfo();
9935 var upgradingState = ["prepare_install", "low_battery", "download_success","downloading"];
9936
9937 if (fwVm.isLoggedIn() == true && !($("#progress").is(":visible")) && data.defaultWanName != ""){
9938 if ($.inArray(data.current_upgrade_state, upgradingState) != -1){
9939 if(null == sv_fotaUpdateCancel){
9940 if(!data.is_mandatory){
9941 $.modal.close();
9942 }
9943 sf_showFotaCurrentStatus();
9944 }else if(false == sv_fotaUpdateCancel){
9945 sv_fotaUpdateCancel = null;
9946 }
9947 }
9948 }
9949 }, 1000);
9950
9951 var checkFotaUpgradeResult = function () {
9952 var info = service.getStatusInfo();
9953 if (info.isLoggedIn) {
9954 service.getUpgradeResult({}, function (data) {
9955 if (data.upgrade_result == "success") {
9956 sf_showFotaUpdateResult(true);
9957 } else if (data.upgrade_result == "fail") {
9958 sf_showFotaUpdateResult(false);
9959 } else {
9960 window.setTimeout(checkFotaUpgradeResult, 1000);
9961 }
9962 }, function () {
9963 window.setTimeout(checkFotaUpgradeResult, 1000);
9964 });
9965 } else {
9966 window.setTimeout(checkFotaUpgradeResult, 1000);
9967 }
9968 };
9969 if(fwVm.updateType() == "mifi_fota"){
9970 checkFotaUpgradeResult();
9971 window.setInterval(function () {
9972 var info = getCurrentStatusInfo();
9973 if (info.isLoggedIn && info.defaultWanName != "") {
9974 if(info.new_version_state && info.fota_package_already_download != "yes" && !config.ALREADY_NOTICE){
9975 service.getUpgradeResult({}, function (data) {
9976 if (data.upgrade_result == "success") {
9977 sf_showFotaUpdateResult(true);
9978 } else if (data.upgrade_result == "fail") {
9979 sf_showFotaUpdateResult(false);
9980 } else {
9981 if(sv_fotaResultAlertPopuped == false){
9982 config.ALREADY_NOTICE = true;
9983 showOTAAlert();
9984 }
9985 }
9986 });
9987 }
9988 }
9989 }, 1000);
9990 }
9991 function checkSMSCapacity(unreadCount){
9992 service.getSmsCapability({}, function(info){
9993 var showSmsConfirm = false;
9994 if(info.nvTotal != 0 && info.nvUsed >= info.nvTotal){
9995 $("#sms_unread_count").attr("tipTitle", "sms_capacity_is_full");
9996 showSmsConfirm = true;
9997 } else if(info.nvTotal != 0 && info.nvUsed + 5 >= info.nvTotal) {
9998 $("#sms_unread_count").attr("tipTitle", "sms_capacity_will_full");
9999 showSmsConfirm = true;
10000 } else {
10001 $("#sms_unread_count").attr("tipTitle", "sms_unread_count");
10002 }
10003 fwVm.showSmsDeleteConfirm(showSmsConfirm);
10004 if(typeof unreadCount != "undefined"){
10005 fwVm.smsUnreadCount(unreadCount);
10006 }
10007 sv__hasCheckedSMSCapacity = true;
10008 });
10009 }
10010 }, 1200);
10011
10012 tooltip.init();
10013
10014 // ������Ϣģ����ʼ��״̬
10015 function checkSmsModelReady(){
10016 var info = getCurrentStatusInfo();
10017 if(info.isLoggedIn){
10018 service.getSMSReady({}, function (data) {
10019 if (data.sms_cmd_status_result == "1") {
10020 window.setTimeout(function(){checkSmsModelReady();}, 1000);
10021 } else {
10022 sv__initSMSCompleted = true;
10023 }
10024 });
10025 } else {
10026 window.setTimeout(function(){checkSmsModelReady();}, 1000);
10027 }
10028 }
10029
10030 // ������������״̬
10031 checkTrafficLimitAlert = function(fwVm, info){
10032 if(window.location.hash == '#entry'){
10033 return false;
10034 }
10035 var APStationEnabled = config.AP_STATION_SUPPORT ? service.getStatusInfo().ap_station_enable : 'undefined';
10036 var trafficResult = getTrafficResult(info);
10037 var inShow = $("#confirm-container:visible").length > 0;
10038 var notPPP = (config.PRODUCT_TYPE == 'CPE' && checkCableMode(info.blc_wan_mode)) ? true : false;
10039
10040 // ��ȡAp Stationʹ��״̬���������ѷ�ʽ
10041 if (config.AP_STATION_SUPPORT && (typeof APStationEnabled == "undefined" || APStationEnabled === '')) {
10042 service.refreshAPStationStatus({}, $.noop());
10043 return false;
10044 }
10045 APStationEnabled = APStationEnabled == 1;
10046
10047 if (!info.isLoggedIn || inShow || (sv_trafficAlertPopuped && sv_trafficAlertPopuped_100) || !info.limitVolumeEnable || (!APStationEnabled && !(info.connectStatus == "ppp_connected")) || notPPP) {
10048 return false;
10049 }
10050
10051 if(sv_resetTrafficAlertPopuped){
10052 window.setTimeout(function () {
10053 sv_resetTrafficAlertPopuped = false;
10054 }, 2000);
10055 return false;
10056 }
10057
10058 if(trafficResult.showConfirm){
10059
10060 var confirmMessage = null;
10061
10062 if(trafficResult.usedPercent > 100 && !sv_trafficAlertPopuped_100){
10063
10064 sv_trafficAlertPopuped = true;
10065 sv_trafficAlertPopuped_100 = true;
10066
10067 confirmMessage = {msg: APStationEnabled ? 'traffic_beyond_msg' : 'traffic_beyond_disconnect_msg'};
10068
10069 } else if (!sv_trafficAlertPopuped) {
10070
10071 sv_trafficAlertPopuped = true;
10072 sv_trafficAlertPopuped_100 = false;
10073 confirmMessage = {msg: APStationEnabled ? 'traffic_limit_msg' : 'traffic_limit_disconnect_msg',
10074 params: [trafficResult.limitPercent]};
10075 }
10076
10077 if (confirmMessage != null) {
10078 if (APStationEnabled) {
10079 showAlert(confirmMessage);
10080 } else {
10081 showConfirm(confirmMessage, function () {
10082 showLoading("disconnecting");
10083 service.disconnect({}, function (data) {
10084 if (data.result) {
10085 successOverlay();
10086 } else {
10087 errorOverlay();
10088 }
10089 });
10090 });
10091 }
10092 }
10093 }
10094 return true;
10095 };
10096
10097 // ����״̬�е�tooltip
10098 function updateStatusBarTrans(status){
10099 $("#statusItemSimStatus").attr("tipTitle", "sim_status_" + status.simStatus);
10100 if (status.wifiStatus) {
10101 if (status.deviceSize == 0) {
10102 $("#wifi_status").attr("tipTitle","wifi_status_on");
10103 } else {
10104 $("#wifi_status").attr("tipTitle","wifi_status" + status.deviceSize);
10105 }
10106 } else {
10107 $("#wifi_status").attr("tipTitle","wifi_status_off");
10108 }
10109 }
10110
10111
10112 // ˢ��wifi��������״̬
10113 function refreshWifiConnectStatus(fwVm, status, wifiSSID, wifiStatus) {
10114 fwVm.connectStatus(status);
10115 if (status == "ppp_disconnecting") {
10116 fwVm.connectStatusTrans("disconnecting");
10117 fwVm.connectStatusText($.i18n.prop("disconnecting"));
10118 } else if (status == "ppp_connecting") {
10119 fwVm.connectStatusTrans("connecting");
10120 fwVm.connectStatusText($.i18n.prop("connecting"));
10121 } else if (status == "ppp_connected") {
10122 fwVm.connectStatusTrans("connected");
10123 fwVm.connectStatusText($.i18n.prop("connected"));
10124 } else if(wifiSSID){
10125 if(wifiStatus =="dhcping" || wifiStatus =="connecting"){
10126 fwVm.connectStatus("wifi_connecting");
10127 fwVm.connectStatusTrans("connecting");
10128 fwVm.connectStatusText($.i18n.prop("connecting"));
10129 }else if(wifiStatus =="connect"){
10130 fwVm.connectStatus("wifi_connect");
10131 fwVm.connectStatusTrans("connected");
10132 fwVm.connectStatusText($.i18n.prop("connected"));
10133 }else{
10134 fwVm.connectStatus("ppp_disconnected");
10135 fwVm.connectStatusTrans("disconnected");
10136 fwVm.connectStatusText($.i18n.prop("disconnected"));
10137 }
10138 }else{
10139 fwVm.connectStatusTrans("disconnected");
10140 fwVm.connectStatusText($.i18n.prop("disconnected"));
10141 }
10142 }
10143
10144 // ��ȡ��ǰ����״̬
10145 getNetworkType = function(networkType) {
10146 var networkTypeTmp = networkType.toLowerCase();
10147 if (networkTypeTmp == '' || networkTypeTmp == 'limited service') {
10148 networkTypeTmp = 'limited_service';
10149 }
10150 if(networkTypeTmp == 'no service') {
10151 networkTypeTmp = 'no_service';
10152 }
10153 if (networkTypeTmp == 'limited_service' || networkTypeTmp == 'no_service') {
10154 $("#networkType", "#statusBar").attr("data-trans", "network_type_" + networkTypeTmp);
10155 return $.i18n.prop("network_type_" + networkTypeTmp);
10156 } else {
10157 $("#networkType", "#statusBar").removeAttr("data-trans");
10158 return networkType;
10159 }
10160 };
10161
10162 if(config.HAS_SMS && menu.checkIsMenuExist("sms_list")){
10163 window.setInterval(function () {
10164 var info = getCurrentStatusInfo();
10165 if(window.location.hash == "#entry" || sf_simStatusInvalid(info.simStatus)){
10166 return;
10167 }
10168 for(key in sv_messagePopStack){
10169 var val = sv_messagePopStack[key];
10170 if($.now() - val > 5000){
10171 delete(sv_messagePopStack["m" + val]);
10172 var node = $(".bubbleItem#m" + val, "#buttom-bubble");
10173 node.fadeOut(1000, function(){
10174 $(this).remove();
10175 });
10176 }
10177 }
10178 if(info.isLoggedIn){
10179 if(info.newSmsReceived && !sv_newSMSMessageInDealing){
10180 sv_newSMSMessageInDealing = true;
10181 service.resetNewSmsReceivedVar();
10182 sf_checkNewMessages();
10183 }
10184 if(info.smsReportReceived){
10185 service.resetSmsReportReceivedVar();
10186 sf_responseSmsReport();
10187 }
10188 }
10189 }, 1000);
10190
10191 if(config.SMS_DATABASE_SORT_SUPPORT){
10192 window.setInterval(function(){
10193 if(menu.checkIsMenuExist("sms_list")){
10194 var info = getCurrentStatusInfo();
10195 if(info.isLoggedIn && sv__initSMSCompleted && !sv_newSMSMessageInDealing && !sf_simStatusInvalid(info.simStatus)){
10196 sv_newSMSMessageInDealing = true;
10197 sf_checkNewMessages();
10198 }
10199 }
10200 }, 20001);
10201 }
10202 }
10203
10204 function sf_checkNewMessages(){
10205
10206 var s_tags = 1;
10207 var s_smsCount = 5;
10208
10209 if(!config.dbMsgs || config.dbMsgs.length == 0){
10210 s_smsCount = 500;
10211 s_tags = 10;
10212 }
10213 service.getSMSMessages({
10214 page : 0,
10215 smsCount : s_smsCount,
10216 nMessageStoreType : 0,
10217 tags : s_tags,
10218 orderBy : "order by id desc"
10219 }, function(data){
10220 if(data && data.messages){
10221 sf_filterNewMessage(data.messages, 0);
10222 }
10223 sv_newSMSMessageInDealing = false;
10224 });
10225 service.getSMSMessages({
10226 page : 0,
10227 smsCount : s_smsCount,
10228 nMessageStoreType : 1,
10229 tags : s_tags,
10230 orderBy : "order by id desc"
10231 }, function(data){
10232 if(data && data.messages){
10233 sf_filterNewMessage(data.messages, 1);
10234 }
10235 sv_newSMSMessageInDealing = false;
10236 });
10237 }
10238
10239 if(config.HAS_SMS){
10240 $(".bubbleItem", "#buttom-bubble").live("mouseover", function(){
10241 var $this = $(this);
10242 delete(sv_messagePopStack[$this.attr("id")]);
10243 }).live("mouseout", function(){
10244 var $this = $(this);
10245 var now = $.now();
10246 sv_messagePopStack["m" + now] = now;
10247 $this.attr("id", "m" + now);
10248 $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").data("targetid", "m" + now);
10249 });
10250
10251 $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").die().live("click", function(){
10252 var id = $(this).data("targetid");
10253 delete(sv_messagePopStack[id]);
10254 var node = $(".bubbleItem#" + id, "#buttom-bubble");
10255 node.fadeOut(1000, function(){
10256 $(this).remove();
10257 });
10258 });
10259 }
10260 }
10261
10262
10263 return {
10264 init:init,
10265 setTrafficAlertPopuped: setTrafficAlertPopuped,
10266 setTrafficAlert100Popuped: setTrafficAlert100Popuped,
10267 getTrafficResult: getTrafficResult,
10268 showOTAAlert:showOTAAlert
10269 };
10270});
10271
10272// ����ͳ������ģ��
10273define("status_traffic_alert","jquery knockout service statusBar echarts".split(" "),
10274
10275 function ($, ko, service, status, echarts) {
10276
10277 var sv_trafficGraph = null;
10278 var sv_sourceData = null;
10279 var sv_usedDataModified = false;
10280 var sv_usedTimeModified = false;
10281
10282 var sv_trafficStaticalInfo = {
10283 // ����ͼ��ʼֵ
10284 data: {
10285 alarm: {
10286
10287 itemStyle: {
10288 normal: {
10289 color: '#8CC916'
10290 }
10291 },
10292 name: '������',
10293 value: 19.7
10294 },
10295 alert: {
10296
10297 itemStyle: {
10298 normal: {
10299 color: '#FF5500'
10300 }
10301 },
10302 name: '����ֵ',
10303 value: 1
10304 },
10305 free: {
10306
10307 itemStyle: {
10308 normal: {
10309 color: '#D8D8D8'
10310 }
10311 },
10312 name: 'δʹ��',
10313 value: 50
10314 },
10315 full: {
10316
10317
10318 itemStyle: {
10319 normal: {
10320 color: '#DF4313'
10321 }
10322 },
10323 name: '��������',
10324 value: 30
10325 },
10326 left1: {
10327
10328 itemStyle: {
10329 normal: {
10330 color: '#D8D8D8'
10331 }
10332 },
10333 name: '����ֵ��δʹ��',
10334 value: 50,
10335 },
10336 start: {
10337
10338 itemStyle: {
10339 normal: {
10340 color: '#D8D8D8'
10341 }
10342 },
10343 name: '����ֵ��δʹ��',
10344 value: 50
10345 },
10346 used: {
10347
10348 itemStyle: {
10349 normal: {
10350 color: '#8CC916'
10351 }
10352 },
10353 name: '��ʹ��',
10354 value: 30
10355 }
10356 },
10357 cacheEle: {},
10358 // Ԫ�ػ�ȡ
10359 getEle: function (i_elementId) {
10360 if (this.cacheEle.hasOwnProperty('id')) {
10361 return this.cacheEle[i_elementId];
10362 } else {
10363 this.cacheEle[i_elementId] = $("#" + i_elementId);
10364 return this.cacheEle[i_elementId];
10365 }
10366 },
10367 // ��ȡ�����澯״ֵ̬
10368 fetchTrafficAlertInfo: function(){
10369 sv_sourceData = getTrafficAlertInfo();
10370 return sv_sourceData;
10371 },
10372 // ��ȡ����ֵ�Ͷ�Ӧ��λֵ
10373 getTrafficStatisticalDatalnfo: function (i_valueInfo) {
10374 return {
10375 data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
10376 unit: /[A-Z]{1,2}/.exec(i_valueInfo)[0]
10377 }
10378 },
10379
10380 // ��ȡʱ��ʱ���֡���
10381 getTrafficTimeHours: function (i_time) {
10382 var s_timeArray = i_time.split(':');
10383 return {
10384 h: parseInt(s_timeArray[0], 10),
10385 m: parseInt(s_timeArray[1], 10),
10386 s: parseInt(s_timeArray[2], 10)
10387 }
10388 },
10389 // ��ȡͳ��ʱ���Ͷ�Ӧ��λֵ
10390 getTrafficTimeInfo: function (i_valueInfo) {
10391 return {
10392 data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
10393 unit: /[a-z]{4,6}/.exec(i_valueInfo)[0]
10394 }
10395 },
10396 // ʱ�任����S
10397 getTrafficTimeToSeconds: function (i_time) {
10398 var s_FormattedTime = this.getTrafficTimeHours(i_time);
10399 return s_FormattedTime.h * 3600 + s_FormattedTime.m * 60 + s_FormattedTime.s;
10400 },
10401 // ͨ�����ƻ�ȡ������λ
10402 getTrafficUnitByScale: function (i_scale) {
10403 if (i_scale == '1024') {
10404 return 'GB';
10405 } else if (i_scale == '1048576') {
10406 return 'TB';
10407 } else {
10408 return 'MB';
10409 }
10410 },
10411 // ��λ��Ӧֵ��ȡ
10412 getTrafficValueByStatisticalUnit: function (i_unit) {
10413 i_unit = i_unit.toLowerCase();
10414 if(i_unit == 'minute'){
10415 return '60';
10416 } else if (i_unit == 'gb') {
10417 return '1024';
10418 } else if(i_unit == 'hour'){
10419 return '3600';
10420 } else if (i_unit == 'tb') {
10421 return '1048576';
10422 } else {
10423 return '1';
10424 }
10425 },
10426
10427 // ���������Ƿ��ɱ༭
10428 isFormEditable: function (fwVm) {
10429 var s_dataPageEditState = fwVm.dataLimitTypeChecked() == '1' && (fwVm.viewEditUsedData() || fwVm.viewEditAlertData() || fwVm.viewEditTotalData());
10430 var s_timePageEditState = fwVm.dataLimitTypeChecked() == '0' && (fwVm.viewEditUsedTime() || fwVm.viewEditAlertTime() || fwVm.viewEditTotalTime());
10431 if (s_dataPageEditState || s_timePageEditState) {
10432 $('.border-color-transition:visible').addClass('attention-focus');
10433 addTimeout(function () {
10434 $('.border-color-transition:visible').removeClass('attention-focus');
10435 }, 1500);
10436 return true;
10437 } else {
10438 var s_result = false;
10439 if (fwVm.dataLimitTypeChecked() == 1) {
10440 if (fwVm.alertDataReach() == '0') {
10441 fwVm.editAlertDataHandler();
10442 s_result = true;
10443 }
10444 if (fwVm.limitDataMonth() == '0') {
10445 fwVm.editTotalDataHandler();
10446 s_result = true;
10447 }
10448 } else {
10449 if (fwVm.alertTimeReach() == '0') {
10450 fwVm.editAlertTimeHandler();
10451 s_result = true;
10452 }
10453 if (fwVm.limitTimeMonth() == '0') {
10454 fwVm.editTotalTimeHandler();
10455 s_result = true;
10456 }
10457 }
10458
10459 if (s_result) {
10460 $('.border-color-transition:visible').addClass('attention-focus');
10461 addTimeout(function () {
10462 $('.border-color-transition:visible').removeClass('attention-focus');
10463 }, 1500);
10464 }
10465 return s_result;
10466 }
10467 },
10468
10469 // ˢ������ͼ��Ϣ������������ֵ����ʾ����
10470
10471 refreshFlowDiagramInfo: function (fwVm) {
10472 var s_alarm = 0;
10473 var s_left = 0;
10474 var s_left1 = 0;
10475 var s_reach = 0;
10476 var s_total = 0;
10477 var s_used = 0;
10478
10479
10480 var s_startName = $.i18n.prop("echarts_no");
10481
10482 if (sv_sourceData.dataLimitChecked == '1') { //if (fwVm.dataLimitChecked() == '1') { //����
10483 s_startName = $.i18n.prop("echarts_used");
10484 sv_trafficGraphOptions.series[0].data = [];
10485
10486 if (fwVm.dataLimitTypeChecked() == '1') { // ����
10487 sv_trafficGraphOptions.title.text = "";
10488 sv_trafficGraphOptions.series[0].data = [];
10489
10490 if (fwVm.limitDataMonth() == 0) {
10491 var s_usedData = sv_trafficStaticalInfo.data.used;
10492 s_usedData.value = 1;
10493 s_usedData.name = $.i18n.prop("echarts_used");
10494 s_usedData.selected = false;
10495 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10496 } else {
10497 s_total = fwVm.limitDataMonth() * fwVm.selectedDataUnit() * 1048576;
10498 s_used = parseInt(sv_sourceData.monthlySent, 10) + parseInt(sv_sourceData.monthlyReceived, 10);
10499 s_reach = s_total * fwVm.alertDataReach() / 100;
10500
10501 if (s_used >= s_total) {
10502 var s_fullData = sv_trafficStaticalInfo.data.full;
10503 s_fullData.value = 100;
10504 s_fullData.name = $.i18n.prop("echarts_full");
10505 sv_trafficGraphOptions.series[0].data.push(s_fullData);
10506 s_startName = $.i18n.prop("echarts_full");
10507 } else {
10508 if (s_reach > s_used) {
10509 s_left1 = s_reach - s_used;
10510 s_left = s_total - s_reach;
10511 } else {
10512 s_alarm = s_used - s_reach;
10513 s_left = s_total - s_used;
10514 }
10515
10516 var s_usedData = sv_trafficStaticalInfo.data.used;
10517 if (s_reach - s_used > 0) {
10518 s_usedData.value = s_used;
10519 } else {
10520 s_usedData.value = s_reach;
10521 }
10522 s_usedData.name = $.i18n.prop("echarts_used");
10523 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10524
10525 if (s_left1 > 0) {
10526 var s_left1Data = sv_trafficStaticalInfo.data.left1;
10527 s_left1Data.value = s_left1;
10528 s_left1Data.name = $.i18n.prop("echarts_left1");
10529 sv_trafficGraphOptions.series[0].data.push(s_left1Data);
10530 }
10531
10532 var s_alertData = sv_trafficStaticalInfo.data.alert;
10533 s_alertData.value = s_total / 200;
10534 s_alertData.name = $.i18n.prop("echarts_alert");
10535 sv_trafficGraphOptions.series[0].data.push(s_alertData);
10536
10537 if (s_alarm > 0) {
10538 var s_alarmData = sv_trafficStaticalInfo.data.alarm;
10539 s_alarmData.value = s_alarm;
10540 s_alarmData.name = $.i18n.prop("echarts_alarm");
10541 sv_trafficGraphOptions.series[0].data.push(s_alarmData);
10542 }
10543
10544 var s_freeData = sv_trafficStaticalInfo.data.free;
10545 s_freeData.value = s_left;
10546 s_freeData.name = $.i18n.prop("echarts_free");
10547 sv_trafficGraphOptions.series[0].data.push(s_freeData);
10548 }
10549 }
10550
10551 }else{// ʱ��
10552
10553 sv_trafficGraphOptions.series[0].data = [];
10554
10555 if (fwVm.limitTimeMonth() == 0) {
10556 var s_usedData = sv_trafficStaticalInfo.data.used;
10557 s_usedData.value = 1;
10558 s_usedData.selected = false;
10559 s_usedData.name = $.i18n.prop("echarts_used");
10560 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10561 } else {
10562 s_total = fwVm.limitTimeMonth() * fwVm.selectedTimeUnit();
10563 s_used = sv_sourceData.monthlyConnectedTime;
10564 s_reach = s_total * fwVm.alertTimeReach() / 100;
10565
10566 if (s_used >= s_total) {
10567 var fullTime = sv_trafficStaticalInfo.data.full;
10568 fullTime.value = 100;
10569 fullTime.name = $.i18n.prop("echarts_full");
10570 sv_trafficGraphOptions.series[0].data.push(fullTime);
10571 s_startName = $.i18n.prop("echarts_full");
10572 } else {
10573 if (s_reach - s_used > 0) {
10574 s_left1 = s_reach - s_used;
10575 s_left = s_total - s_reach;
10576 } else {
10577 s_alarm = s_used - s_reach;
10578 s_left = s_total - s_used;
10579 }
10580
10581 var s_usedTime = sv_trafficStaticalInfo.data.used;
10582 if (s_reach - s_used > 0) {
10583 s_usedTime.value = s_used;
10584 } else {
10585 s_usedTime.value = s_reach;
10586 }
10587 s_usedTime.name = $.i18n.prop("echarts_used");
10588 sv_trafficGraphOptions.series[0].data.push(s_usedTime);
10589
10590 if (s_left1 > 0) {
10591 var s_left1Time = sv_trafficStaticalInfo.data.left1;
10592 s_left1Time.value = s_left1;
10593 s_left1Time.name = $.i18n.prop("echarts_left1");
10594 sv_trafficGraphOptions.series[0].data.push(s_left1Time);
10595 }
10596
10597 var s_alertTime = sv_trafficStaticalInfo.data.alert;
10598 s_alertTime.value = s_total / 200;
10599 s_alertTime.name = $.i18n.prop("echarts_alert");
10600 sv_trafficGraphOptions.series[0].data.push(s_alertTime);
10601
10602 if (s_alarm > 0) {
10603 var s_alarmTime = sv_trafficStaticalInfo.data.alarm;
10604 s_alarmTime.value = s_alarm;
10605 s_alarmTime.name = $.i18n.prop("echarts_alarm");
10606 sv_trafficGraphOptions.series[0].data.push(s_alarmTime);
10607 }
10608
10609 var s_freeTime = sv_trafficStaticalInfo.data.free;
10610 s_freeTime.value = s_left;
10611 s_freeTime.name = $.i18n.prop("echarts_free");
10612 sv_trafficGraphOptions.series[0].data.push(s_freeTime);
10613 }
10614 }
10615 }
10616 } else {
10617 var s_usedData = sv_trafficStaticalInfo.data.used;
10618 s_usedData.value = 1;
10619 s_usedData.selected = false;
10620 s_usedData.name = $.i18n.prop("echarts_no");
10621
10622 sv_trafficGraphOptions.series[0].data = [s_usedData];
10623 sv_trafficGraphOptions.title.text = '';
10624 }
10625 sv_trafficStaticalInfo.setFlowDiagramInfo(sv_trafficGraphOptions, s_startName);
10626 },
10627
10628
10629 // �ػ�����ͼ
10630 setFlowDiagramInfo: function (i_options, i_startName) {
10631 var s_startPart = sv_trafficStaticalInfo.data.start;
10632
10633 s_startPart.name = i_startName;
10634 s_startPart.selected = false;
10635 s_startPart.value = 0;
10636
10637 var s_arr = [s_startPart].concat(i_options.series[0].data);
10638 i_options.series[0].data = s_arr;
10639 sv_trafficGraph.setOption(i_options, true);
10640
10641 addTimeout(function () {
10642 sv_trafficGraph.resize();
10643 }, 1000);
10644 }
10645 };
10646
10647
10648 // ����ͼ��������
10649 var sv_trafficGraphOptions = {
10650 animation: false,
10651 color: ['red', 'red', 'red', 'red', 'red'],
10652 series: [
10653 {
10654 name: '��������',
10655 radius: ['0', '75'],
10656 selectedOffset: 3,
10657 type: 'pie',
10658 data: [
10659
10660 ],
10661 itemStyle: {
10662 normal: {
10663 labelLine: {
10664 show: false
10665 },
10666 label: {
10667 show: false
10668 }
10669 }
10670 }
10671 }
10672 ],
10673 title: {
10674 itemGap: 0,
10675 text: '',
10676 subtextStyle: {
10677 color: '#FFF',
10678 fontFamily: '΢���ź�',
10679 fontSize: 16,
10680 fontWeight: 'bolder'
10681 },
10682 textStyle: {
10683 color: '#FFF',
10684 fontFamily: '΢���ź�',
10685 fontSize: 20,
10686 fontWeight: 'bolder'
10687 },
10688 x: 'center',
10689 y: 'center'
10690 },
10691 tooltip: {
10692 formatter: "{b}"
10693 }
10694 };
10695
10696
10697 // ��ȡ������������
10698 function getTrafficAlertInfo() {
10699 return service.getTrafficAlertInfo();
10700 }
10701
10702
10703
10704 // ��������ViewModel
10705
10706 function trafficViewModel() {
10707
10708 var target = this;
10709
10710 var info = sv_trafficStaticalInfo.fetchTrafficAlertInfo();
10711 var dataMonth = info.limitDataMonth.split("_");
10712
10713 sv_usedDataModified = false;
10714 sv_usedTimeModified = false;
10715
10716 target.alertDataReach = ko.observable(info.alertDataReach || 0);
10717 target.alertTimeReach = ko.observable(info.alertTimeReach || 0);
10718 target.dataLimitChecked = ko.observable(info.dataLimitChecked == '0' ? '0' : '1');
10719 target.dataLimitTypeChecked = ko.observable(info.dataLimitTypeChecked == '0' ? '0' : '1');
10720 target.limitTimeMonth = ko.observable(info.limitTimeMonth || 0);
10721
10722
10723 // ע��˳��
10724 target.usedDataText = ko.observable(transUnit(parseInt(info.monthlySent, 10) + parseInt(info.monthlyReceived, 10), false));
10725 var sv_staticalDataInfo = sv_trafficStaticalInfo.getTrafficStatisticalDatalnfo(target.usedDataText());
10726 var sv_staticalInfoData = sv_staticalDataInfo.data;
10727 target.dataUsed = ko.observable(sv_staticalInfoData);
10728 var sv_staticalInfoUnit = sv_staticalDataInfo.unit;
10729 target.selectedDataUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_staticalInfoUnit));
10730 target.usedDataTextDescData = ko.observable("");
10731
10732 target.limitDataMonth = ko.observable(dataMonth[0] || 0);
10733 target.selectedDataUnit = ko.observable(dataMonth[1] || 1);
10734
10735 var limitDataMonthTmp = transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1024 * 1024, false);
10736 var limitDataMonthUnitTmp = limitDataMonthTmp.substring(limitDataMonthTmp.length-2);
10737 target.limitDataMonth(limitDataMonthTmp.substring(0, limitDataMonthTmp.length-2));
10738 target.selectedDataUnit(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(limitDataMonthUnitTmp));
10739
10740 target.usedDataTextDesc = ko.computed(sf_usedDataTextDesc);
10741 target.limitDataMonthDescData = ko.observable("");
10742 target.limitDataMonthDesc = ko.computed(sf_limitDataMonthDesc);
10743 target.alertDataReachDescData = ko.observable("");
10744 target.alertDataReachDesc = ko.computed(sf_alertDataReachDesc);
10745 target.leftDataDescData = ko.observable("");
10746 target.leftDataDesc = ko.computed(sf_leftDataDesc);
10747 target.monthlyConnectedTime = ko.observable(transSecond2Time(info.monthlyConnectedTime));
10748
10749 var sv_timeInfo1 = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(info.monthlyConnectedTime));
10750 target.usedTime = ko.observable(sv_timeInfo1.data);
10751 target.selectedTimeUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfo1.unit));
10752
10753 target.usedTimeTextDescData = ko.observable("");
10754 target.usedTimeTextDesc = ko.computed(sf_usedTimeTextDesc);
10755
10756 var sv_timeInfoNew = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(parseFloat(target.limitTimeMonth()) * 3600));
10757 target.selectedTimeUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfoNew.unit));
10758 target.limitTimeMonth(sv_timeInfoNew.data);
10759
10760
10761 target.limitTimeMonthDescData = ko.observable("");
10762 target.limitTimeMonthDescText = ko.observable("traffic_limit_time_h");
10763 target.limitTimeMonthDesc = ko.computed(sf_limitTimeMonthDesc);
10764 target.alertTimeReachDescData = ko.observable("");
10765 target.alertTimeReachDesc = ko.computed(sf_alertTimeReachDesc);
10766 target.leftTimeDescData = ko.observable("");
10767 target.leftTimeDesc = ko.computed(sf_leftTimeDesc);
10768 target.save = sf_save;
10769 target.viewEditUsedData = ko.observable(false);
10770 target.editUsedDataHandler = sf_editUsedDataHandler;
10771 target.editUsedDataSaveHandler = sf_editUsedDataSaveHandler;
10772 target.saveUsedData = sf_saveUsedData;
10773 target.editUsedDataCancelHandler = sf_editUsedDataCancelHandler;
10774 target.viewEditTotalData = ko.observable(false);
10775 target.editTotalDataHandler = sf_editTotalDataHandler;
10776 target.editTotalDataSaveHandler = sf_editTotalDataSaveHandler;
10777 target.editTotalDataCancelHandler = sf_editTotalDataCancelHandler;
10778 target.viewEditAlertData = ko.observable(false);
10779 target.editAlertDataHandler = sf_editAlertDataHandler;
10780 target.editAlertDataSaveHandler = sf_editAlertDataSaveHandler;
10781 target.editAlertDataCancelHandler = sf_editAlertDataCancelHandler;
10782 target.viewEditUsedTime = ko.observable(false);
10783 target.editUsedTimeHandler = sf_editUsedTimeHandler;
10784 target.saveUsedTime = sf_saveUsedTime;
10785 target.editUsedTimeSaveHandler = sf_editUsedTimeSaveHandler;
10786 target.editUsedTimeCancelHandler = sf_editUsedTimeCancelHandler;
10787 target.viewEditTotalTime = ko.observable(false);
10788 target.editTotalTimeHandler = sf_editTotalTimeHandler ;
10789 target.editTotalTimeSaveHandler = sf_editTotalTimeSaveHandler;
10790 target.editTotalTimeCancelHandler = sf_editTotalTimeCancelHandler;
10791 target.viewEditAlertTime = ko.observable(false);
10792 target.editAlertTimeHandler = sf_editAlertTimeHandler;
10793 target.editAlertTimeSaveHandler = sf_editAlertTimeSaveHandler;
10794 target.editAlertTimeCancelHandler = sf_editAlertTimeCancelHandler;
10795 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
10796
10797
10798 // ��������������
10799 function sf_alertDataReachDesc() {
10800 if(isNaN(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach())) {
10801 target.alertDataReachDescData(target.alertDataReach() + ', ');
10802 return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), ' ');
10803 }
10804
10805 var s_value = transUnit(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach() * 1048576 / 100, false);
10806 target.alertDataReachDescData(target.alertDataReach() + ',' + s_value);
10807 return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), s_value);
10808 }
10809 // ʱ������������
10810 function sf_alertTimeReachDesc() {
10811 if(isNaN(target.limitTimeMonth() * target.alertTimeReach())) {
10812 target.alertTimeReachDescData(target.alertTimeReach() + ', ');
10813 return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), ' ');
10814 }
10815 var s_value = transSecond2Time(target.limitTimeMonth() * target.selectedTimeUnit() * target.alertTimeReach() / 100);
10816 target.alertTimeReachDescData(target.alertTimeReach() + ',' + s_value);
10817 return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), s_value);
10818 }
10819
10820
10821 // ��������ֵȡ���༭��ť�¼�
10822 function sf_editAlertDataCancelHandler() {
10823 target.alertDataReach(sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue'));
10824 target.viewEditAlertData(false);
10825 }
10826
10827 // ��������ֵ�༭��ť�¼�
10828 function sf_editAlertDataHandler() {
10829 sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue', target.alertDataReach());
10830 target.viewEditAlertData(true);
10831 }
10832
10833 // ��������ֵ�����༭��ť�¼�
10834 function sf_editAlertDataSaveHandler() {
10835 if (sv_trafficStaticalInfo.getEle('alertDataReach').valid()) {
10836 target.viewEditAlertData(false);
10837 }
10838 }
10839
10840 // ʱ������ֵȡ���༭��ť�¼�
10841 function sf_editAlertTimeCancelHandler() {
10842 target.alertTimeReach(sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue'));
10843 target.viewEditAlertTime(false);
10844 }
10845 // ʱ������ֵ�༭��ť�¼�
10846 function sf_editAlertTimeHandler() {
10847 sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue', target.alertTimeReach());
10848 target.viewEditAlertTime(true);
10849 }
10850 // ʱ������ֵ�����༭��ť�¼�
10851 function sf_editAlertTimeSaveHandler() {
10852 if (sv_trafficStaticalInfo.getEle('alertTimeReach').valid()) {
10853 target.viewEditAlertTime(false);
10854 }
10855 }
10856
10857 // �ײ������༭��ť�¼�
10858 function sf_editTotalDataHandler() {
10859 sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue', target.limitDataMonth());
10860 sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue', target.selectedDataUnit());
10861 target.viewEditTotalData(true);
10862 }
10863
10864 // �ײ����������༭��ť�¼�
10865 function sf_editTotalDataSaveHandler() {
10866 if (sv_trafficStaticalInfo.getEle('limitDataMonth').valid()) {
10867 target.usedDataText(transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1048576, false));
10868 target.viewEditTotalData(false);
10869 }
10870 }
10871
10872 // �ײ�����ȡ���༭��ť�¼�
10873 function sf_editTotalDataCancelHandler() {
10874 target.limitDataMonth(sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue'));
10875 target.selectedDataUnit(sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue'));
10876 target.viewEditTotalData(false);
10877 }
10878 // �ײ�ʱ��ȡ���༭��ť�¼�
10879 function sf_editTotalTimeCancelHandler() {
10880 target.limitTimeMonth(sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue'));
10881 target.viewEditTotalTime(false);
10882 }
10883 // �ײ�ʱ���༭��ť�¼�
10884 function sf_editTotalTimeHandler() {
10885 sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue', target.limitTimeMonth());
10886 target.viewEditTotalTime(true);
10887 }
10888 // �ײ�ʱ�䱣���༭��ť�¼�
10889 function sf_editTotalTimeSaveHandler() {
10890 if (sv_trafficStaticalInfo.getEle('limitTimeMonth').valid()) {
10891 target.viewEditTotalTime(false);
10892 }
10893 }
10894
10895 // ��������ȡ���༭��ť�¼�
10896 function sf_editUsedDataCancelHandler() {
10897 target.dataUsed(sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue'));
10898 target.selectedDataUsedUnit(sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue'));
10899 sv_trafficStaticalInfo.getEle('editUsedDataCancel').siblings('label.error').hide();
10900 target.viewEditUsedData(false);
10901 }
10902 // ���������༭��ť�¼�
10903 function sf_editUsedDataHandler() {
10904 sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue', target.dataUsed());
10905 sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue', target.selectedDataUsedUnit());
10906 target.dataUsed(target.dataUsed());
10907 target.viewEditUsedData(true);
10908 }
10909 // �����������水ť�¼�
10910 function sf_editUsedDataSaveHandler() {
10911 if (sv_trafficStaticalInfo.getEle('dataUsed').valid()) {
10912 sv_usedDataModified = true;
10913 target.viewEditUsedData(false);
10914 }
10915 }
10916 // ����ʱ��ȡ���༭��ť�¼�
10917 function sf_editUsedTimeCancelHandler() {
10918 target.usedTime(sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue'));
10919 target.viewEditUsedTime(false);
10920 }
10921 // ����ʱ���༭��ť�¼�
10922 function sf_editUsedTimeHandler() {
10923 sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue', target.usedTime());
10924 target.viewEditUsedTime(true);
10925 }
10926
10927 // ����ʱ�䱣���༭��ť�¼�
10928 function sf_editUsedTimeSaveHandler() {
10929 if (sv_trafficStaticalInfo.getEle('usedTime').valid()) {
10930 target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
10931 target.viewEditUsedTime(false);
10932 sv_usedTimeModified = true;
10933 }
10934 }
10935
10936 // ʣ������������
10937 function sf_leftDataDesc() {
10938 var s_left = (target.limitDataMonth() * target.selectedDataUnit() - target.dataUsed() * target.selectedDataUsedUnit()) * 1048576;
10939 if(s_left < 0) {
10940 s_left = 0;
10941 }
10942
10943 if(isNaN(s_left)) {
10944 target.leftDataDescData('');
10945 return $.i18n.prop('traffic_data_left_text', ' ');
10946 }
10947
10948 target.leftDataDescData(transUnit(s_left, false));
10949 return $.i18n.prop('traffic_data_left_text', transUnit(s_left, false));
10950 }
10951 //ʣ��ʱ��������
10952 function sf_leftTimeDesc() {
10953 var s_surplus = target.limitTimeMonth() * target.selectedTimeUnit() - sv_trafficStaticalInfo.getTrafficTimeToSeconds(target.monthlyConnectedTime());
10954 if(s_surplus < 0) {
10955 s_surplus = 0;
10956 }
10957
10958 if(isNaN(s_surplus)) {
10959 target.leftTimeDescData(' ');
10960 return $.i18n.prop('traffic_data_left_text', ' ');
10961 }
10962 target.leftTimeDescData(transSecond2Time(s_surplus));
10963 return $.i18n.prop('traffic_data_left_text', transSecond2Time(s_surplus));
10964 }
10965 // �ײ�����������
10966 function sf_limitDataMonthDesc() {
10967 if(isNaN(target.limitDataMonth())) {
10968 target.limitDataMonthDescData("");
10969 return $.i18n.prop('traffic_limit_data_text', ' ');
10970 }else{
10971 // todo
10972 }
10973
10974 target.limitDataMonthDescData(target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
10975 return $.i18n.prop('traffic_limit_data_text', target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
10976 }
10977 // �ײ�ʱ��������
10978 function sf_limitTimeMonthDesc() {
10979 if(isNaN(target.limitTimeMonth())) {
10980 target.limitTimeMonthDescData(' ');
10981 target.limitTimeMonthDescText('traffic_limit_time_h');
10982 return $.i18n.prop('traffic_limit_time_h', ' ');
10983 }else{
10984 // todo:
10985 }
10986
10987 target.limitTimeMonthDescData(target.limitTimeMonth());
10988
10989 if(target.selectedTimeUnit() == "60"){
10990 target.limitTimeMonthDescText('traffic_limit_time_m');
10991 return $.i18n.prop('traffic_limit_time_m', target.limitTimeMonth());
10992 }else{
10993 target.limitTimeMonthDescText('traffic_limit_time_h');
10994 return $.i18n.prop('traffic_limit_time_h', target.limitTimeMonth());
10995 }
10996 }
10997
10998 // Ӧ�ð�ť�¼�
10999 function sf_save() {
11000 if (sv_trafficStaticalInfo.isFormEditable(target) && target.dataLimitChecked() == '1') {
11001 return false;
11002 }
11003
11004 if (target.selectedDataUnit() == '1' && target.selectedDataUsedUnit() == '1048576' && target.dataLimitTypeChecked() == "1" && target.dataLimitChecked() == '1' && !(parseInt(target.dataUsed(), 10) < parseInt('4096', 10)) ) {
11005 showAlert('traffic_over_note');
11006 return false;
11007 }
11008
11009 showLoading();
11010 service.setTrafficAlertInfo({
11011 alertDataReach: parseInt(target.alertDataReach(), 10),
11012 alertTimeReach: parseInt(target.alertTimeReach(), 10),
11013 dataLimitChecked: target.dataLimitChecked(),
11014 dataLimitTypeChecked: target.dataLimitTypeChecked(),
11015 limitDataMonth: target.limitDataMonth() + "_" + target.selectedDataUnit(),
11016 limitTimeMonth: target.selectedTimeUnit() == "60" ? target.limitTimeMonth()/60 : target.limitTimeMonth()//save by hours
11017 }, function (data) {
11018 if (data.result == 'success') {
11019 if(target.dataLimitTypeChecked() == "1" && sv_usedDataModified) {
11020 target.saveUsedData();
11021 } else if(target.dataLimitTypeChecked() == "0" && sv_usedTimeModified) {
11022 target.saveUsedTime();
11023 } else {
11024 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11025 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11026 status.setTrafficAlertPopuped(false);
11027 successOverlay();
11028 }
11029 } else {
11030 errorOverlay();
11031 }
11032 }, function () {
11033 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11034 errorOverlay();
11035 });
11036 }
11037
11038 // ����������������
11039 function sf_saveUsedData() {
11040 var val = target.dataUsed() * target.selectedDataUsedUnit();
11041 service.trafficCalibration({
11042 way: 'data',
11043 value: val
11044 }, function(){
11045 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11046 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11047 successOverlay();
11048 target.viewEditUsedData(false);
11049 status.setTrafficAlertPopuped(false);
11050 sv_usedDataModified = false;
11051 }, function(){
11052 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11053 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11054 errorOverlay();
11055 });
11056 }
11057
11058
11059
11060 function sf_saveUsedTime() {
11061 service.trafficCalibration({
11062 way: 'time',
11063 value: target.selectedTimeUsedUnit() == "60" ? parseFloat(target.usedTime())/60 : target.usedTime()
11064 }, function(){
11065 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11066 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11067 successOverlay();
11068 target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
11069 target.viewEditUsedTime(false);
11070 status.setTrafficAlertPopuped(false);
11071 sv_usedTimeModified = false;
11072 }, function(){
11073 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11074 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11075 errorOverlay();
11076 });
11077 }
11078
11079
11080 // ��������������
11081 function sf_usedDataTextDesc() {
11082 if(isNaN(target.dataUsed())) {
11083 target.usedDataTextDescData("");
11084 return $.i18n.prop('traffic_used_text', ' ');
11085 }
11086 target.usedDataTextDescData(target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
11087 return $.i18n.prop('traffic_used_text', target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
11088 }
11089 // ����ʱ��������
11090 function sf_usedTimeTextDesc() {
11091 target.usedTimeTextDescData(target.monthlyConnectedTime());
11092 return $.i18n.prop('traffic_used_text', target.monthlyConnectedTime());
11093 }
11094
11095
11096 }
11097
11098 function init() {
11099 sv_trafficGraph = echarts.init($("#traffic_graphic")[0]);
11100 window.onresize = sv_trafficGraph.resize;
11101 var s_container = $('#container');
11102 ko.cleanNode(s_container[0]);
11103 var fwVm = new trafficViewModel();
11104 ko.applyBindings(fwVm, s_container[0]);
11105 $('#trafficAlertForm').validate({
11106 submitHandler: function () {
11107 fwVm.save();
11108 },
11109
11110
11111 errorPlacement: function (error, para) {
11112 if (para.attr("name") == "alertDataReach") {
11113 error.insertAfter("#editAlertDataDiv");
11114 } else if (para.attr("name") == "alertTimeReach") {
11115 error.insertAfter("#editAlertTimeDiv");
11116 } else if (para.attr("name") == "dataUsed") {
11117 error.insertAfter("#editUsedDataDiv");
11118 } else if (para.attr("name") == "limitDataMonth") {
11119 error.insertAfter("#editTotalDataDiv");
11120 } else if (para.attr("name") == "limitTimeMonth") {
11121 error.insertAfter("#editTotalTimeDiv");
11122 } else if (para.attr("name") == "usedTime") {
11123 error.insertAfter("#editUsedTimeDiv");
11124 } else {
11125 error.insertAfter(para);
11126 }
11127 },
11128
11129 rules: {
11130 alertDataReach: {
11131 range: [ 1, 100 ],
11132 digits: true
11133 },
11134 alertTimeReach: {
11135 range: [ 1, 100 ],
11136 digits: true
11137 },
11138 dataUsed: {
11139 range : [ 0, 9999 ],
11140 decimalRange : true
11141 },
11142 limitDataMonth: {
11143 range : [ 1, 9999 ],
11144 decimalRange : true
11145 },
11146 limitTimeMonth: {
11147 range : [ 1, 9999 ],
11148 decimalRange : true
11149 },
11150 usedTime: {
11151 range : [ 0, 9999 ],
11152 decimalRange : true
11153 }
11154 }
11155
11156 });
11157
11158 var sv_originalLan = window.language;
11159 window.setInterval(function(){
11160 if(sv_originalLan != window.language){
11161 sv_originalLan = window.language;
11162 sv_trafficStaticalInfo.refreshFlowDiagramInfo(fwVm);
11163 }
11164 }, 1000);
11165
11166 }
11167
11168 return {
11169 init: init
11170 };
11171});
11172
11173// ״̬����ʾ��ʵ��
11174define("tooltip",[ "jquery" ],
11175
11176 function($) {
11177
11178
11179 // ����Ԫ��λ����Ϣ
11180 // @method calculatePositionInfo
11181 // @param trigger Ԫ��
11182 // @param tooltip ״̬��
11183 // @param {JSON} config �����
11184
11185 function calculatePositionInfo(trigger, tooltip, config) {
11186 var top = trigger.offset().top;
11187 var left = trigger.offset().left;
11188 var position = config.position[0];
11189 var height = tooltip.outerHeight() + trigger.outerHeight();
11190 var width = tooltip.outerWidth() + trigger.outerWidth();
11191
11192 top -= tooltip.outerHeight() - config.offset[0];
11193 left += trigger.outerWidth() + config.offset[1];
11194
11195 if (/iPad/i.test(navigator.userAgent)) {
11196 top -= $(window).scrollTop();
11197 }
11198
11199 if (position == 'center') {
11200 top += height / 2;
11201 }
11202 if (position == 'bottom') {
11203 top += height;
11204 }
11205 position = config.position[1];
11206 if (position == 'center') {
11207 left -= width / 2;
11208 }else if (position == 'left') {
11209 left -= width;
11210 }
11211
11212 return {
11213 top : top,
11214 left : left
11215 };
11216 }
11217
11218 // ״̬����ʼ��
11219 function init() {
11220
11221 $(".statusItem", "#statusBar").each(function(i, n){
11222 var $this = $(this);
11223 $this.attr("tipTitle", $this.attr("title")).removeAttr("title");
11224 }).hover(
11225 function() {
11226 var $this = $(this);
11227 var title = $this.attr("tipTitle");
11228 var tooltip = $("<div>").addClass("tooltip in").appendTo(document.body).hide()
11229 .append($this.attr("i18n") ? $.i18n.prop(title) : title);
11230 if ($this.attr("i18n")) {
11231 tooltip.attr("data-trans", title).attr("id", "tooltip_" + $this.attr("id"));
11232 }
11233 var pos = calculatePositionInfo($this, tooltip, {
11234 position : [ 'bottom', 'center' ],
11235 offset : [ 0, 0 ]
11236 });
11237 tooltip.css({
11238 position : 'absolute',
11239 top : pos.top,
11240 left : pos.left
11241 }).show();
11242 }, function() {
11243 $(".tooltip").hide().remove();
11244 });
11245 }
11246
11247 return {
11248 init : init
11249 };
11250 });
11251
11252define("menu","set service knockout underscore jquery".split(" "),
11253 function (set, fnc, libko, libus, libjq) {
11254 var displayMenuWhenLogout = false;
11255 var vmMenu;
11256 var menu = [];
11257 var menuResource = "";
11258
11259 function menuExistCheck(path) {
11260 for (var i = 0; i < menu.length; i++) {
11261 if (menu[i].path == path) {
11262 return true;
11263 }
11264 }
11265 return false;
11266 }
11267
11268 function getIsLoggedin() {
11269 var loginStatus = fnc.getLoginStatus();
11270 return (loginStatus.status == "loggedIn");
11271 }
11272
11273 function buildNew() {
11274 var loggedIn = getIsLoggedin();
11275 var menuMain = libus.filter(menu, function (param) {
11276 return (param.level == '1' && ((param.requireLogin && loggedIn) || !param.requireLogin) && param.hash != "#entry");
11277 });
11278 vmMenu.menuMain(menuMain);
11279 vmMenu.loggedIn(loggedIn);
11280
11281 getMainWth(vmMenu.menuMain().length);
11282 vmMenu.showMenu(loggedIn || displayMenuWhenLogout);
11283 libjq("#nav").translate();
11284 }
11285
11286 function getMainWth(len) {
11287 var width = 100 / len;
11288 libjq('ul#list-nav li').each(function () {
11289 libjq(this).css('width', width + '%');
11290 });
11291 }
11292
11293 function menuRefresh() {
11294 var currentHash = window.location.hash;
11295 var itmRoot = libus.find(menu, function (param) {
11296 return param.hash == currentHash;
11297 });
11298 while (itmRoot.parent) {
11299 itmRoot = libus.find(menu, function (param) {
11300 return param.hash == itmRoot.parent;
11301 });
11302 }
11303 if (!itmRoot.parent) {
11304 libjq("#list-nav li").removeClass("active");
11305 var mid = itmRoot.hash.substring(1, itmRoot.hash.length);
11306 libjq("#list-nav li[mid=" + mid + "]").addClass("active");
11307 }
11308 vmMenu.changeMenu(itmRoot);
11309 }
11310
11311 function menuSearch(hashVal) {
11312 hashVal = hashVal || window.location.hash;
11313 var loggedIn = getIsLoggedin();
11314 return libus.filter(menu, function (param) {
11315 return (hashVal == param.hash && ((param.requireLogin && loggedIn) || !param.requireLogin));
11316 });
11317 }
11318
11319 function menuRenderSub(level, baseItem) {
11320 var levelItem = libus.find(menu, function (param) {
11321 return param.parent == baseItem.hash && param.path == baseItem.path;
11322 });
11323 libjq(".menu-" + level + "-level").removeClass("active");
11324 if (levelItem) {
11325 if (level == "two") {
11326 menuRenderSub("three", levelItem);
11327 //forward/backward support
11328 clickMenuTrig(levelItem.hash, level);
11329 }
11330 libjq(".menu-" + level + "-level." + levelItem.hash.substring(1)).addClass("active");
11331 }
11332 }
11333
11334 function menuActSub() {
11335 var currentHash = window.location.hash;
11336 var itmRoot = libus.find(menu, function (param) {
11337 return param.hash == currentHash;
11338 });
11339 if (itmRoot.level == 1) {
11340 menuRenderSub("two", itmRoot);
11341 }
11342 if (itmRoot.level == 2) {
11343 menuRenderSub("three", itmRoot);
11344 //forward/backward support
11345 clickMenuTrig(itmRoot.hash, itmRoot.level);
11346 }
11347 if (itmRoot.level == 3) {
11348 //forward/backward support
11349 clickMenuTrig(itmRoot.parent, itmRoot.level);
11350 libjq(".menu-three-level").removeClass("active");
11351 libjq(".menu-three-level." + itmRoot.hash.substring(1)).addClass("active");
11352 }
11353 }
11354
11355 function clickMenuTrig(hash, level) {
11356 libjqobj = libjq(".menu-two-level." + hash.substring(1));
11357 var levelArr = ['3', 'three', '2', 'two'];
11358 if (libus.indexOf(levelArr, level) != -1 && libjqobj.hasClass('active')) {
11359 return;
11360 }
11361
11362 libjqobj.siblings().removeClass('active');
11363 libjqobj.addClass('active');
11364
11365 libjqobj.siblings().not('.menu-two-level').slideUp();
11366 libjqobj.next().has('ul li').slideDown();
11367 }
11368
11369 set.blc_wan_mode = fnc.getOpMode().blc_wan_mode;
11370 if (!set.RJ45_SUPPORT) {
11371 menuResource = "menu";
11372 } else {
11373 switch (set.blc_wan_mode) {
11374 case "PPPOE":
11375 case "AUTO_PPPOE":
11376 menuResource = "menu_pppoe";
11377 break;
11378 default:
11379 menuResource = "menu";
11380 break;
11381 }
11382 }
11383
11384 require([set.DEVICE + '/' + menuResource], function (otherMenu) {
11385 menu = otherMenu;
11386 if (set.SD_CARD_SUPPORT) {
11387 menu = menu.concat([{ hash: '#httpshare_guest', path: 'sd_httpshare', level: '', requireLogin: false, checkSIMStatus: false},
11388 { hash: '#sdcard', path: 'sd', level: '', requireLogin: true, checkSIMStatus: false},
11389 { hash: '#httpshare', path: 'sd_httpshare', level: '', requireLogin: true, checkSIMStatus: false}]);
11390 }
11391 });
11392
11393 function initialize() {
11394 vmMenu = new Menu_vm();
11395 }
11396
11397 function Menu_vm() {
11398 var loginState = getIsLoggedin();
11399 var target = this;
11400 target.loggedIn = libko.observable(loginState);
11401
11402 target.showMenu = libko.observable(loginState || displayMenuWhenLogout);
11403
11404 var menuMain = libus.filter(menu, function (param) {
11405 return (param.level == '1' && ((param.requireLogin && target.loggedIn()) || !param.requireLogin) && param.hash != "#entry");
11406 });
11407
11408 target.menuMain = libko.observableArray(menuMain);
11409 target.secondMenu = libko.observableArray([]);
11410 //target.curThirdMenu; cov_2
11411 target.changeMenu = function (data) {
11412 var secondMenu = getSubMenu(data);
11413 if (secondMenu.length == 0) {
11414 libjq("#container").addClass("fixContainerWidth");
11415 } else {
11416 libjq("#container").removeClass("fixContainerWidth");
11417 }
11418
11419 target.secondMenu(secondMenu);
11420 return true;
11421 };
11422 target.thirdMenu = function () {
11423 return target.curThirdMenu;
11424 };
11425 target.getThirdMenu = function (data) {
11426 target.curThirdMenu = getSubMenu(data);
11427 };
11428 function getSubMenu(data) {
11429 return libus.filter(menu, function (param) {
11430 return ((param.parent && param.parent == data.hash) && ((param.requireLogin && target.loggedIn()) || !param.requireLogin));
11431 });
11432 }
11433 }
11434
11435 return {
11436 activeSubMenu: menuActSub,
11437 checkIsMenuExist: menuExistCheck,
11438 findMenu: menuSearch,
11439 rebuild: buildNew,
11440 refreshMenu: menuRefresh,
11441 init: initialize
11442 };
11443});