blob: 069fe7287c8347ae3eb6cdbbb47a1cd54030819d [file] [log] [blame]
w.dengd463b342024-12-20 10:21:38 +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.qu28df13a2025-01-07 19:14:21 -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 }
w.dengd463b342024-12-20 10:21:38 +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 = {};
mj.qu9e77b892025-03-26 02:08:28 -07002849 valueReq.cmd = "WirelessMode,CountryCode,web_channel,HT_MCS,wifi_band,wifi_11n_cap,MAX_Access_num,m_MAX_Access_num,MAX_Station_num,wifi_sta_connection";
w.dengd463b342024-12-20 10:21:38 +08002850 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,
mj.qu9e77b892025-03-26 02:08:28 -07002858 channel: paramD.web_channel,
w.dengd463b342024-12-20 10:21:38 +08002859 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.qu28df13a2025-01-07 19:14:21 -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",
w.dengd463b342024-12-20 10:21:38 +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.qu28df13a2025-01-07 19:14:21 -08002937 iccid: paramD.ziccid,
2938 cellid: paramD.cell_id,
w.dengd463b342024-12-20 10:21:38 +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 }
w.deng5fb68452025-02-10 17:07:51 +08004408 function wefotagetNewVersionState() {
4409 return stuffMake(arguments, {}, prepare, deal, null, false);
4410 function prepare(values, isPost) {
4411 var valueReq = {};
4412 valueReq.cmd = "wefota_new_version_state,wefota_current_upgrade_state";
4413 valueReq.multi_data = 1;
4414 return valueReq;
4415 }
4416 function deal(paramD) {
4417 if (paramD) {
4418 return paramD;
4419 } else {
4420 return errUnknownObj;
4421 }
4422 }
4423 }
w.dengd463b342024-12-20 10:21:38 +08004424 function getMandatory() {
4425 return stuffMake(arguments, {}, prepare, deal, null, false);
4426 function prepare(values, isPost) {
4427 var valueReq = {};
4428 if (config.UPGRADE_TYPE == "OTA") {
4429 valueReq.cmd = "is_mandatory";
4430 } else {
4431 valueReq.cmd = "fota_new_version_state";
4432 }
4433 return valueReq;
4434 }
4435 function deal(paramD) {
4436 if (paramD) {
4437 if (config.UPGRADE_TYPE == "OTA") {
4438 return {
4439 "is_mandatory": paramD.is_mandatory == "1"
4440 };
4441 } else {
4442 return {
4443 "is_mandatory": paramD.fota_new_version_state == "has_critical"
4444 };
4445 }
4446 } else {
4447 return errUnknownObj;
4448 }
4449 }
4450 }
4451 function getUpgradeResult() {
4452 return stuffMake(arguments, {}, prepare, deal, null, false);
4453 function prepare(values, isPost) {
4454 var valueReq = {};
4455 valueReq.cmd = "upgrade_result";
4456 return valueReq;
4457 }
4458 function deal(paramD) {
4459 if (paramD) {
4460 return paramD;
4461 } else {
4462 return errUnknownObj;
4463 }
4464 }
4465 }
4466 function getCurrentUpgradeState() {
4467 return stuffMake(arguments, {}, prepare, deal, null, false);
4468 function prepare(values, isPost) {
4469 var valueReq = {};
4470 valueReq.cmd = "fota_current_upgrade_state";
4471 return valueReq;
4472 }
4473 function deal(paramD) {
4474 if (paramD) {
4475 paramD.current_upgrade_state = paramD.fota_current_upgrade_state;
4476 return paramD;
4477 } else {
4478 return errUnknownObj;
4479 }
4480 }
4481 }
4482 function getPackSizeInfo() {
4483 return stuffMake(arguments, {}, prepare, deal, null, false);
4484 function prepare(values, isPost) {
4485 var valueReq = {};
4486 valueReq.cmd = "fota_pkg_total_size,fota_dl_pkg_size";
4487 valueReq.multi_data = 1;
4488 return valueReq;
4489 }
4490 function deal(paramD) {
4491 if (paramD) {
4492 return paramD;
4493 } else {
4494 return errUnknownObj;
4495 }
4496 }
4497 }
4498 function setUpgradeSelectOp() {
4499 return stuffMake(arguments, {}, prepare, deal, null, true);
4500 function prepare(values, isPost) {
4501 var valueReq = {};
4502 valueReq.goformId = "IF_UPGRADE";
4503 valueReq.select_op = values.selectOp;
4504 if (valueReq.select_op == 'check') {
4505 valueReq.ota_manual_check_roam_state = 1;
4506 }
4507 return valueReq;
4508 }
4509 function deal(paramD) {
4510 if (paramD) {
4511 return paramD;
4512 } else {
4513 return errUnknownObj;
4514 }
4515 }
4516 }
4517 function getOTAUpdateSetting() {
4518 return stuffMake(arguments, {}, prepare, deal, null, false);
4519 function prepare(values, isPost) {
4520 var valueReq = {};
4521 valueReq.cmd = "fota_updateMode,fota_updateIntervalDay,fota_allowRoamingUpdate";
4522 valueReq.multi_data = 1;
4523 return valueReq;
4524 }
4525 function deal(paramD) {
4526 if (paramD) {
4527 return {
4528 updateMode: paramD.fota_updateMode,
4529 updateIntervalDay: paramD.fota_updateIntervalDay,
4530 allowRoamingUpdate: paramD.fota_allowRoamingUpdate
4531 };
4532 } else {
4533 return errUnknownObj;
4534 }
4535 }
4536 }
4537 function setOTAUpdateSetting() {
4538 return stuffMake(arguments, {}, prepare, deal, null, true);
4539 function prepare(values, isPost) {
4540 var valueReq = {};
4541 valueReq.goformId = "SetUpgAutoSetting";
4542 valueReq.UpgMode = values.updateMode;
4543 valueReq.UpgIntervalDay = values.updateIntervalDay;
4544 valueReq.UpgRoamPermission = values.allowRoamingUpdate;
4545 return valueReq;
4546 }
4547 function deal(paramD) {
4548 if (paramD && paramD.result == "success") {
4549 return paramD;
4550 } else {
4551 return errUnknownObj;
4552 }
4553 }
4554 }
4555 function getManualOTAUpdateSetting() {
4556 return stuffMake(arguments, {}, prepare, deal, null, false);
4557 function prepare(values, isPost) {
4558 var valueReq = {};
4559 valueReq.cmd = "fota_manualUpgradeURL";
4560 valueReq.multi_data = 1;
4561 return valueReq;
4562 }
4563 function deal(paramD) {
4564 if (paramD) {
4565 return {
4566 updateURL: paramD.fota_manualUpgradeURL
4567 };
4568 } else {
4569 return errUnknownObj;
4570 }
4571 }
4572 }
4573 function setManualOTAUpdateSetting() {
4574 return stuffMake(arguments, {}, prepare, deal, null, true);
4575 function prepare(values, isPost) {
4576 var valueReq = {};
4577 valueReq.goformId = "SetUpgManualSetting";
4578 valueReq.UpgURL = values.updateURL;
4579 return valueReq;
4580 }
4581 function deal(paramD) {
4582 if (paramD && paramD.result == "success") {
4583 return paramD;
4584 } else {
4585 return errUnknownObj;
4586 }
4587 }
4588 }
w.deng5fb68452025-02-10 17:07:51 +08004589
4590 function setWefotaOTAUpdateSetting() {
4591 return stuffMake(arguments, {}, prepare, deal, null, true);
4592 function prepare(values, isPost) {
4593 var valueReq = {};
4594 valueReq.goformId = "SetUpgWefotaSetting";
4595 return valueReq;
4596 }
4597 function deal(paramD) {
4598 if (paramD && paramD.result == "success") {
4599 return paramD;
4600 } else {
4601 return errUnknownObj;
4602 }
4603 }
4604 }
4605
w.dengd463b342024-12-20 10:21:38 +08004606 function getOTAlastCheckTime() {
4607 return getParams({
4608 nv: ['dm_last_check_time']
4609 }, arguments[1], arguments[2]);
4610 }
4611 function getSignalStrength() {
4612 return getParams({
4613 nv: ['network_type', 'sub_network_type', 'rssi', 'rscp', 'lte_rsrp']
4614 }, arguments[1], arguments[2]);
4615 }
4616 function clearUpdateResult() {
4617 return stuffMake(arguments, {}, prepare, deal, null, true);
4618 function prepare(values, isPost) {
4619 var valueReq = {};
4620 valueReq.goformId = "RESULT_RESTORE";
4621 return valueReq;
4622 }
4623 function deal(paramD) {
4624 if (paramD && paramD.result == "success") {
4625 return paramD;
4626 } else {
4627 return errUnknownObj;
4628 }
4629 }
4630 }
4631 function childGroupList() {
4632 return stuffMake(arguments, {}, prepare, deal, null, false);
4633 function prepare(values, isPost) {
4634 var valueReq = {
4635 cmd: "childGroupList"
4636 };
4637 return valueReq;
4638 }
4639 function deal(paramD) {
4640 if (paramD && (paramD.childGroupList || paramD.devices)) {
4641 return paramD;
4642 } else {
4643 return {
4644 devices: []
4645 };
4646 }
4647 }
4648 }
4649 function addChildGroup() {
4650 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4651 : {
4652 errorType: 'no_auth'
4653 }, prepare, deal, null, true);
4654 function prepare(values, isPost) {
4655 var valueReq = {
4656 goformId: "ADD_DEVICE",
4657 mac: values.macAddress
4658 };
4659 return valueReq;
4660 }
4661 function deal(paramD) {
4662 if (paramD && paramD.result == 'success') {
4663 return paramD;
4664 } else {
4665 return errUnknownObj;
4666 }
4667 }
4668 }
4669 function removeChildGroup() {
4670 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4671 : {
4672 errorType: 'no_auth'
4673 }, prepare, deal, null, true);
4674 function prepare(values, isPost) {
4675 var valueReq = {
4676 goformId: "DEL_DEVICE",
4677 mac: values.mac
4678 };
4679 return valueReq;
4680 }
4681 function deal(paramD) {
4682 if (paramD && paramD.result == 'success') {
4683 return paramD;
4684 } else {
4685 return errUnknownObj;
4686 }
4687 }
4688 }
4689 function checkCurrentUserInChildGroup(devices) {
4690 if (typeof config.currentUserInChildGroup == "undefined") {
4691 var childGroupDevice = [];
4692 if (typeof devices != "undefined") {
4693 childGroupDevice = devices;
4694 } else {
4695 childGroupDevice = childGroupList({}).devices;
4696 }
4697 var userMacAddr = getUserMacAddr({}).get_user_mac_addr;
4698 var found = _.find(childGroupDevice, function (item) {
4699 return item.mac == userMacAddr;
4700 });
4701 config.currentUserInChildGroup = typeof found != 'undefined';
4702 return {
4703 result: typeof found != 'undefined'
4704 };
4705 }
4706 return {
4707 result: config.currentUserInChildGroup
4708 };
4709 }
4710 function getUserMacAddr() {
4711 return getParams({
4712 nv: 'get_user_mac_addr'
4713 }, arguments[1], arguments[2]);
4714 }
4715 function getHostNameList() {
4716 return stuffMake(arguments, {}, prepare, deal, null, false);
4717 function prepare(values, isPost) {
4718 var valueReq = {
4719 cmd: "hostNameList"
4720 };
4721 return valueReq;
4722 }
4723 function deal(paramD) {
4724 if (paramD && (paramD.hostNameList || paramD.devices)) {
4725 return paramD;
4726 } else {
4727 return {
4728 devices: []
4729 };
4730 }
4731 }
4732 }
4733 function editHostName() {
4734 return stuffMake(arguments, {}, prepare, deal, null, true);
4735 function prepare(values, isPost) {
4736 var valueReq = {
4737 goformId: "EDIT_HOSTNAME",
4738 mac: values.mac,
4739 hostname: values.hostname
4740 };
4741 return valueReq;
4742 }
4743 function deal(paramD) {
4744 if (paramD && paramD.result == 'success') {
4745 return paramD;
4746 } else {
4747 return errUnknownObj;
4748 }
4749 }
4750 }
4751 function getSiteWhiteList() {
4752 return stuffMake(arguments, {}, prepare, deal, null, false);
4753 function prepare(values, isPost) {
4754 var valueReq = {
4755 cmd: "site_white_list"
4756 };
4757 return valueReq;
4758 }
4759 function deal(paramD) {
4760 if (paramD && (paramD.site_white_list || paramD.siteList)) {
4761 return paramD;
4762 } else {
4763 return {
4764 siteList: []
4765 };
4766 }
4767 }
4768 }
4769 function removeSiteWhite() {
4770 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4771 : {
4772 errorType: 'no_auth'
4773 }, prepare, deal, null, true);
4774 function prepare(values, isPost) {
4775 var valueReq = {
4776 goformId: "REMOVE_WHITE_SITE",
4777 ids: values.ids.join(',')
4778 };
4779 return valueReq;
4780 }
4781 function deal(paramD) {
4782 if (paramD && paramD.result == 'success') {
4783 return paramD;
4784 } else {
4785 return errUnknownObj;
4786 }
4787 }
4788 }
4789 function saveSiteWhite() {
4790 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4791 : {
4792 errorType: 'no_auth'
4793 }, prepare, deal, null, true);
4794 function prepare(values, isPost) {
4795 var valueReq = {
4796 goformId: "ADD_WHITE_SITE",
4797 name: values.name,
4798 site: values.site
4799 };
4800 return valueReq;
4801 }
4802 function deal(paramD) {
4803 if (paramD && paramD.result == 'success') {
4804 return paramD;
4805 } else {
4806 return errUnknownObj;
4807 }
4808 }
4809 }
4810 function getTimeLimited() {
4811 var defaultResult = {
4812 '0': [],
4813 '1': [],
4814 '2': [],
4815 '3': [],
4816 '4': [],
4817 '5': [],
4818 '6': []
4819 };
4820 return stuffMake(arguments, {}, prepare, deal, null, false);
4821 function prepare(values, isPost) {
4822 var valueReq = {
4823 cmd: "time_limited"
4824 };
4825 return valueReq;
4826 }
4827 function deal(paramD) {
4828 if (paramD) {
4829 return parseTimeLimited(paramD);
4830 } else {
4831 return defaultResult;
4832 }
4833 }
4834 function parseTimeLimited(paramD) {
4835 if (paramD.time_limited == '') {
4836 return {
4837 time_limited: []
4838 };
4839 }
4840 var weeks = paramD.time_limited.split(';');
4841 _.each(weeks, function (week) {
4842 var weekTime = week.split('+');
4843 if (weekTime.length == 2) {
4844 defaultResult[weekTime[0]] = weekTime[1].split(',');
4845 }
4846 });
4847 return defaultResult;
4848 }
4849 }
4850 function saveTimeLimited() {
4851 return stuffMake(arguments, config.currentUserInChildGroup == false ? {}
4852 : {
4853 errorType: 'no_auth'
4854 }, prepare, deal, null, true);
4855 function prepare(values, isPost) {
4856 var valueReq = {
4857 goformId: "SAVE_TIME_LIMITED",
4858 time_limited: values.time
4859 };
4860 return valueReq;
4861 }
4862 function deal(paramD) {
4863 if (paramD && paramD.result == 'success') {
4864 return paramD;
4865 } else {
4866 return errUnknownObj;
4867 }
4868 }
4869 }
4870 function getTsw() {
4871 return stuffMake(arguments, {}, prepare, deal, null, false);
4872 function prepare(values, isPost) {
4873 var valueReq = {
4874 cmd: "openEnable,closeEnable,openTime,closeTime",
4875 multi_data: '1'
4876 };
4877 return valueReq;
4878 }
4879 function deal(paramD) {
4880 if (paramD) {
4881 if (paramD.openTime.indexOf(':') != -1) {
4882 var open = paramD.openTime.split(':');
4883 paramD.openH = leftInsert(open[0], 2, '0');
4884 paramD.openM = leftInsert(open[1], 2, '0');
4885 } else {
4886 paramD.openH = '06';
4887 paramD.openM = '00';
4888 }
4889 if (paramD.closeTime.indexOf(':') != -1) {
4890 var close = paramD.closeTime.split(':');
4891 paramD.closeH = leftInsert(close[0], 2, '0');
4892 paramD.closeM = leftInsert(close[1], 2, '0');
4893 } else {
4894 paramD.closeH = '22';
4895 paramD.closeM = '00';
4896 }
4897 return paramD;
4898 } else {
4899 return errUnknownObj;
4900 }
4901 }
4902 }
4903 function saveTsw() {
4904 return stuffMake(arguments, {}, prepare, deal, null, true);
4905 function prepare(values, isPost) {
4906 var valueReq = {
4907 goformId: "SAVE_TSW",
4908 openEnable: values.openEnable,
4909 closeEnable: values.closeEnable
4910 };
4911 if (values.openEnable == '1') {
4912 valueReq.openTime = values.openTime;
4913 valueReq.closeTime = values.closeTime;
4914 }
4915 return valueReq;
4916 }
4917 function deal(paramD) {
4918 if (paramD && paramD.result == 'success') {
4919 return paramD;
4920 } else if (paramD && paramD.result == 'failure') {
4921 return paramD;
4922 } else {
4923 return errUnknownObj;
4924 }
4925 }
4926 }
4927 function trafficCalibration() {
4928 return stuffMake(arguments, {}, prepare, deal, null, true);
4929 function prepare(values, isPost) {
4930 var valueReq = {
4931 goformId: "FLOW_CALIBRATION_MANUAL",
4932 calibration_way: values.way,
4933 time: values.way == 'time' ? values.value : 0,
4934 data: values.way == 'data' ? values.value : 0
4935 };
4936 return valueReq;
4937 }
4938 function deal(paramD) {
4939 if (paramD && paramD.result == 'success') {
4940 return paramD;
4941 } else {
4942 return errUnknownObj;
4943 }
4944 }
4945 }
4946 function getParams() {
4947 return stuffMake(arguments, {}, prepare, deal, null, false);
4948 function prepare(values, isPost) {
4949 var valueReq = {};
4950 if (_.isArray(values.nv)) {
4951 valueReq.cmd = values.nv.join(',');
4952 valueReq.multi_data = 1;
4953 } else {
4954 valueReq.cmd = values.nv;
4955 }
4956 return valueReq;
4957 }
4958 function deal(paramD) {
4959 if (paramD) {
4960 return paramD;
4961 } else {
4962 return errUnknownObj;
4963 }
4964 }
4965 }
4966 function getRedirectData() {
4967 return stuffMake(arguments, {}, prepare, deal, null, false);
4968 function prepare(values, isPost) {
4969 var valueReq = {};
4970 valueReq.cmd = "vwim_mc_state,traffic_overrun,detect_new_version";
4971 valueReq.multi_data = 1;
4972 return valueReq;
4973 }
4974 function deal(paramD) {
4975 if (paramD) {
4976 var result = {};
4977 result.vwim_mc_state = paramD.vwim_mc_state;
4978 result.traffic_overrun = paramD.traffic_overrun;
4979 result.detect_new_version = paramD.detect_new_version;
4980 result.blc_wan_mode = informationAll.blc_wan_mode;
4981 return result;
4982 } else {
4983 return errUnknownObj;
4984 }
4985 }
4986 }
4987 function clearRedirectFlag() {
4988 return stuffMake(arguments, {}, prepare, deal, null, true);
4989 function prepare(values, isPost) {
4990 var valueReq = {};
4991 valueReq.goformId = "CLEAR_REDIRECT_FLAG";
4992 valueReq.flag_id = values.redirectFlags;
4993 return valueReq;
4994 }
4995 function deal(paramD) {
4996 if (paramD) {
4997 return paramD;
4998 } else {
4999 return errUnknownObj;
5000 }
5001 }
5002 }
5003 function getV4Switch() {
5004 return stuffMake(arguments, {}, prepare, deal, null, false);
5005 function prepare(values, isPost) {
5006 var valueReq = {};
5007 valueReq.cmd = "lock_zone_enable,pin_interlock_and_V4_lock";
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 setV4Switch() {
5020 return stuffMake(arguments, {}, prepare, deal, null, true);
5021 function prepare(values, isPost) {
5022 var valueReq = {};
5023 valueReq.goformId = "PIN_LOCK_V4_ENCODE";
5024 valueReq.pin_interlock_and_V4_lock = values.pin_interlock_and_V4_lock;
5025 valueReq.TspLock_key_data = values.TspLock_key_data;
5026 return valueReq;
5027 }
5028 function deal(paramD) {
5029 if (paramD && paramD.result == "success") {
5030 return paramD;
5031 } else {
5032 return errUnknownObj;
5033 }
5034 }
5035 }
5036 function getCellId() {
5037 return stuffMake(arguments, {}, prepare, deal, null, false);
5038 function prepare(values, isPost) {
5039 var valueReq = {};
5040 valueReq.cmd = "cell_id_list,global_cell_id,network_type,sub_network_type,cell_not_correct";
5041 valueReq.multi_data = 1;
5042 return valueReq;
5043 }
5044 function deal(paramD) {
5045 if (paramD) {
5046 return paramD;
5047 } else {
5048 return errUnknownObj;
5049 }
5050 }
5051 }
5052 function setCellIdSwitch() {
5053 return stuffMake(arguments, {}, prepare, deal, null, true);
5054 function prepare(values, isPost) {
5055 var valueReq = {};
5056 valueReq.goformId = "LOCK_ZONE";
5057 valueReq.lock_zone_enable = values.lock_zone_enable;
5058 return valueReq;
5059 }
5060 function deal(paramD) {
5061 if (paramD && paramD.result == "success") {
5062 return paramD;
5063 } else {
5064 return errUnknownObj;
5065 }
5066 }
5067 }
5068 function getUpdateType() {
5069 return stuffMake(arguments, {}, prepare, deal, null, false);
5070 function prepare(values, isPost) {
5071 var valueReq = {
5072 cmd: "update_type"
5073 };
5074 return valueReq;
5075 }
5076 function deal(paramD) {
5077 return {
5078 update_type: paramD.update_type ? paramD.update_type : "mifi_fota"
5079 }
5080 }
5081 }
5082 function getSecurityInfo() {
5083 return stuffMake(arguments, {}, prepare, deal, null, false);
5084 function prepare(values, isPost) {
5085 var valueReq = {};
5086 valueReq.cmd = "AuthMode,passPhrase";
5087 valueReq.multi_data = 1;
5088 return valueReq;
5089 }
5090 function deal(paramD) {
5091 if (paramD) {
5092 var result = {};
5093 result.AuthMode = paramD.AuthMode;
5094 result.passPhrase = config.PASSWORD_ENCODE ? Base64.decode(paramD.passPhrase) : paramD.passPhrase;
5095 return result;
5096 } else {
5097 return errUnknownObj;
5098 }
5099 }
5100 }
5101 //can delete
5102 function setSecurityInfo() {
5103 return stuffMake(arguments, {}, prepare, deal, null, true);
5104 function prepare(values, isPost) {
5105 var valueReq = {};
5106 valueReq.goformId = "SET_WIFI_SECURITY_INFO";
5107 valueReq.AuthMode = values.AuthMode;
5108 if (valueReq.AuthMode == "WPAPSKWPA2PSK") {
5109 valueReq.passPhrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;
5110 }
5111 return valueReq;
5112 }
5113 function deal(paramD) {
5114 if (paramD) {
5115 return paramD;
5116 } else {
5117 return errUnknownObj;
5118 }
5119 }
5120 }
5121 function setWifiBasic() {
5122 stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
5123 function prepare(values) {
5124 var valueReq = {
5125 goformId: "SET_WIFI_SSID1_SETTINGS",
5126 ssid: values.SSID,
5127 broadcastSsidEnabled: values.broadcast,
5128 MAX_Access_num: values.station,
5129 security_mode: values.AuthMode,
5130 cipher: values.cipher,
5131 NoForwarding: values.NoForwarding,
5132 show_qrcode_flag: values.show_qrcode_flag
5133 };
5134 if (config.WIFI_WEP_SUPPORT) {
5135 valueReq.wep_default_key = values.wep_default_key;
5136 valueReq.wep_key_1 = values.wep_key_1;
5137 valueReq.wep_key_2 = values.wep_key_2;
5138 valueReq.wep_key_3 = values.wep_key_3;
5139 valueReq.wep_key_4 = values.wep_key_4;
5140 if (values.wep_default_key == '1') {
5141 valueReq.WEP2Select = values.WEP2Select;
5142 } else if (values.wep_default_key == '2') {
5143 valueReq.WEP3Select = values.WEP3Select;
5144 } else if (values.wep_default_key == '3') {
5145 valueReq.WEP4Select = values.WEP4Select;
5146 } else {
5147 valueReq.WEP1Select = values.WEP1Select;
5148 }
5149 }
5150 if (values.AuthMode == "WPAPSK" || values.AuthMode == "WPA2PSK" || values.AuthMode == "WPAPSKWPA2PSK" || values.AuthMode == "WPA3Personal" || values.AuthMode == "WPA2WPA3") {
5151 valueReq.security_shared_mode = values.cipher;
5152 valueReq.passphrase = config.PASSWORD_ENCODE ? Base64.encode(values.passPhrase) : values.passPhrase;
5153 } else if (values.AuthMode == "SHARED") {
5154 valueReq.security_shared_mode = "WEP";
5155 valueReq.security_mode = "SHARED";
5156 } else {
5157 if (values.encryptType == "WEP") {
5158 valueReq.security_shared_mode = "WEP";
5159 valueReq.security_mode = "OPEN";
5160 } else {
5161 valueReq.security_shared_mode = "NONE";
5162 }
5163 }
5164 return valueReq;
5165 }
5166 function deal(paramD) {
5167 if (paramD) {
5168 return paramD;
5169 } else {
5170 return errUnknownObj;
5171 }
5172 }
5173 }
5174 function setWifiBasic4SSID2() {
5175 stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
5176 function prepare(values) {
5177 var valueReq = {
5178 goformId: "SET_WIFI_SSID2_SETTINGS",
5179 m_SSID: values.m_SSID,
5180 m_HideSSID: values.m_broadcast,
5181 m_MAX_Access_num: values.m_station,
5182 m_AuthMode: values.m_AuthMode,
5183 cipher: values.m_cipher,
5184 m_NoForwarding: values.m_NoForwarding,
5185 m_show_qrcode_flag: values.m_show_qrcode_flag
5186 };
5187 if (config.WIFI_WEP_SUPPORT) {
5188 valueReq.m_DefaultKeyID = values.m_wep_default_key;
5189 valueReq.m_Key1Str1 = values.m_wep_key_1;
5190 valueReq.m_Key2Str1 = values.m_wep_key_2;
5191 valueReq.m_Key3Str1 = values.m_wep_key_3;
5192 valueReq.m_Key4Str1 = values.m_wep_key_4;
5193 if (values.m_wep_default_key == '1') {
5194 valueReq.m_Key2Type = values.m_WEP2Select;
5195 } else if (values.m_wep_default_key == '2') {
5196 valueReq.m_Key3Type = values.m_WEP3Select;
5197 } else if (values.m_wep_default_key == '3') {
5198 valueReq.m_Key4Type = values.m_WEP4Select;
5199 } else {
5200 valueReq.m_Key1Type = values.m_WEP1Select;
5201 }
5202 }
5203 if (values.m_AuthMode == "WPAPSK" || values.m_AuthMode == "WPA2PSK" || values.m_AuthMode == "WPAPSKWPA2PSK" || values.m_AuthMode == "WPA3Personal" || values.m_AuthMode == "WPA2WPA3") {
5204 valueReq.m_EncrypType = values.m_cipher;
5205 valueReq.m_WPAPSK1 = config.PASSWORD_ENCODE ? Base64.encode(values.m_passPhrase) : values.m_passPhrase;
5206 } else if (values.m_AuthMode == "SHARED") {
5207 valueReq.m_EncrypType = "WEP";
5208 valueReq.m_security_mode = "SHARED";
5209 } else {
5210 if (values.m_encryptType == "WEP") {
5211 valueReq.m_EncrypType = "WEP";
5212 valueReq.m_security_mode = "OPEN";
5213 } else {
5214 valueReq.m_EncrypType = "NONE";
5215 }
5216 }
5217 return valueReq;
5218 }
5219 function deal(paramD) {
5220 if (paramD) {
5221 return paramD;
5222 } else {
5223 return errUnknownObj;
5224 }
5225 }
5226 }
5227 function getWifiBasic() {
5228 return stuffMake(arguments, {}, prepare, deal, null, false);
5229 function prepare(values, isPost) {
5230 var valueReq = {};
5231 var wpapsk = config.PASSWORD_ENCODE ? "WPAPSK1_encode,m_WPAPSK1_encode," : "imei,rnum_js,WPAPSK1_enaes,m_WPAPSK1_enaes,";
5232 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";
5233 valueReq.multi_data = 1;
5234 return valueReq;
5235 }
5236 function deal(paramD) {
5237 if (paramD) {
5238 var result = {
5239 wifi_enable: paramD.wifi_cur_state == "1" ? "1" : "0",
5240 multi_ssid_enable: paramD.m_ssid_enable,
5241 MAX_Station_num: $.isNumeric(paramD.MAX_Station_num) ? paramD.MAX_Station_num : config.MAX_STATION_NUMBER,
5242 AuthMode: paramD.AuthMode,
5243 SSID: paramD.SSID1,
5244 broadcast: paramD.HideSSID,
5245 apIsolation: paramD.NoForwarding,
5246 passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.WPAPSK1_enaes),
5247 MAX_Access_num: paramD.MAX_Access_num,
5248 cipher: paramD.EncrypType == "TKIP" ? "0" : paramD.EncrypType == "AES" ? 1 : 2,
5249 encryptType: paramD.EncrypType,
5250 show_qrcode_flag: paramD.show_qrcode_flag == "1" ? true : false,
5251 keyID: paramD.DefaultKeyID,
5252 Key1Str1: paramD.Key1Str1,
5253 Key2Str1: paramD.Key2Str1,
5254 Key3Str1: paramD.Key3Str1,
5255 Key4Str1: paramD.Key4Str1,
5256 m_SSID: paramD.m_SSID,
5257 m_broadcast: paramD.m_HideSSID,
5258 m_apIsolation: paramD.m_NoForwarding,
5259 m_MAX_Access_num: paramD.m_MAX_Access_num,
5260 m_AuthMode: paramD.m_AuthMode,
5261 m_passPhrase: config.PASSWORD_ENCODE ? Base64.decode(paramD.m_WPAPSK1_encode) : wifiDecode(paramD.rnum_js,paramD.imei,paramD.m_WPAPSK1_enaes),
5262 m_cipher: paramD.m_EncrypType == "TKIP" ? "0" : paramD.m_EncrypType == "AES" ? 1 : 2,
5263 m_show_qrcode_flag: paramD.m_show_qrcode_flag == "1" ? true : false,
5264 m_encryptType: paramD.m_EncrypType,
5265 m_keyID: paramD.m_DefaultKeyID,
5266 m_Key1Str1: paramD.m_Key1Str1,
5267 m_Key2Str1: paramD.m_Key2Str1,
5268 m_Key3Str1: paramD.m_Key3Str1,
5269 m_Key4Str1: paramD.m_Key4Str1,
5270 rotationFlag: paramD.rotationFlag,
5271 ap_station_enable: paramD.wifi_sta_connection
5272 };
5273 return result;
5274 } else {
5275 return errUnknownObj;
5276 }
5277 }
5278 }
5279 function setWifiBasicMultiSSIDSwitch() {
5280 stuffMakeAndCheckServerIsOnline(arguments, prepare, deal);
5281 function prepare(values) {
5282 var paraTemp = values;
5283 if (values.wifiEnabled == '0') {
5284 paraTemp = {
5285 wifiEnabled: values.wifiEnabled
5286 }
5287 }
5288 var valueReq = $.extend({
5289 goformId: "SET_WIFI_INFO",
5290 }, paraTemp);
5291 return valueReq;
5292 }
5293 function deal(paramD) {
5294 if (paramD) {
5295 return paramD;
5296 } else {
5297 return errUnknownObj;
5298 }
5299 }
5300 }
5301 function stuffMake(array, result, prepare, dealMethod, errorObject, isPost) {
5302 var values = array[0],
5303 callback = array[1],
5304 errorCallback = array[2];
5305 var objectToReturn;
5306 if (result && typeof result.errorType === 'string') {
5307 objectToReturn = $.extend(errUnknownObj, result);
5308 if (!callback) {
5309 return objectToReturn;
5310 }
5311 doCallback(objectToReturn, callback, errorCallback);
5312 } else {
5313 objectToReturn = $.extend({}, result);
5314 var valueReq;
5315 if (prepare) {
5316 valueReq = prepare(values, isPost);
5317 } else {
5318 valueReq = values;
5319 }
5320 if (!callback) {
5321 if (valueReq && (valueReq.cmd || valueReq.goformId)) {
5322 var r = reqSync(valueReq, isPost);
5323 if (dealMethod) {
5324 objectToReturn = $.extend({}, dealMethod(r));
5325 } else {
5326 objectToReturn = r;
5327 }
5328 }
5329 return objectToReturn;
5330 } else {
5331 if (valueReq && (valueReq.cmd || valueReq.goformId)) {
5332 reqAsync(valueReq, function (paramD) {
5333 if (dealMethod) {
5334 objectToReturn = $.extend({}, dealMethod(paramD));
5335 } else {
5336 objectToReturn = $.extend({}, paramD);
5337 }
5338 if (!valueReq.notCallback) {
5339 doCallback(objectToReturn, callback, errorCallback);
5340 }
5341 }, function () {
5342 if (errorObject) {
5343 objectToReturn = $.extend(errUnknownObj, errorObject);
5344 } else {
5345 objectToReturn = $.extend(errUnknownObj, {
5346 errorType: 'Unknown'
5347 });
5348 }
5349 doCallback(objectToReturn, callback, errorCallback);
5350 }, isPost);
5351 } else {
5352 doCallback(objectToReturn, callback, errorCallback);
5353 }
5354 }
5355 }
5356 function doCallback(resultToReturn, callback, errorCallback) {
5357 errorCallback = errorCallback ? errorCallback : callback;
5358 if (isErrorObject(resultToReturn)) {
5359 switch (resultToReturn.errorType) {
5360 case 'cellularNetworkError':
5361 case 'deviceError':
5362 case 'wifiConnectionError':
5363 window.receivedNonSpecificError(resultToReturn);
5364 break;
5365 default:
5366 errorCallback(resultToReturn);
5367 }
5368 } else {
5369 callback(resultToReturn);
5370 }
5371 }
5372 }
5373 function reqSync(values, isPost) {
5374 return reqAJAX(values, null, null, false, isPost);
5375 }
5376 function reqAsync(values, successCallback, errorCallback, isPost) {
5377 reqAJAX(values, successCallback, errorCallback, true, isPost);
5378 }
5379 function getString(values){
5380 var regexp = /^[A-z0-9]+$/;
5381 var matches = values.match(regexp);
5382 if (matches == null){
5383 return "error";
5384 } else {
5385 return values;
5386 }
5387 }
5388 function reqAJAX(values, successCallback, errorCallback, async, isPost) {
5389 var result = null;
5390 $.ajax({
5391 type: !!isPost ? "POST" : "GET",
5392 url: isPost ? "/reqproc/proc_post" : values.cmd ? "/reqproc/proc_get" : "/reqproc/proc_post",
5393 data: values,
5394 dataType: "json",
5395 async: !!async,
5396 cache: false,
5397 error: function (paramD) {
5398 if (async) {
5399 errorCallback(paramD);
5400 } else if (paramD.status == 200) {
5401 result = jQuery.parseJSON('(' + getString(paramD.responseText) + ')');
5402 }
5403 },
5404 success: function (paramD) {
5405 if (async) {
5406 successCallback(paramD);
5407 } else {
5408 result = paramD;
5409 }
5410 }
5411 });
5412 if (!async) {
5413 return result;
5414 }
5415 }
5416 var informationAll = {
5417 networkType: "",
5418 signalImg: "0",
5419 spn_b1_flag: "1",
5420 spn_name_data: "",
5421 spn_b2_flag: "1",
5422 networkOperator: "China Mobile",
5423 connectStatus: "ppp_disconnected",
5424 rj45ConnectStatus: "rj45_dead",
5425 attachedDevices: [],
5426 ssid1AttachedNum: 0,
5427 ssid2AttachedNum: 0,
5428 data_counter: {
5429 uploadRate: 0,
5430 downloadRate: 0,
5431 totalSent: 0,
5432 totalReceived: 0,
5433 totalConnectedTime: 0,
5434 currentSent: 0,
5435 currentReceived: 0,
5436 currentConnectedTime: 0,
5437 monthlySent: 0,
5438 monthlyReceived: 0,
5439 monthlyConnectedTime: 0,
5440 month: ''
5441 },
5442 newSmsReceived: false,
5443 smsReportReceived: false,
5444 smsUnreadCount: "0",
5445 isLoggedIn: undefined,
5446 limitVolumeEnable: false,
5447 limitVolumeType: '1',
5448 limitVolumePercent: "100",
5449 limitVolumeSize: "0",
5450 allowRoamingUpdate: "0",
5451 blc_wan_mode: "",
5452 ap_station_enable: undefined,
5453 ap_station_mode: undefined,
5454 dialMode: '',
5455 ethWanMode: 'AUTO',
5456 fota_user_selector: '',
5457 defaultWanName: ""
5458 };
5459 var errUnknownObj = {
5460 errorType: 'UnknownError',
5461 errorId: '123',
5462 errorText: 'UnknownError'
5463 };
5464 var updateTimerFlag = true;
5465 return {
5466 clearRedirectFlag: clearRedirectFlag,
5467 connect: connect,
5468 disconnect: disconnect,
5469 getSIMPhoneBookCapacity: getSIMPhoneBookCapacity,
5470 getDevicePhoneBookCapacity: getDevicePhoneBookCapacity,
5471 getDevicePhoneBooks: getDevicePhoneBooks,
5472 getSIMPhoneBooks: getSIMPhoneBooks,
5473 getPhoneBooks: getPhoneBooks,
5474 getPhoneBookReady: getPhoneBookReady,
5475 getPhoneBooksByGroup: getPhoneBooksByGroup,
5476 deletePhoneBooks: deletePhoneBooks,
5477 deleteAllPhoneBooks: deleteAllPhoneBooks,
5478 deleteAllPhoneBooksByGroup: deleteAllPhoneBooksByGroup,
5479 savePhoneBook: savePhoneBook,
5480 deleteAllMessages: deleteAllMessages,
5481 deleteMessage: deleteMessage,
5482 setSmsRead: setSmsRead,
5483 sendSMS: sendSMS,
5484 saveSMS: saveSMS,
5485 getSMSReady: getSMSReady,
5486 getSMSMessages: getSMSMessages,
5487 getSMSDeliveryReport: getSMSDeliveryReport,
5488 getSmsCapability: getSmsCapability,
5489 resetNewSmsReceivedVar: resetNewSmsReceivedVar,
5490 resetSmsReportReceivedVar: resetSmsReportReceivedVar,
5491 getSmsSetting: getSmsSetting,
5492 setSmsSetting: setSmsSetting,
5493 getAttachedCableDevices: getAttachedCableDevices,
5494 getCurrentlyAttachedDevicesInfo: getCurrentlyAttachedDevicesInfo,
5495 getConnectionInfo: getConnectionInfo,
5496 getRedirectData: getRedirectData,
5497 getLanguage: getLanguage,
5498 setLanguage: setLanguage,
5499 getNetSelectInfo: getNetSelectInfo,
5500 getSecurityInfo: getSecurityInfo,
5501 setSecurityInfo: setSecurityInfo,
5502 getStatusInfo: getStatusInfo,
5503 getConnectionMode: getConnectionMode,
5504 setConnectionMode: setConnectionMode,
5505 getWifiBasic: getWifiBasic,
5506 setWifiBasic: setWifiBasic,
5507 setWifiBasic4SSID2: setWifiBasic4SSID2,
5508 setWifiBasicMultiSSIDSwitch: setWifiBasicMultiSSIDSwitch,
5509 getWpsInfo: getWpsInfo,
5510 openWps: openWps,
5511 getSleepMode: getSleepMode,
5512 setSleepMode: setSleepMode,
5513 getWifiAdvance: getWifiAdvance,
5514 setWifiAdvance: setWifiAdvance,
5515 getWifiRange: getWifiRange,
5516 setWifiRange: setWifiRange,
5517
5518 getLoginStatus: getLoginStatus,
5519 getLoginData: getLoginData,
5520 login: login,
5521 logout: logout,
5522 changeManageInfo: changeManageInfo,
5523 getPinData: getPinData,
5524 enablePin: enablePin,
5525 disablePin: disablePin,
5526 changePin: changePin,
5527 enterPIN: enterPIN,
5528 enterPUK: enterPUK,
5529 getLanInfo: getLanInfo,
5530 setLanInfo: setLanInfo,
5531 getApnSettings: getApnSettings,
mj.qu28df13a2025-01-07 19:14:21 -08005532 getNetworkStatus: getNetworkStatus,
w.dengd463b342024-12-20 10:21:38 +08005533 deleteApn: deleteApn,
5534 setDefaultApn: setDefaultApn,
5535 addOrEditApn: addOrEditApn,
5536 getQuickSettingInfo: getQuickSettingInfo,
5537 setQuickSetting4IPv6: setQuickSetting4IPv6,
5538 scanForNetwork: scanForNetwork,
5539 setBearerPreference: setBearerPreference,
5540 editHostName: editHostName,
5541 getSiteWhiteList: getSiteWhiteList,
5542 removeSiteWhite: removeSiteWhite,
5543 saveSiteWhite: saveSiteWhite,
5544 setNetwork: setNetwork,
5545 getUpnpSetting: getUpnpSetting,
5546 setUpnpSetting: setUpnpSetting,
5547 getDmzSetting: getDmzSetting,
5548 setDmzSetting: setDmzSetting,
5549 getDeviceInfo: getDeviceInfo,
5550 getDeviceInfoLow: getDeviceInfoLow,
5551 getPortForward: getPortForward,
5552 setPortForward: setPortForward,
5553 getPortFilter: getPortFilter,
5554 setPortFilterBasic: setPortFilterBasic,
5555 setPortFilter: setPortFilter,
5556 deleteFilterRules: deleteFilterRules,
5557 getPortMap: getPortMap,
5558 setPortMap: setPortMap,
5559 enablePortMap: enablePortMap,
5560 deleteMapRules: deleteMapRules,
5561 getTrafficAlertInfo: getTrafficAlertInfo,
5562 setTrafficAlertInfo: setTrafficAlertInfo,
5563 getCurrentUpgradeState: getCurrentUpgradeState,
5564 setUpgradeSelectOp: setUpgradeSelectOp,
5565 addTimerThings: addTimerSomething,
5566 removeTimerThings: removeTimerSomething,
5567 getPackSizeInfo: getPackSizeInfo,
5568 getMandatory: getMandatory,
5569 getOTAUpdateSetting: getOTAUpdateSetting,
5570 setOTAUpdateSetting: setOTAUpdateSetting,
5571 getManualOTAUpdateSetting: getManualOTAUpdateSetting,
5572 setManualOTAUpdateSetting: setManualOTAUpdateSetting,
w.deng5fb68452025-02-10 17:07:51 +08005573 setWefotaOTAUpdateSetting: setWefotaOTAUpdateSetting,
w.dengd463b342024-12-20 10:21:38 +08005574 getSignalStrength: getSignalStrength,
5575 getOTAlastCheckTime: getOTAlastCheckTime,
5576 clearUpdateResult: clearUpdateResult,
5577 refreshAPStationStatus: refreshAPStationStatus,
5578 getSntpParams: getSntpParams,
5579 setSntpSetting: setSntpSetting,
5580 setSNTPDate: setSNTPDate,
5581 restoreFactorySettings: restoreFactorySettings,
5582 checkRestoreStatus: checkRestoreStatus,
5583 getSysSecurity: getSysSecurity,
5584 setSysSecurity: setSysSecurity,
5585 deleteForwardRules: deleteForwardRules,
5586 enableVirtualServer: enableVirtualServer,
5587 getSDConfiguration: getSDConfiguration,
5588 setSdCardMode: setSdCardMode,
5589 checkFileExists: checkFileExists,
5590 getFileList: getFileList,
5591 fileRename: fileRename,
5592 getSdMemorySizes: getSdMemorySizes,
5593 deleteFilesAndFolders: deleteFilesAndFolders,
5594 createFolder: createFolder,
5595 setSdCardSharing: setSdCardSharing,
5596 setUpdateInfoWarning: setUpdateInfoWarning,
5597 getUpdateInfoWarning: getUpdateInfoWarning,
5598 getAPStationBasic: getAPStationBasic,
5599 setAPStationBasic: setAPStationBasic,
5600 getWdsInfo: getWdsInfo,
5601 setWDS: setWDS,
5602 addUrlFilterRule: addUrlFilterRule,
5603 getUrlFilterList: getUrlFilterList,
5604 deleteSelectedRules: deleteSelectedRules,
5605 getMacFilterInfo: getMacFilterInfo,
5606 setMacFilter: setMacFilter,
5607 getFastbootSetting: getFastbootSetting,
5608 setFastbootSetting: setFastbootSetting,
5609 turnOffDevice: turnOffDevice,
5610 restart: restart,
5611 getScheduleSetting: getScheduleSetting,
5612 setScheduleSetting: setScheduleSetting,
5613 getPingResult: getPingResult,
5614 pingResultClear: pingResultClear,
5615 getPingSetting: getPingSetting,
5616 setPingSettingStart: setPingSettingStart,
5617 updateTimerFlag: updateTimerFlag,
5618 childGroupList: childGroupList,
5619 addChildGroup: addChildGroup,
5620 removeChildGroup: removeChildGroup,
5621 checkCurrentUserInChildGroup: checkCurrentUserInChildGroup,
5622 getTimeLimited: getTimeLimited,
5623 saveTimeLimited: saveTimeLimited,
5624 getHostNameList: getHostNameList,
5625 getHotspotList: getHotspotList,
5626 searchHotspot: searchHotspot,
5627 getSearchHotspotList: getSearchHotspotList,
5628 saveHotspot: saveHotspot,
5629 deleteHotspot: deleteHotspot,
5630 connectHotspot: connectHotspot,
5631 disconnectHotspot: disconnectHotspot,
5632 getOpMode: getOpMode,
5633 getRj45PlugState: getRj45PlugState,
5634 SetOperationMode: SetOperationMode,
5635 getPppoeParams: getPppoeParams,
5636 setPppoeDialMode: setPppoeDialMode,
5637 getTsw: getTsw,
5638 saveTsw: saveTsw,
5639 trafficCalibration: trafficCalibration,
5640 getParams: getParams,
5641 getNewVersionState: getNewVersionState,
w.deng5fb68452025-02-10 17:07:51 +08005642 wefotagetNewVersionState: wefotagetNewVersionState,
w.dengd463b342024-12-20 10:21:38 +08005643 getUpgradeResult: getUpgradeResult,
5644 getV4Switch: getV4Switch,
5645 setV4Switch: setV4Switch,
5646 getCellId: getCellId,
5647 setCellIdSwitch: setCellIdSwitch,
5648 getDdnsParams: getDdnsParams,
5649 setDDNSForward: setDDNSForward,
5650 getUpdateType: getUpdateType,
5651 getCurretnMAC: getCurretnMAC,
5652 getUSSDResponse: getUSSDResponse,
5653 USSDReplyCancel: USSDReplyCancel,
5654 getNetworkUnlockTimes: getNetworkUnlockTimes,
5655 unlockNetwork: unlockNetwork,
5656 getSyslogInfo: getSyslogInfo,
5657 setSysLog: setSysLog,
5658 };
5659});
5660
5661 // Router����
5662
5663define("adm_lan","jquery knockout set service".split(" "),
5664
5665 function ($, ko, config, service) {
5666
5667 var originfrmLan = "";
5668
5669 // ��ȡ·������������Ϣ
5670 function getLanInfo() {
5671 return service.getLanInfo();
5672 }
5673
5674 function hex(val) {
5675 var h = (val - 0).toString(16);
5676 if (h.length == 1)
5677 h = '0' + h;
5678 return h.toUpperCase();
5679 }
5680
5681 function LanViewModel() {
5682 var target = this;
5683
5684 var info = getLanInfo();
5685
5686 target.dhcpStart = ko.observable(info.dhcpStart);
5687 target.dhcpEnd = ko.observable(info.dhcpEnd);
5688 target.dhcpLease = ko.observable(info.dhcpLease);
5689
5690 target.ipAddress = ko.observable(info.ipAddress);
5691 target.subnetMask = ko.observable(info.subnetMask);
5692 target.dhcpServer = ko.observable(info.dhcpServer);
5693
5694 target.macAddress = ko.observable(info.macAddress);
5695 target.showMacAddress = ko.observable(config.SHOW_MAC_ADDRESS);
5696
5697 target.hasWifi = ko.observable(config.HAS_WIFI);
5698 target.hasUssd = config.HAS_USSD;
5699 target.hasDdns = config.DDNS_SUPPORT;
5700
5701 target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
5702
5703 target.clear = function () {
5704 clearTimer();
5705 init();
5706 clearValidateMsg();
5707 };
5708
5709 target.refreshStatus = function () {
5710 var connInfo = service.getConnectionInfo();
5711 if (connInfo.connectStatus == 'ppp_disconnected') {
5712 $('input', '#frmLan').each(function () {
5713 $(this).attr("disabled", false);
5714 });
5715 } else {
5716 $('input', '#frmLan').each(function () {
5717 $(this).attr("disabled", true);
5718 });
5719
5720 clearValidateMsg();
5721 }
5722 };
5723
5724 // ������Ӧ�������������ñ���
5725 target.saveAct = function () {
5726 showLoading();
5727 var params = {
5728 ipAddress: target.ipAddress(),
5729 subnetMask: target.subnetMask(),
5730 dhcpServer: target.dhcpServer(),
5731 dhcpStart: target.dhcpStart(),
5732 dhcpEnd: target.dhcpEnd(),
5733 dhcpLease: target.dhcpLease()
5734 };
5735
5736 service.setLanInfo(params, function (result) {
5737 if (result.result == "success") {
5738 successOverlay();
5739 target.clear();
5740 } else {
5741 errorOverlay();
5742 }
5743 });
5744 };
5745
5746 // ������Ӧ�������������ñ���
5747 target.save = function () {
5748 var frmLanObj = $('#frmLan').serialize();
5749 if (frmLanObj == originfrmLan) {
5750 showAlert("setting_no_change");
5751 return false;
5752 }
5753 if (config.RJ45_SUPPORT) {
5754 var pppObj = service.getPppoeParams();
5755 if (sf_isValidate_StaticIP(pppObj.static_wan_ipaddr, target.ipAddress(), target.subnetMask())) {
5756 showAlert("lan_tip_staticip_notsame");
5757 return false;
5758 }
5759 }
5760 showConfirm("lan_confirm_reopen", function () {
5761 target.saveAct();
5762 });
5763 };
5764
5765 target.refreshStatus();
5766 // dhcpServer�л���Ӧ����
5767 target.dhcpServerHandler = function () {
5768 $("#txtIpAddress").parent().find(".error").hide();
5769 $("#txtIpAddress").show();
5770 return true;
5771 };
5772 addTimeout(function () {
5773 originfrmLan = $('#frmLan').serialize();
5774 }, 500);
5775 }
5776
5777
5778 function sf_opAnd4Byte(i_v1, i_v2) {
5779 var index;
5780 var var1 = [];
5781 var var2 = [];
5782 var result='0x';
5783
5784 for (index=2,index_tmp=0; index<10; index+=2,index_tmp++) {
5785 var1[index_tmp]='0x'+i_v1.substring(index,index+2);
5786 var2[index_tmp]='0x'+i_v2.substring(index,index+2);
5787 }
5788
5789 for (index=0; index<4; index++) {
5790 result = result + hex(var1[index]&var2[index]);
5791 }
5792
5793 return result - 0;
5794 }
5795
5796 // �������ر���У������
5797 $.validator.addMethod("dhcp_check", function (i_value, i_element, i_parameter) {
5798 var dhcpIp = i_parameter == "start" ? $('#txtDhcpIpPoolStart').val() : $('#txtDhcpIpPoolEnd').val();
5799 var result = sf_isValidate_Gateway($('#txtIpAddress').val(), $('#txtSubnetMask').val(), dhcpIp);
5800 return this.optional(i_element) || result;
5801 });
5802
5803 $.validator.addMethod("dhcpCompare", function (i_value, i_element, i_parameter) {
5804 var result;
5805 if(i_parameter == "#txtDhcpIpPoolStart") {
5806 result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), $(i_parameter).val(), i_value);
5807 }
5808 else {
5809 result = sf_isValidate_StartEndIp($('#txtIpAddress').val(), $('#txtSubnetMask').val(), i_value, $(i_parameter).val());
5810 }
5811 return result != 1;
5812 });
5813
5814 $.validator.addMethod("ipRange", function (i_value, i_element, i_parameter) {
5815 var DHCP_flag = false;
5816 if($('#dhcpEnable').is(':checked')){
5817 DHCP_flag = true;
5818 }
5819 var result = sf_isValidate_StartEndIp(i_value, $('#txtSubnetMask').val(), $('#txtDhcpIpPoolStart').val(), $('#txtDhcpIpPoolEnd').val(), DHCP_flag);
5820 return result != 2;
5821 });
5822
5823 $.validator.addMethod("subnetmask_check", function (i_value, i_element, i_parameter) {
5824 var result = sf_isValidate_Netmask(i_value);
5825 return this.optional(i_element) || result;
5826 });
5827
5828
5829 // ��̬��ЧIPУ�麯��
5830 function sf_isValidate_StaticIP(i_ip, i_lanIp, i_lanMask){
5831 if(!i_ip || !i_lanIp || !i_lanMask){//������������
5832 return false;
5833 }
5834
5835 //������IP����
5836 if (i_ip == i_lanIp) {
5837 return true;
5838 }
5839
5840 var res1 = [];
5841 var res2 = [];
5842
5843 var mask_array = [];
5844
5845 ip_array = i_ip.split(".");
5846 lanIp_array = i_lanIp.split(".");
5847 mask_array = i_lanMask.split(".");
5848 for(var index = 0; index < ip_array.length; index += 1){
5849 res1.push(parseInt(mask_array[index]) & parseInt(ip_array[index]));
5850 res2.push(parseInt(mask_array[index]) & parseInt(lanIp_array[index]));
5851 }
5852 if(res2.join(".") != res1.join(".")){//�ڲ�ͬ����
5853 return false;
5854 }else{//��ͬһ����
5855 return true;
5856 }
5857 }
5858
5859
5860 function sf_isValidate_NetmaskIP(i_ip) {
5861 return (i_ip == 255
5862 || i_ip == 254
5863 || i_ip == 252
5864 || i_ip == 248
5865 || i_ip == 240
5866 || i_ip == 224
5867 || i_ip == 192
5868 || i_ip == 128
5869 || i_ip == 0);
5870 }
5871
5872 function sf_convertIpToString(i_ip)
5873 {
5874 var s_i1 = i_ip.indexOf('.');
5875 var s_i2 = i_ip.indexOf('.', (s_i1 + 1));
5876 var s_i3 = i_ip.indexOf('.', (s_i2 + 1));
5877 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));
5878 o_ip = '0x' + o_ip;
5879
5880 return o_ip;
5881 }
5882
5883 function sf_getIpString_3(i_ip)
5884 {
5885 var i1 = i_ip.indexOf('.');
5886 var i2 = i_ip.indexOf('.', (i1 + 1));
5887 var i3 = i_ip.indexOf('.', (i2 + 1));
5888 var i4 = i_ip.substring((i3+1),i_ip.length)-0;
5889
5890 return i4;
5891 }
5892
5893
5894 // ����У�麯��
5895 function sf_isValidate_Gateway(i_wanIp, i_netmaskIp, i_gatewayIp) {
5896 var s_wanIp = sf_convertIpToString(i_wanIp);
5897 var lan4 = sf_getIpString_3(i_wanIp);
5898
5899 var s_netmaskIp = sf_convertIpToString(i_netmaskIp);
5900 var mask4 = sf_getIpString_3(i_netmaskIp);
5901
5902 var s_gatewayIp = sf_convertIpToString(i_gatewayIp);
5903 var pool4 = sf_getIpString_3(i_gatewayIp);
5904
5905 var net_no;
5906 var lo_broadcast;
5907
5908 if (sf_opAnd4Byte(s_wanIp, s_netmaskIp) != sf_opAnd4Byte(s_gatewayIp, s_netmaskIp)) {
5909 return false;
5910 }
5911
5912 net_no = (lan4 & mask4);
5913 lo_broadcast = (lan4 & mask4) + (255-mask4);
5914
5915 return !(pool4==net_no || pool4==lo_broadcast);
5916
5917 }
5918
5919 // ��������У�麯��
5920 function sf_isValidate_Netmask(i_netmask) {
5921 var addr = i_netmask.split(".");
5922
5923 if ("0.0.0.0" == i_netmask || "255.255.255.255" == i_netmask) {
5924 return false;
5925 }
5926
5927 if (addr.length != 4) {
5928 return false;
5929 }
5930
5931 addr[0] = parseInt(addr[0]);
5932 addr[1] = parseInt(addr[1]);
5933 addr[2] = parseInt(addr[2]);
5934 addr[3] = parseInt(addr[3]);
5935
5936 if (addr[3] != 0) {
5937 if (addr[0] != 255 || addr[1] != 255 || addr[2] != 255) {
5938 return false;
5939 } else {
5940 if (!sf_isValidate_NetmaskIP(addr[3])) {
5941 return false;
5942 }
5943 }
5944 }
5945
5946 if (addr[2] != 0) {
5947 if (addr[0] != 255 || addr[1] != 255) {
5948 return false;
5949 } else {
5950 if (!sf_isValidate_NetmaskIP(addr[2])) {
5951 return false;
5952 }
5953 }
5954 }
5955
5956 if (addr[1] != 0) {
5957 if (addr[0] != 255) {
5958 return false;
5959 } else {
5960 if (!sf_isValidate_NetmaskIP(addr[1])) {
5961 return false;
5962 }
5963 }
5964 }
5965
5966 if (addr[0] != 255) {
5967 return false;
5968 }
5969
5970 return true;
5971 }
5972
5973 // DHCP IP��У�麯��
5974 function sf_isValidate_StartEndIp(i_lanIpaddr, i_netIp, i_startIp, i_endIp, i_DHCPFlag) {
5975 s_startIp = sf_convertIpToString(i_startIp);
5976 s_endIp = sf_convertIpToString(i_endIp);
5977 s_lanIp = sf_convertIpToString(i_lanIpaddr);
5978
5979 if(s_startIp>s_endIp) {
5980 return 1;
5981 }
5982
5983 if(s_lanIp >= s_startIp && s_lanIp <= s_endIp) {
5984 return 2;
5985 }
5986
5987 return 0;
5988 }
5989
5990
5991 function init() {
5992 var container = $('#container');
5993 ko.cleanNode(container[0]);
5994 var fwVm = new LanViewModel();
5995 ko.applyBindings(fwVm, container[0]);
5996
5997 addInterval(fwVm.refreshStatus, 1000);
5998
5999 $('#frmLan').validate({
6000 submitHandler:function () {
6001 fwVm.save();
6002 },
6003
6004 rules:{
6005 txtIpAddress: {
6006 lanip_check: true,
6007 ipRange: true
6008 },
6009 txtSubnetMask: {
6010 ipv4: true,
6011 subnetmask_check: true
6012 },
6013 txtDhcpIpPoolStart: {
6014 lanip_check: true,
6015 dhcp_check: "start",
6016 dhcpCompare: "#txtDhcpIpPoolEnd"
6017 },
6018 txtDhcpIpPoolEnd: {
6019 lanip_check: true,
6020 dhcp_check: "end",
6021 dhcpCompare: "#txtDhcpIpPoolStart"
6022 },
6023 txtDhcpLease: {
6024 range: [1, 65535],
6025 digits: true
6026 }
6027 },
6028
6029 groups: {
6030 lanip_check: "txtDhcpIpPoolStart txtDhcpIpPoolEnd"
6031 },
6032
6033 errorPlacement: function (error, element) {
6034 if (element.attr("name") == "txtDhcpLease") {
6035 error.insertAfter("#errorHolder");
6036 } else if (element.attr("name") == "txtDhcpIpPoolStart") {
6037 error.insertAfter("#txtDhcpIpPoolEnd");
6038 } else {
6039 error.insertAfter(element);
6040 }
6041 }
6042 });
6043
6044 }
6045
6046
6047 return {
6048 init:init
6049 }
6050});
6051
6052// others �����:Fast Boot Settings��Restart and Reset��SNTP��Turn Off Device��PIN Management
6053define("adm_others","jquery knockout set service underscore".split(" "),
6054
6055 function ($, ko, config, service, _) {
6056
6057 var timeSetModes = _.map(config.sntpTimeSetMode, function(item) {
6058 return new Option(item.name, item.value);
6059 });
6060
6061 var timeZones = _.map(config.timeZone, function(item){
6062 return new Option(item.name, item.value);
6063 });
6064
6065 var daylightSave = _.map(config.daylightSave, function(item){
6066 return new Option(item.name, item.value);
6067 });
6068
6069 var sv_sntpYears = [];
6070 var sv_sntpMonths = [];
6071 var sv_sntpDates = []; //���ݴ�С����������
6072 var sv_sntpHours = [];
6073 var sv_sntpMinutes = [];
6074 var sc_startpHours = [];
6075 var sc_startMinutes = [];
6076 var sc_pingTimes = [];
6077
6078 var sf_bigMonth = [1, 3, 5, 7, 8, 10, 12];
6079 var sf_smallMonth = [4, 6, 9, 11];
6080
6081 function sf_produceArray(start, end, arryName) {
6082 var item = {};
6083 for(var i = start; i <= end; i++) {
6084 item.name = i;
6085 item.value = i;
6086 arryName.push(new Option(item.name, item.value));
6087 }
6088 }
6089
6090 //�����ꡢ�¡�ʱ���ֵ�����
mj.qu2d3c2af2025-06-22 23:23:15 -07006091 sf_produceArray(2000, 2037, sv_sntpYears);
w.dengd463b342024-12-20 10:21:38 +08006092 sf_produceArray(1, 12, sv_sntpMonths);
6093 sf_produceArray(0, 23, sv_sntpHours);
6094 sf_produceArray(0, 59, sv_sntpMinutes);
6095 sf_produceArray(0, 23, sc_startpHours);
6096 sf_produceArray(0, 59, sc_startMinutes);
6097 sf_produceArray(0, 59, sc_startMinutes);
6098 sf_produceArray(1, 10, sc_pingTimes);
6099
6100 function othersViewModel() {
6101 var target = this;
6102
6103 var inChildGroup = false;
6104 var scheduleInfo = service.getScheduleSetting();
6105 var pingDiagInfo = service.getPingSetting();
6106
6107 target.fastbootSupport = config.FAST_BOOT_SUPPORT;
6108 target.turnOffSupport = config.TURN_OFF_SUPPORT;
6109 target.SNTPSupport = config.HAS_SNTP;
6110 target.hasUssd = config.HAS_USSD;
6111 target.hasDdns = config.DDNS_SUPPORT;
6112 target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
6113 target.scheduleSetting = ko.observable(scheduleInfo.scheduleSetting);
6114 target.scheduleHour = ko.observable(parseInt(scheduleInfo.scheduleHour));
6115 target.scheduleMinute = ko.observable(parseInt(scheduleInfo.scheduleMinute));
6116 target.scr_hours = ko.observableArray(sc_startpHours);
6117 target.scr_minutes = ko.observableArray(sc_startMinutes);
6118 target.src_times = ko.observableArray(sc_pingTimes);
6119 target.pingTimes = ko.observable(pingDiagInfo.pingTimes);
6120 target.pingURL = ko.observable(pingDiagInfo.pingURL);
6121
6122
6123 if (config.HAS_PARENTAL_CONTROL) {
6124 inChildGroup = service.checkCurrentUserInChildGroup().result;
6125 }
6126 target.currentUserInChildGroup = ko.observable(inChildGroup);
6127
6128 var sv_fastbootInfo = service.getFastbootSetting();
6129 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");
6130 target.fastbootSetting = ko.observable(sv_fastbootInfo.fastbootEnabled);
6131
6132
6133 // @method addInterval
6134 addInterval(function(){
6135 target.fastbootEnableFlag(config.RJ45_SUPPORT ? (sv_fastbootInfo.need_sim_pin != "yes" && service.getRj45PlugState().rj45_plug == "wan_lan_off") : sv_fastbootInfo.need_sim_pin != "yes");
6136 }, 1000);
6137
6138 // �ָ���������
6139 // @event restore
6140 target.restore = function () {
6141 showConfirm("restore_confirm", function () {
6142 showLoading("restoring");
6143 service.restoreFactorySettings({}, function (info) {
6144 if (info && info.result == "success") {
6145 successOverlay();
6146 } else {
6147 errorOverlay();
6148 }
6149 }, function (result) {
6150 if (isErrorObject(result) && result.errorType == 'no_auth') {
6151 errorOverlay();
6152 }
6153 });
6154 });
6155 };
6156
6157 target.restart = function () {
6158 showConfirm("restart_confirm", function () {
6159 restartDevice(service);
6160 });
6161 };
6162
6163 target.scheduleRestart = function () {
6164 showLoading();
6165 var params = {};
6166 params.scheduleSetting = target.scheduleSetting();
6167 params.scheduleHour = target.scheduleHour();
6168 params.scheduleMinute = target.scheduleMinute();
6169 service.setScheduleSetting(params, function (result) {
6170 if (result.result != "success") {
6171 errorOverlay();
6172 } else {
6173 successOverlay();
6174 }
6175 });
6176 };
6177
6178 target.pingResult = ko.observable();
6179
6180 target.loadFileContent = function() {
6181 var newPingResInfo = service.getPingResult();
6182 if (newPingResInfo.pingResult !== target.pingResult()) {
6183 target.pingResult(newPingResInfo.pingResult);
6184 }
6185 };
6186
6187 function showinfo(msgObj, minHeight) {
6188 var option = {
6189 title: 'info',
6190 img: 'pic/res_info.png',
6191 msg: msgObj,
6192 minHeight: minHeight
6193 };
6194 popup(option);
mj.qu28df13a2025-01-07 19:14:21 -08006195
w.dengd463b342024-12-20 10:21:38 +08006196 $('#yesbtn, #nobtn, #okbtn').hide();
mj.qu28df13a2025-01-07 19:14:21 -08006197
w.dengd463b342024-12-20 10:21:38 +08006198 setTimeout(function() {
6199 $.modal.close();
6200 }, 1000);
6201 }
mj.qu28df13a2025-01-07 19:14:21 -08006202
w.dengd463b342024-12-20 10:21:38 +08006203 setInterval(target.loadFileContent, 1000);
6204
6205 target.pingStart = function () {
6206 showinfo('ping_starting');
6207 var params = {};
6208 params.pingTimes = target.pingTimes();
6209 params.pingURL = target.pingURL();
6210 service.setPingSettingStart(params, function (result) {
6211 if (result.result != "success") {
6212 errorOverlay();
6213 }
6214 });
6215 };
6216
6217 target.pingClear = function () {
6218 showLoading();
6219 service.pingResultClear({}, function (result) {
6220 if (result.result != "success") {
6221 errorOverlay();
6222 } else {
6223 successOverlay();
6224 }
6225 });
6226 };
6227
6228 // ���ٿ��ػ�����
6229 target.saveFastBoot = function() {
6230 showLoading();
6231 var params = {
6232 fastbootEnabled: target.fastbootSetting(),
6233 need_hard_reboot: sv_fastbootInfo.need_hard_reboot
6234 };
6235 service.setFastbootSetting(params, function(result) {
6236 if (result.result == "success") {
6237 successOverlay();
6238 } else {
6239 errorOverlay();
6240 }
6241 });
6242 };
6243
6244 // �ػ�
6245 target.turnoff = function () {
6246 showConfirm("turnoff_confirm", function () {
6247 showLoading("turnoff");
6248 service.turnOffDevice({}, function (info) {
6249 if (info && info.result == "success") {
6250 successOverlay();
6251 } else {
6252 errorOverlay();
6253 }
6254 }, $.noop);
6255 });
6256 };
6257
6258 //SNTP����serverУ׼ʱ��
6259 service.setSNTPDate({
6260 goformId: "SNTP_Getdatastatic"
6261 });
6262
6263 var target = this;
6264 var sntpInfo = service.getSntpParams();
6265
6266 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));
6267
6268 target.day = ko.observable();
6269 target.localTime = ko.observable();
6270
6271 //��ʼ����ǰ����ʱ��
6272 //target.updateCurrentTime; cov_2
6273 target.timeSetModes = ko.observableArray(timeSetModes);
6274 target.isManualSetTime = ko.observable(false);
6275 target.isAutoSntpTime = ko.observable(false);
6276
6277 target.currentMode = ko.observable(sntpInfo.sntp_time_set_mode);
6278
6279 changeSetTimeMode();
6280 target.changeSetTimeMode = function(){
6281 changeSetTimeMode();
6282 };
6283
6284 target.currentYear = ko.observable(parseInt(sntpInfo.sntp_year, 10));
6285 target.currentMonth = ko.observable(parseInt(sntpInfo.sntp_month, 10));
6286 target.currentDate = ko.observable(parseInt(sntpInfo.sntp_day, 10));
6287 target.currentHour = ko.observable(parseInt(sntpInfo.sntp_hour, 10));
6288 target.currentMinute = ko.observable(parseInt(sntpInfo.sntp_minute, 10));
6289
6290
6291 // ��Ҫ��������ˢ�������б����ݣ�ע��˳��
6292
6293 target.years = ko.observableArray(sv_sntpYears);
6294 target.months = ko.observableArray(sv_sntpMonths);
6295 //���û�ѡ���·ݵ�ʱ���ı�����ѡ������ѡ��
6296 target.initDateList = function(){
6297 initDateList();
6298 target.dates(sv_sntpDates);
6299 }
6300
6301 //��ʼ�������б�
6302 initDateList();
6303 target.dates = ko.observableArray(sv_sntpDates);
6304 target.hours = ko.observableArray(sv_sntpHours);
6305 target.minutes = ko.observableArray(sv_sntpMinutes);
6306
6307 //�Զ�SNTP��ȡʱ�����ݰ󶨴���
6308 var serverArray = _.map(sntpInfo.sntp_servers, function(item) {
6309 return new Option(item.name, item.value)
6310 });
6311
6312 target.serverList = ko.observableArray(serverArray);
6313
6314 // �������ֲ����޸ģ��޸��޷�ˢ����ҳ
6315
6316 target.currentServer0 = ko.observable(sntpInfo.sntp_server0);
6317 target.currentServer1 = ko.observable(sntpInfo.sntp_server1);
6318 target.currentServer2 = ko.observable(sntpInfo.sntp_server2);
6319 target.customServer0 = ko.observable(sntpInfo.sntp_other_server0);
6320 target.customServer1 = ko.observable(sntpInfo.sntp_other_server1);
6321 target.customServer2 = ko.observable(sntpInfo.sntp_other_server2);
6322 target.isOther0 = ko.observable(false);
6323 target.isOther1 = ko.observable(false);
6324 target.isOther2 = ko.observable(false);
6325
6326 initOtherServer();
6327
6328 target.changeServerSelect = function(){
6329 initOtherServer();
6330 }
6331
6332 target.timeZones = ko.observableArray(timeZones);
6333 target.currentTimeZone = ko.observable(sntpInfo.sntp_timezone + "_" + sntpInfo.sntp_timezone_index);
6334 target.daylightSaves = ko.observableArray(daylightSave);
6335 target.currentDaylightSave = ko.observable(sntpInfo.sntp_dst_enable);
6336
6337 //���µ�ǰ��ʾʱ��
6338 target.updateCurrentTime = function() {
6339 var globalDay = globalTime.getDay();
6340
6341 switch(globalDay){
6342 case 6:
6343 target.day($.i18n.prop("saturday"));
6344 break;
6345 case 5:
6346 target.day($.i18n.prop("friday"));
6347 break;
6348 case 4:
6349 target.day($.i18n.prop("thursday"));
6350 break;
6351 case 3:
6352 target.day($.i18n.prop("wednesday"));
6353 break;
6354 case 2:
6355 target.day($.i18n.prop("tuesday"));
6356 break;
6357 case 1:
6358 target.day($.i18n.prop("monday"));
6359 break;
6360 case 0:
6361 target.day($.i18n.prop("sunday"));
6362 break;
6363 default:
6364 break;
6365 }
6366
6367 var localCurrentTime = globalTime.getFullYear() + "-" + getTwoDigit(globalTime.getMonth()+1) + "-" + getTwoDigit(globalTime.getDate()) + " " + getTwoDigit(globalTime.getHours()) + ":" + getTwoDigit(globalTime.getMinutes()) + ":" + getTwoDigit(globalTime.getSeconds());
6368 target.localTime(localCurrentTime);
6369 globalTime.setTime(globalTime.getTime()+1000);
6370 };
6371
6372 // SNTP����
6373 target.apply = function(){
6374 var tmpArray = [];
6375 for(var i=0; i< sntpInfo.sntp_servers.length; i++){
6376 tmpArray.push(sntpInfo.sntp_servers[i].value);
6377 }
6378 var staInfo = service.getStatusInfo();
6379 if(!checkConnectedStatus(staInfo.connectStatus, staInfo.rj45ConnectStatus, staInfo.connectWifiStatus) && target.currentMode() == "auto"){
6380 showAlert("sntp_syn_time_wan_connected");
6381 return;
6382 }
6383
6384 showLoading("");
6385 var requestParams = {
6386 goformId: "SNTP",
6387 manualsettime : target.currentMode(),
6388 sntp_server1_ip : target.currentServer0(),
6389 sntp_server2_ip : target.currentServer1(),
6390 sntp_server3_ip : target.currentServer2(),
6391 sntp_other_server0 : target.customServer0(),
6392 sntp_other_server1 : target.customServer1(),
6393 sntp_other_server2 : target.customServer2(),
6394 timezone : target.currentTimeZone().split("_")[0],
6395 sntp_timezone_index : target.currentTimeZone().split("_")[1],
6396 DaylightEnabled : target.currentDaylightSave(),
6397 time_year : target.currentYear(),
6398 time_month : target.currentMonth(),
6399 time_day : target.currentDate(),
6400 time_hour : target.currentHour(),
6401 time_minute : target.currentMinute()
6402 };
6403
6404 service.setSntpSetting(requestParams, function(data2){
6405 if(data2) {
6406 if(data2.result == "success" && target.currentMode() == "auto"){
6407 successOverlay("sntp_req_success");
6408 //hideLoading();
6409 }else if(data2.result == "processing" && target.currentMode() == "auto"){
6410 successOverlay("sntp_processing");
6411 }else{
6412 //����serverУ׼ʱ��
6413 service.setSNTPDate({
6414 goformId: "SNTP_Getdatastatic"
6415 }, function(result){
6416 var sntpInfo = service.getSntpParams();
6417 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));
6418 successOverlay();
6419 });
6420 }
6421 } else {
6422 errorOverlay();
6423 }
6424 });
6425 }
6426
6427 // �ֶ�/�Զ��л���Ӧ����
6428 function changeSetTimeMode() {
6429 if(target.currentMode() == "manual") {
6430 target.isManualSetTime(true);
6431 target.isAutoSntpTime(false);
6432 } else {
6433 target.isManualSetTime(false);
6434 target.isAutoSntpTime(true);
6435 }
6436 return true;
6437 }
6438
6439 // ��ʼ��ʱ��
6440 function initDateList(){
6441 sv_sntpDates = [];
6442 if($.inArray(parseInt(target.currentMonth(), 10), sf_smallMonth) != -1) {
6443 sf_produceArray(1, 30, sv_sntpDates);
6444 } else if($.inArray(parseInt(target.currentMonth(), 10), sf_bigMonth) != -1) {
6445 sf_produceArray(1, 31, sv_sntpDates);
6446 } else if(parseInt(target.currentYear(), 10)%4 == 0) {
6447 sf_produceArray(1, 29, sv_sntpDates);
6448 } else {
6449 sf_produceArray(1, 28, sv_sntpDates);
6450 }
6451 }
6452
6453 // ��ʼ������������
6454 function initOtherServer(){
6455 target.isOther0(target.currentServer0() == "Other");
6456 target.isOther1(target.currentServer1() == "Other");
6457 target.isOther2(target.currentServer2() == "Other");
6458 !target.isOther0() && $("#sntp_server0").find(".error").hide();
6459 !target.isOther1() && $("#sntp_server1").find(".error").hide();
6460 !target.isOther2() && $("#sntp_server2").find(".error").hide();
6461 }
6462
6463
6464 }
6465
6466 // ��ʼ�� ViewModel����������ͼ����
6467 function init() {
6468 var fwVm = new othersViewModel();
6469 var container = $('#container')[0];
6470 ko.cleanNode(container);
6471 ko.applyBindings(fwVm, container);
6472 fwVm.updateCurrentTime();
6473
6474 addInterval(function(){
6475 fwVm.updateCurrentTime();
6476 }, 1000);
6477
6478 $("#sntpForm").validate({
6479 submitHandler: function(){
6480 fwVm.apply();
6481 },
6482 rules: {
6483 sntp_other_server0 : "sntp_invalid_server_name",
6484 sntp_other_server1 : "sntp_invalid_server_name",
6485 sntp_other_server2 : "sntp_invalid_server_name"
6486 }
6487 });
6488 }
6489
6490 return {
6491 init:init
6492 }
6493 });
w.denged536982025-07-21 10:24:31 +08006494
6495const errorMessages = {
6496 "en": {
6497 txtCurrent: {
6498 manage_info_check: "Please enter a valid password."
6499 },
6500 txtNew: {
6501 manage_info_check: "Please enter a valid password."
6502 },
6503 txtConfirm: {
6504 equalTo: "The new password and the confirmed password do not match or contain illegal characters."
6505 }
6506 },
6507 "zh": {
6508 txtCurrent: {
6509 manage_info_check: "请输入有效的密码"
6510 },
6511 txtNew: {
6512 manage_info_check: "请输入有效的密码"
6513 },
6514 txtConfirm: {
6515 equalTo: "新密码和确认密码不匹配或者包含非法字符"
6516 }
6517 }
6518};
6519
w.dengd463b342024-12-20 10:21:38 +08006520// �������� �
6521
6522define("adm_management","jquery knockout set service underscore CryptoJS".split(" "),
6523
6524 function ($, ko, config, service, _, CryptoJS) {
6525
6526 function manageViewModel() {
6527 var target = this;
6528
6529 target.currentValue = ko.observable();
6530 target.newValue = ko.observable();
6531 target.confirmValue = ko.observable();
6532
6533 function sf_changeValue() {
6534 var sv_manageInfo = {};
6535 if (config.PASSWORD_ENCODE) {
6536 sv_manageInfo.oldValue = target.currentValue();
6537 sv_manageInfo.newValue = target.newValue();
6538 } else {
6539 var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
6540
6541 if (!pwdRegex.test(target.newValue())) {
6542 showConfirm("password_note_too_low", function () {
6543
6544 var kparam = service.getDeviceInfoLow();
6545 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
6546 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
6547 var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
6548 iv: tiv,
6549 mode: CryptoJS.mode.CBC,
6550 padding: CryptoJS.pad.ZeroPadding
6551 }).toString();
6552 var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
6553 iv: tiv,
6554 mode: CryptoJS.mode.CBC,
6555 padding: CryptoJS.pad.ZeroPadding
6556 }).toString();
6557
6558 sv_manageInfo.oldValue = cipherold;
6559 sv_manageInfo.newValue = ciphernew;
6560
6561 showLoading();
6562
6563 service.changeManageInfo(sv_manageInfo, function (resultInfo) {
6564 target.cancel();
6565 if (resultInfo && resultInfo.result == true) {
6566 successOverlay();
6567 } else {
6568 if (resultInfo && resultInfo.errorType == "badPassword") {
6569 hideLoading();
6570 showAlert("current_password_error",function(){
6571 $("#txtCurrent").focus();
6572 });
6573 } else {
6574 errorOverlay();
6575 }
6576 }
6577 });
6578 });
6579 return;
6580 }
6581 var kparam = service.getDeviceInfoLow();
6582 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
6583 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
6584 var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
6585 iv: tiv,
6586 mode: CryptoJS.mode.CBC,
6587 padding: CryptoJS.pad.ZeroPadding
6588 }).toString();
6589 var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
6590 iv: tiv,
6591 mode: CryptoJS.mode.CBC,
6592 padding: CryptoJS.pad.ZeroPadding
6593 }).toString();
6594
6595 sv_manageInfo.oldValue = cipherold;
6596 sv_manageInfo.newValue = ciphernew;
6597 }
6598
6599 showLoading();
6600
6601 service.changeManageInfo(sv_manageInfo, function (resultInfo) {
6602 target.cancel();
6603 if (resultInfo && resultInfo.result == true) {
6604 successOverlay();
6605 } else {
6606 if (resultInfo && resultInfo.errorType == "badPassword") {
6607 hideLoading();
6608 showAlert("current_password_error",function(){
6609 $("#txtCurrent").focus();
6610 });
6611 } else {
6612 errorOverlay();
6613 }
6614 }
6615 });
6616 }
6617
6618 // ��������������
6619 function sf_cancel() {
6620 target.currentValue("");
6621 target.newValue("");
6622 target.confirmValue("");
6623 }
6624
6625 target.cancel = sf_cancel;
6626
6627 // �޸�����
6628 target.changeValue = sf_changeValue;
6629 }
6630
6631 function init() {
6632 var container = $('#container');
6633 ko.cleanNode(container[0]);
6634 var fwVm = new manageViewModel();
6635 ko.applyBindings(fwVm, container[0]);
6636
mj.qu7af1f5b2025-07-31 19:31:40 -07006637 const langObj = service.getLanguage();
6638 const langCode = (langObj && langObj.Language || 'en').split('-')[0];
6639 const messages = errorMessages[langCode] || errorMessages['en'];
6640 console.log('langCode =', langCode);
w.denged536982025-07-21 10:24:31 +08006641
w.dengd463b342024-12-20 10:21:38 +08006642 $('#frmPassword').validate({
6643 submitHandler:function () {
6644 fwVm.changeValue();
6645 },
6646 rules:{
6647 txtCurrent:"manage_info_check",
6648 txtNew:"manage_info_check",
6649 txtConfirm:{ equalTo:"#txtNew"}
w.denged536982025-07-21 10:24:31 +08006650 },
6651 messages: messages
w.dengd463b342024-12-20 10:21:38 +08006652 });
6653 }
6654
6655 return {
6656 init:init
6657 }
6658 }
6659);
6660// PIN�����
6661
6662define("adm_pin","jquery knockout set service".split(" "),
6663
6664 function ($, ko, config, service) {
6665 var pageState = {common:0, requirePin:1, modifyPin:2, requirePuk:3, destroyed:4};
6666 var pinStatus = {enable:"1", disable:"0"};
6667
6668
6669 function pinViewModel() {
6670 var target = this;
6671 var sv_currentPinData = service.getPinData();
6672
6673 target.isDataCard = config.PRODUCT_TYPE == 'DATACARD';
6674 target.originPinStatus = ko.observable(sv_currentPinData.pin_status);
6675
6676 target.pinStatus = ko.observable(sv_currentPinData.pin_status);
6677 target.pinNumber = ko.observable(sv_currentPinData.pinnumber);
6678 target.pukNumber = ko.observable(sv_currentPinData.puknumber);
6679
6680 target.currentPin = ko.observable();
6681 target.newPin = ko.observable();
6682 target.confirmPin = ko.observable();
6683
6684 target.puk = ko.observable();
6685
6686 target.pageState = ko.observable();
6687 // �����������ɹ���־λ
6688 target.operateSuccessFlag = true;
6689
6690 target.callback = sf_callback;
6691
6692 function sf_callback(info) {
6693 if (info && info.result == true) {
6694 target.operateSuccessFlag = true;
6695 successOverlay();
6696 } else {
6697 target.operateSuccessFlag = false;
6698
6699 // ����һ��ǰҪ������ʾ
6700 if(target.pinNumber() == 2){
6701 showAlert("last_enter_pin");
6702 } else if(target.pukNumber() == 2){
6703 showAlert("last_enter_puk");
6704 }
6705 else{
6706 errorOverlay();
6707 }
6708 }
6709 init(target);
6710 }
6711
6712
6713 // ȷ����ť�¼������������޸�PIN������PUK����PIN������PIN��ʹ��״̬
6714
6715 function sf_changePin() {
6716 if (target.isConnectedNetWork()) {
6717 showAlert("cannot_operate_when_connected");
6718 return;
6719 }
6720
6721 if (target.pageState() == pageState.common) {
6722 return;
6723 }
6724
6725 var sv_pinPara = {
6726 oldPin:target.currentPin(),
6727 newPin:target.newPin()
6728 };
6729 showLoading();
6730
6731 if (target.pageState() == pageState.modifyPin) {
6732 service.changePin(sv_pinPara, target.callback);
6733 } else if (target.pageState() == pageState.requirePuk) {
6734 sv_pinPara = {
6735 PinNumber:target.newPin(),
6736 PUKNumber:target.puk()
6737 };
6738 service.enterPUK(sv_pinPara, target.callback);
6739 } else {
6740 if (target.pinStatus() == pinStatus.enable) {
6741 service.enablePin(sv_pinPara, target.callback);
6742 } else {
6743 service.disablePin(sv_pinPara, target.callback);
6744 }
6745 }
6746 }
6747
6748
6749 // ȡ���¼�����
6750 function sf_cancel() {
6751 target.pageState(pageState.common);
6752 target.pinStatus(target.originPinStatus());
6753 target.clear();
6754 }
6755
6756 // ����ҳ�������ͼ�����Ϣ
6757 function sf_clear() {
6758 target.confirmPin("");
6759 target.currentPin("");
6760 target.newPin("");
6761 target.puk("");
6762 clearValidateMsg();
6763 }
6764
6765 // �������ݣ����õ�ǰ��ҳ��״̬
6766 function sf_computePageState(i_pinData) {
6767 if (i_pinData.pinnumber > 0) {
6768 //�����ɹ�ҳ���ص���ʼ״̬������ʧ�ܲ���pinnumber>0,ҳ�治��ת
6769 if (target.operateSuccessFlag) {
6770 target.cancel();
6771 } else {
6772 target.clear();
6773 }
6774 } else {
6775 target.clear();
6776 if (i_pinData.puknumber > 0) {
6777 target.pageState(pageState.requirePuk);
6778 } else {
6779 target.pageState(pageState.destroyed);
6780 }
6781 }
6782 }
6783
6784 // ����PIN�޸�״̬�¼�����
6785 function sf_displayModifyPinPage() {
6786 if (target.isConnectedNetWork()) {
6787 showAlert("cannot_operate_when_connected");
6788 return;
6789 }
6790 target.pinStatus(target.originPinStatus());
6791 target.pageState(pageState.modifyPin);
6792 target.clear();
6793 }
6794
6795 // ����ҳ��Ԫ�ص�ʹ��״̬
6796 function sf_fixPageEnable() {
6797 if (target.isConnectedNetWork()) {
6798 $('#frmPin :input').each(function () {
6799 disableBtn($(this));
6800 });
6801 clearValidateMsg();
6802 } else {
6803 $('#frmPin :input').each(function () {
6804 if (this.id == "txtPin" || this.id == "btnPinApply") {
6805 if (target.pageState() == pageState.common) {
6806 disableBtn($(this));
6807 return;
6808 }
6809 }
6810 if (this.id == "btnModifyPin") {
6811 if (target.originPinStatus() != pinStatus.enable) {
6812 disableBtn($(this));
6813 return;
6814 }
6815 }
6816 if (this.id == "pinEnable" || this.id == "pinDisable") {
6817 if (target.pageState() == pageState.modifyPin) {
6818 disableBtn($(this));
6819 return;
6820 }
6821 }
6822 enableBtn($(this));
6823 });
6824
6825 }
6826 }
6827
6828 // �Ƿ�������
6829 function sf_isConnectedNetWork() {
6830 var info = service.getConnectionInfo();
6831 return info.connectStatus == "ppp_connected";
6832 }
6833
6834 // PINʹ�ܸı�ʱ�¼�����
6835 function sf_pinStatusChangeEvent() {
6836 if (target.pinStatus() == target.originPinStatus()) {
6837 target.pageState(pageState.common);
6838 } else {
6839 target.pageState(pageState.requirePin);
6840 }
6841 target.clear();
6842 }
6843
6844 target.changePin = sf_changePin;
6845 target.cancel = sf_cancel;
6846 target.clear = sf_clear;
6847 target.computePageState = sf_computePageState;
6848
6849 target.computePageState(sv_currentPinData);
6850
6851 target.displayModifyPinPage = sf_displayModifyPinPage;
6852 target.fixPageEnable = sf_fixPageEnable;
6853 target.isConnectedNetWork = sf_isConnectedNetWork;
6854
6855 target.pinStatusChangeEvent = ko.dependentObservable(sf_pinStatusChangeEvent, this);
6856 }
6857
6858 function init(oldViewModel) {
6859
6860 var fwVm = oldViewModel;
6861
6862 if (fwVm) {
6863 var sv_currentPinData = service.getPinData();
6864 fwVm.originPinStatus(sv_currentPinData.pin_status);
6865 fwVm.pinNumber(sv_currentPinData.pinnumber);
6866 fwVm.pukNumber(sv_currentPinData.puknumber);
6867 fwVm.computePageState(sv_currentPinData);
6868 } else {
6869 fwVm = new pinViewModel();
6870 addInterval(function () {
6871 fwVm.fixPageEnable();
6872 }, 1000);
6873 }
6874
6875 var container = $('#container')[0];
6876 ko.cleanNode(container);
6877 ko.applyBindings(fwVm, container);
6878 fwVm.fixPageEnable();
6879
6880 $('#frmPin').validate({
6881 submitHandler:function () {
6882 fwVm.changePin();
6883 },
6884 rules:{
6885 txtPuk:"puk_check",
6886 txtPin:"pin_check",
6887 txtNewPin:"pin_check",
6888 txtConfirmPin:{equalToPin:"#txtNewPin"}
6889 }
6890 });
6891 }
6892
6893 return {
6894 init:init
6895 }
6896 }
6897);
6898
6899// ��������
6900define("adm_quick_set","jquery knockout set service underscore CryptoJS".split(" "),
6901
6902 function ($, ko, config, service, _, CryptoJS) {
6903
6904 var sv_wifiState = {ok:0, wps_on:1, wifi_off:2};
6905 var sv_apnMode = {auto:"auto", manual:"manual"};
6906 var sv_minStep = 1;
6907 var sv_maxStep = 5;
6908
6909 // ��ȡ��Ȩ��ʽ
6910 function sf_fetchAuthenticationModes() {
6911 return _.map(config.APN_AUTH_MODES, function (item) {
6912 return new Option(item.name, item.value);
6913 });
6914 }
6915
6916 // WIFI��ȫģʽѡ��
6917 var sv_securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
6918 return new Option(item.name, item.value);
6919 });
6920
6921
6922 function quickSettingViewModel() {
6923 var target = this;
6924
6925 var sv_quickSettingInfo = service.getQuickSettingInfo();
6926
6927 target.currentStep = ko.observable(sv_minStep);
6928 target.ipType = ko.observable(sv_quickSettingInfo.pdp_type == "IP" ? "IP" : sv_quickSettingInfo.ipv6_pdp_type);
6929 target.supportIPv6 = config.IPV6_SUPPORT;
6930 target.supportIpv4AndIpv6 = config.IPV4_AND_V6_SUPPORT;
6931
6932 target.wpsFlag = ko.observable(sv_quickSettingInfo.WscModeOption);
6933
6934 function sf_apnDisabled() {
6935 return (sv_quickSettingInfo.apn_index < config.defaultApnSize || sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting");
6936 }
6937
6938 function sf_apnModeDisabled() {
6939 return (sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting" || (!target.profileName() && target.apnMode() == sv_apnMode.auto));//ѡ��Ϊ�ջ��������ӻ�������
6940 }
6941
6942 function sf_currAPN() {
6943 var sv_APNText = sv_quickSettingInfo["APN_configtmp" + sv_quickSettingInfo.apn_index];
6944 var strIPv6APN = sv_quickSettingInfo["ipv6_APN_configtmp" + sv_quickSettingInfo.apn_index];
6945
6946 var sv_apn = [];
6947 var sv_ipv6APNItems = [];
6948
6949 if (sv_APNText) {
6950 sv_apn = sv_APNText.split("($)");
6951 }
6952
6953 if (strIPv6APN) {
6954 sv_ipv6APNItems = strIPv6APN.split("($)");
6955 }
6956
6957 return {
6958 m_profile_name:sv_apn[0],
6959 wan_apn:sv_apn[1],
6960 ppp_auth_mode: sv_apn[4] == "" || typeof(sv_apn[4]) == "undefined" ? "" : sv_apn[4].toLowerCase(),
6961 ppp_username:sv_apn[5],
6962 ppp_passtmp:sv_apn[6],
mj.que145fd02025-06-05 00:13:13 -07006963 pdp_type: sv_apn[7] == "" || typeof(sv_apn[7]) == "undefined" ? sv_ipv6APNItems[7] : sv_apn[7],
w.dengd463b342024-12-20 10:21:38 +08006964 ipv6_wan_apn:sv_ipv6APNItems[1],
6965 ipv6_ppp_auth_mode:typeof(sv_ipv6APNItems[4]) == "undefined" || sv_ipv6APNItems[4] == ""? "" : sv_ipv6APNItems[4].toLowerCase(),
6966 ipv6_ppp_username:sv_ipv6APNItems[5],
6967 ipv6_ppp_passtmp:sv_ipv6APNItems[6],
6968 ipv6_pdp_type:sv_ipv6APNItems[7]
6969 }
6970 }
6971
6972 // ��ǰAPN����
6973 target.currAPN = ko.computed(sf_currAPN);
6974
6975 target.apn = ko.observable(target.currAPN().wan_apn);
mj.que145fd02025-06-05 00:13:13 -07006976 target.ipType = ko.observable(target.currAPN().pdp_type);
w.dengd463b342024-12-20 10:21:38 +08006977 target.ipv6_apn = ko.observable(target.currAPN().ipv6_wan_apn);
6978 target.ipv6_selectedAuthMode = ko.observable(target.currAPN().ipv6_ppp_auth_mode);
6979 target.ipv6_username = ko.observable(target.currAPN().ipv6_ppp_username);
6980 target.ipv6_password = ko.observable(target.currAPN().ipv6_ppp_passtmp);
6981 target.profileName = ko.observable(target.currAPN().m_profile_name);
6982 target.selectedAuthMode = ko.observable(target.currAPN().ppp_auth_mode);
6983 target.username = ko.observable(target.currAPN().ppp_username);
6984 target.password = ko.observable(target.currAPN().ppp_passtmp);
6985
6986 target.transAPN = ko.observable("apn_ipv4_apn");
6987 target.transAPNIPv6 = ko.observable("apn_ipv6_apn");
6988 target.transAuthMode = ko.observable("apn_authentication_ipv4");
6989 target.transAuthModeIPv6 = ko.observable("apn_authentication_ipv6");
6990 target.transUserName = ko.observable("apn_user_name_ipv4");
6991 target.transPassword = ko.observable("apn_password_ipv4");
6992 target.transUserNameIPv6 = ko.observable("apn_user_name_ipv6");
6993 target.transPasswordIPv6 = ko.observable("apn_password_ipv6");
6994
6995
6996
6997 target.apnDisabled = ko.computed(sf_apnDisabled);
6998 target.apnMode = ko.observable(sv_quickSettingInfo.apn_mode);
6999 target.apnModeDisabled = ko.computed(sf_apnModeDisabled);
7000 target.authModes = ko.observableArray(sf_fetchAuthenticationModes());
7001
7002 if (target.ipType() == "IPv6") {
7003 target.showIPv4 = false;
7004 target.showIPv6 = true;
7005 target.transAPNIPv6("apn");
7006 target.transAuthModeIPv6("apn_authentication");
7007 target.transUserNameIPv6("apn_user_name");
7008 target.transPasswordIPv6("apn_password");
7009 } else if (config.IPV4_AND_V6_SUPPORT && target.ipType() == "IPv4v6") {
7010 target.showIPv4 = true;
7011 target.showIPv6 = true;
7012 //ʹ��Ĭ��
7013 } else if (target.ipType() == "IP" || target.ipType() == "IPv4") {
7014 target.showIPv4 = true;
7015 target.showIPv6 = false;
7016 target.transAPN("apn");
7017 target.transAuthMode("apn_authentication");
7018 target.transUserName("apn_user_name");
7019 target.transPassword("apn_password");
7020 } else { //pdp_type == "IPv4v6" && config.IPV4V6_SUPPORT
7021 target.showIPv4 = true;
7022 target.showIPv6 = false;
7023 target.transAPN("apn");
7024 target.transAuthMode("apn_authentication");
7025 target.transUserName("apn_user_name");
7026 target.transPassword("apn_password");
7027 }
7028
7029 target.wifiDisabled = (sv_quickSettingInfo.wifi_cur_state != "1");
7030 target.ssid = ko.observable(sv_quickSettingInfo.SSID1);
7031 target.broadcast = ko.observable(sv_quickSettingInfo.HideSSID);
7032 target.hasWifiWep = config.WIFI_WEP_SUPPORT;
7033 target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
7034 target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
7035
7036 target.securityModes = ko.observableArray(sv_securityModes);
7037 target.selectedSecurityMode = ko.observable(sv_quickSettingInfo.AuthMode);
7038 target.WPAKey = ko.observable(sv_quickSettingInfo.WPAPSK1);
7039
7040 target.apnMode_display = ko.observable("");
7041
7042 target.apnMode_trans = ko.computed(sf_apnMode_trans);
7043 target.selectedAuthMode_display = ko.computed(sf_selectedAuthMode_display);
7044 target.ipv6_selectedAuthMode_display = ko.computed(sf_ipv6_selectedAuthMode_display);
7045
7046 target.showWifiPassword = ko.observable(false);
7047 target.showWifiPasswordHandler = sf_showWifiPasswordHandler;
7048
7049 //�ж��Ƿ���802 n only��
7050 var sv_adInfo = service.getWifiAdvance();
7051 target.adBand = ko.observable(sv_adInfo.wifiBand);
7052 target.adMode = ko.observable(sv_adInfo.mode);
7053
7054 target.encryptType = ko.observable(sv_quickSettingInfo.EncrypType);
7055 target.keyID = ko.observable(sv_quickSettingInfo.DefaultKeyID);
7056 target.wepPassword = ko.observable("");
7057
7058 target.getWepPassword = sf_getWepPassword;
7059 target.wepPassword(target.getWepPassword());
7060 target.profileChangeHandler = sf_profileChangeHandler;
7061
7062 target.broadcast_display = ko.observable("");
7063 target.broadcast_trans = ko.computed(sf_broadcast_trans);
7064
7065 target.selectedSecurityMode_display = ko.observable();
7066 target.selectedSecurityMode_trans = ko.computed(sf_selectedSecurityMode_trans);
7067
7068
7069 target.callback = sf_callback;
7070 target.next = sf_button_next;
7071 target.previous = sf_button_previous;
7072 target.save = sf_button_save;
7073
7074 function sf_apnMode_trans() {
7075 if (sv_apnMode.auto == target.apnMode()) {
7076 target.apnMode_display($.i18n.prop("apn_auto_apn"));
7077 return "apn_auto_apn";
7078 } else {
7079 target.apnMode_display($.i18n.prop("apn_manual_apn"));
7080 return "apn_manual_apn";
7081 }
7082 }
7083
7084 function sf_broadcast_trans() {
7085 if ("0" == target.broadcast()) {
7086 target.broadcast_display($.i18n.prop("enable"));
7087 return "enable";
7088 } else {
7089 target.broadcast_display($.i18n.prop("disable"));
7090 return "disable";
7091 }
7092 }
7093
7094 function sf_button_next() {
7095 var currentStep = target.currentStep();
7096 var toStep = target.currentStep() + 1;
7097 sf_changeStep(toStep);
7098
7099 if (currentStep == 1 && target.apnMode() == sv_apnMode.auto) {
7100 toStep = target.currentStep() + 1;
7101 sf_changeStep(toStep);
7102 }
7103 }
7104
7105 function sf_button_previous() {
7106
7107 var currentStep = target.currentStep();
7108 var toStep = target.currentStep() - 1;
7109
7110 sf_changeStep(toStep);
7111
7112 if (currentStep == 3 && target.apnMode() == sv_apnMode.auto) {
7113 toStep = target.currentStep() - 1;
7114 sf_changeStep(toStep);
7115 }
7116 }
7117 function sf_button_save() {
7118 var submit = function () {
7119 sf_quickSetting4IPv6();
7120 };
7121 var result = sf_isDisabled_Wifi();
7122 if(result == sv_wifiState.wifi_off){
7123 showConfirm("quick_setting_wifi_disable_confirm", submit);
7124 } else if (result == sv_wifiState.wps_on) {
7125 showAlert("wps_on_info");
7126 } else{
7127 showConfirm("quick_setting_param_changed_confirm", submit);//submit();
7128 }
7129 }
7130 // ���������ύ���Ļص�����
7131 function sf_callback(data) {
7132 if (data.result == "success") {
7133 successOverlay();
mj.qu7b3dd3a2025-07-10 01:31:18 -07007134 location.hash = "#main";
w.dengd463b342024-12-20 10:21:38 +08007135 }
7136 else {
7137 errorOverlay();
7138 }
7139 }
7140
7141 // �任����ʱ����
7142 function sf_changeStep(i_step) {
7143 if (i_step > sv_maxStep) {
7144 i_step = sv_maxStep;
7145 } else if (i_step < sv_minStep) {
7146 i_step = sv_minStep;
7147 }
7148
7149 target.currentStep(i_step);
7150 return true;
7151 }
7152
7153 function sf_ipv6_selectedAuthMode_display() {
7154 var mode = target.ipv6_selectedAuthMode();
7155 return sf_getAuthModeNameByValue(mode);
7156 }
7157 // ���ݼ�Ȩģʽ��ֵ��������
7158 function sf_getAuthModeNameByValue(authMode) {
7159 for (var i = 0; i < config.APN_AUTH_MODES.length; i++) {
7160 if (authMode == config.APN_AUTH_MODES[i].value) {
7161 return config.APN_AUTH_MODES[i].name;
7162 }
7163 }
7164 }
7165
7166 function sf_getWepPassword(){
7167 return target.keyID() == '3' ? sv_quickSettingInfo.Key4Str1 : (target.keyID() == '2' ? sv_quickSettingInfo.Key3Str1 : target.keyID() == '1' ? sv_quickSettingInfo.Key2Str1 : sv_quickSettingInfo.Key1Str1);
7168 }
7169
7170 function sf_isDisabled_Wifi() {
7171 var s_wpsInfo = service.getWpsInfo();
7172 if(s_wpsInfo.radioFlag == "0"){
7173 return sv_wifiState.wifi_off;
7174 }else if (s_wpsInfo.wpsFlag == '1') {
7175 return sv_wifiState.wps_on;
7176 }
7177 return sv_wifiState.ok;
7178 }
7179 function sf_profileChangeHandler(i_data, i_event) {
7180 $("#pwdWepKey").parent().find("label[class='error']").hide();
7181 target.wepPassword(target.getWepPassword());
7182 return true;
7183 }
7184
7185 // ���������ύ(֧��IPv6��
7186 function sf_quickSetting4IPv6() {
7187 showLoading();
7188 var useIPv4ForV6 = config.IPV4V6_SUPPORT && target.currAPN().pdp_type == "IPv4v6";
7189
7190 var ciphertext = "";
7191 if (config.PASSWORD_ENCODE) {
7192 ciphertext = target.WPAKey();
7193 } else {
7194 var kparam = service.getDeviceInfoLow();
7195 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
7196 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
7197 ciphertext = CryptoJS.AES.encrypt(target.WPAKey(), tkey, {
7198 iv: tiv,
7199 mode: CryptoJS.mode.CBC,
7200 padding: CryptoJS.pad.ZeroPadding
7201 }).toString();
7202 }
7203
7204 var s_quickSettingParameters = {
7205 apn_index: sv_quickSettingInfo.apn_index,
7206 apnMode: target.apnMode(),
7207 Encryption_Mode_hid: target.selectedSecurityMode(),
7208 ipv6_ppp_auth_mode: useIPv4ForV6 ? target.selectedAuthMode() : target.ipv6_selectedAuthMode(),
7209 ipv6_ppp_username: useIPv4ForV6 ? target.username() : target.ipv6_username(),
7210 ipv6_ppp_passtmp: useIPv4ForV6 ? target.password() : target.ipv6_password(),
7211 ipv6_wan_apn: useIPv4ForV6 ? target.apn() : target.ipv6_apn(),
7212 pdp_type: target.ipType(),
7213 ppp_auth_mode: target.selectedAuthMode(),
7214 ppp_username: target.username(),
7215 ppp_passtmp: target.password(),
7216 profile_name: target.profileName(),
7217 //Ŀǰ����ģʽֻ��2�֣�����3������Ϊ�̶�ֵ
7218 //������Ҫ����Ϊ5�֣�����ֵ��Ҫ����
7219 security_shared_mode: "NONE",
7220 SSID_Broadcast: target.broadcast(),
7221 SSID_name: target.ssid(),
7222 wan_apn: target.apn(),
7223 wep_default_key: 0,
7224 WPA_ENCRYPTION_hid: target.selectedSecurityMode() == "OPEN" ? "NONE" : target.selectedSecurityMode() == "WPA2PSK" ? 1 : 2,
7225 WPA_PreShared_Key: ciphertext
7226 }
7227
7228 s_quickSettingParameters.wep_default_key = target.keyID();
7229
7230 if(target.encryptType() == "SHARED" || target.selectedSecurityMode() == "WEP") {
7231
7232 s_quickSettingParameters.security_shared_mode = "WEP";
7233
7234 s_quickSettingParameters.wep_key_1 = sv_quickSettingInfo.Key1Str1;
7235 s_quickSettingParameters.wep_key_2 = sv_quickSettingInfo.Key2Str1;
7236 s_quickSettingParameters.wep_key_3 = sv_quickSettingInfo.Key3Str1;
7237 s_quickSettingParameters.wep_key_4 = sv_quickSettingInfo.Key4Str1;
7238
7239 var WEPSelectTmp = '0';
7240
7241 if(target.wepPassword().length =='5' ||target.wepPassword().length =='13'){
7242 WEPSelectTmp = '1';
7243 }else{
7244 WEPSelectTmp = '0';
7245 }
7246
7247 if(target.keyID() =='3'){
7248 s_quickSettingParameters.wep_key_4 = target.wepPassword();
7249 s_quickSettingParameters.WEP4Select = WEPSelectTmp;
7250 }else if(target.keyID() =='2'){
7251 s_quickSettingParameters.wep_key_3 = target.wepPassword();
7252 s_quickSettingParameters.WEP3Select = WEPSelectTmp;
7253 }else if(target.keyID() =='1'){
7254 s_quickSettingParameters.wep_key_2 = target.wepPassword();
7255 s_quickSettingParameters.WEP2Select = WEPSelectTmp;
7256 }else{
7257 s_quickSettingParameters.wep_key_1 = target.wepPassword();
7258 s_quickSettingParameters.WEP1Select = WEPSelectTmp;
7259 }
7260 }else if(target.encryptType() == "WPAPSKWPA2PSK") {
7261 s_quickSettingParameters.security_shared_mode = "NONE";
7262 }else {
7263 s_quickSettingParameters.security_shared_mode = "NONE";
7264 }
7265
7266 service.setQuickSetting4IPv6(s_quickSettingParameters, target.callback);
7267 }
7268
7269 function sf_selectedAuthMode_display() {
7270 var mode = target.selectedAuthMode();
7271 return sf_getAuthModeNameByValue(mode);
7272 }
7273
7274 function sf_selectedSecurityMode_trans() {
7275 var mode = target.selectedSecurityMode();
7276 var modesOption = config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES;
7277 for (var i = 0; i < modesOption.length; i++) {
7278 if (mode == modesOption[i].value) {
7279 target.selectedSecurityMode_display($.i18n.prop("security_mode_" + modesOption[i].value));
7280 return "security_mode_" + modesOption[i].value;
7281 }
7282 }
7283 }
7284
7285 function sf_showWifiPasswordHandler(){
7286 $("#pwdWepKey").parent().find(".error").hide();
7287 $("#codeWPAKey").parent().find(".error").hide();
7288 var checkbox = $("#showWifiPassword:checked");
7289 if(checkbox && checkbox.length == 0){
7290 target.showWifiPassword(true);
7291 }else{
7292 target.showWifiPassword(false);
7293 }
7294 }
7295
7296 }
7297
7298 function init() {
7299 var container = $('#container');
7300 ko.cleanNode(container[0]);
7301 var fwVm = new quickSettingViewModel();
7302 ko.applyBindings(fwVm, container[0]);
7303
7304 $('#quickSettingForm').validate({
7305 submitHandler:function () {
7306 if (fwVm.currentStep() < 5) {
7307 fwVm.next();
7308 } else {
7309 fwVm.save();
7310 }
7311 },
7312 rules:{
7313 txtAPN:"apn_check",
7314 txtIPv6APN:"apn_check",
7315 txtSSID:'ssid',
7316 pwdWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
7317 txtWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
7318 txtWPAKey:'wifi_password_check',
7319 codeWPAKey:'wifi_password_check',
7320 txtUserName:'ppp_username_check',
7321 txtIPv6UserName:'ppp_username_check',
7322 txtSecretCode:"ppp_secretcode_check",
7323 txtIPv6SecretCode:"ppp_secretcode_check"
7324 },
7325 errorPlacement:function (error, element) {
7326 var id = element.attr("id");
7327 if (id == "pwdWepKey" || id == "txtWepKey"){
7328 error.insertAfter("#lblShowWepPassword");
7329 } else if (id == "txtWPAKey" || id == "codeWPAKey") {
7330 error.insertAfter("#lblShowWifiPassword");
7331 } else {
7332 error.insertAfter(element);
7333 }
7334 }
7335 });
7336 }
7337
7338 return {
7339 init:init
7340 };
7341 }
7342);
7343
7344define("main","set service knockout underscore jquery statusBar echarts".split(" "), function (set, fnc, libko, libus, libjq, barStat, echarts) {
7345
7346 var chartOptions = {
7347 color: ['red', 'red', 'red', 'red', 'red'],
7348 series: [{
7349 name: '��������',
7350 type: 'pie',
7351 radius: ['0', '72'],
7352 itemStyle: {
7353 normal: {
7354 label: {
7355 show: false
7356 },
7357 labelLine: {
7358 show: false
7359 }
7360 }
7361 },
7362 data: [],
7363 selectedOffset: 3
7364 }
7365 ],
7366 animation: false,
7367 title: {
7368 text: '',
7369 x: 'center',
7370 y: 'center',
7371 itemGap: 0,
7372 textStyle: {
7373 color: '#FFF',
7374 fontFamily: '΢���ź�',
7375 fontSize: 20,
7376 fontWeight: 'bolder'
7377 },
7378 subtextStyle: {
7379 color: '#FFF',
7380 fontFamily: '΢���ź�',
7381 fontSize: 16,
7382 fontWeight: 'bolder'
7383 }
7384 },
7385 tooltip: {
7386 formatter: "{b}"
7387 },
7388 };
7389 var languageOld = window.language;
7390 var num_refresh = 0;
7391 var traffic_graphic_chart = null;
7392 var connStat = {
7393 CONNECTED: 1,
7394 DISCONNECTED: 2,
7395 CONNECTING: 3,
7396 DISCONNECTING: 4
7397 };
7398 function init() {
7399 num_refresh = 0;
7400 homeUtil.oldUsedData = null;
7401 homeUtil.oldAlarmData = null;
7402 traffic_graphic_chart = echarts.init(libjq("#traffic_graphic")[0]);
7403 var container = libjq('#container')[0];
7404 libko.cleanNode(container);
7405 var tmp = new VmHome();
7406 libko.applyBindings(tmp, container);
7407 var data = fnc.getLoginData();
7408 var psw_flg = data.psw_changed;
7409 if (psw_flg != "1") {
7410 showConfirm("password_note_first_change", function () {
7411 window.location.hash = '#pwd_mode';
7412 });
7413 return;
7414 }
7415 }
7416
7417 var homeUtil = {
7418 initStatus: null,
7419 initShownStatus: function (data) {
7420 this.initStatus = {};
7421 var ipv6Mode = data.ipv6PdpType.toLowerCase().indexOf("v6") > 0;
7422 if (set.RJ45_SUPPORT) {
7423 var mode = checkCableMode(data.blc_wan_mode);
7424 if (mode) {
7425 this.initStatus.showIpv6WanIpAddr = false;
7426 this.initStatus.showIpv4WanIpAddr = true;
7427 } else if (set.IPV6_SUPPORT) {
7428 if (data.pdpType == "IP") {
7429 this.initStatus.showIpv6WanIpAddr = false;
7430 this.initStatus.showIpv4WanIpAddr = true;
7431 } else if (ipv6Mode) {
7432 if (data.ipv6PdpType == "IPv6") {
7433 this.initStatus.showIpv6WanIpAddr = true;
7434 this.initStatus.showIpv4WanIpAddr = false;
7435 } else {
7436 this.initStatus.showIpv6WanIpAddr = true;
7437 this.initStatus.showIpv4WanIpAddr = true;
7438 }
7439 }
7440 } else {
7441 this.initStatus.showIpv6WanIpAddr = false;
7442 this.initStatus.showIpv4WanIpAddr = true;
7443 }
7444 } else {
7445 if (set.IPV6_SUPPORT) {
7446 if (data.pdpType == "IP") {
7447 this.initStatus.showIpv6WanIpAddr = false;
7448 this.initStatus.showIpv4WanIpAddr = true;
7449 } else if (ipv6Mode) {
7450 if (data.ipv6PdpType == "IPv6") {
7451 this.initStatus.showIpv6WanIpAddr = true;
7452 this.initStatus.showIpv4WanIpAddr = false;
7453 } else {
7454 this.initStatus.showIpv6WanIpAddr = true;
7455 this.initStatus.showIpv4WanIpAddr = true;
7456 }
7457 }
7458 } else {
7459 this.initStatus.showIpv6WanIpAddr = false;
7460 this.initStatus.showIpv4WanIpAddr = true;
7461 }
7462 }
7463 },
7464 wanIpGet: function (data) {
7465 var addrInfo = {
7466 wanIpAddress: '',
7467 ipv6WanIpAddress: ''
7468 };
7469 addrInfo.wanIpAddress = verifyDeviceInfo(data.wanIpAddress);
7470 addrInfo.ipv6WanIpAddress = verifyDeviceInfo(data.ipv6WanIpAddress);
7471 return addrInfo;
7472 },
7473 cachedAPStationBasic: null,
7474 cachedConnectionMode: null,
7475 getCanConnectNetWork: function (param) {
7476 var status = fnc.getStatusInfo();
7477 if (status.simStatus != "modem_init_complete") {
7478 return false;
7479 }
7480 var typeNetworkTmp = status.networkType.toLowerCase();
7481 if (typeNetworkTmp == 'searching') {
7482 return false;
7483 }
7484 if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
7485 typeNetworkTmp = 'limited_service';
7486 }
7487 if (typeNetworkTmp == 'no service') {
7488 typeNetworkTmp = 'no_service';
7489 }
7490 if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
7491 if (param.cStatus() != connStat.CONNECTED) {
7492 return false;
7493 }
7494 }
7495 if (set.AP_STATION_SUPPORT) {
7496 if (status.connectWifiStatus == "connect") {
7497 if (status.ap_station_mode == "wifi_pref") {
7498 return false;
7499 }
7500 }
7501 }
7502 return true;
7503 },
7504 doConnect: function () {
7505 showLoading('connecting');
7506 fnc.connect({}, function (data) {
7507 if (data.result) {
7508 successOverlay();
7509 } else {
7510 errorOverlay();
7511 }
7512 });
7513 },
7514 refreshHomeData: function (param) {
7515 var info = fnc.getConnectionInfo();
7516 param.connectStatus(info.connectStatus);
7517 param.canConnect(this.getCanConnectNetWork(param));
7518 param.networkType(homeUtil.getNetworkType(info.networkType));
7519 if (info.connectStatus == "ppp_connected") {
7520 param.current_Flux(transUnit(parseInt(info.data_counter.currentReceived, 10) + parseInt(info.data_counter.currentSent, 10), false));
7521 param.connected_Time(transSecond2Time(info.data_counter.currentConnectedTime));
7522 param.up_Speed(transUnit(info.data_counter.uploadRate, true));
7523 param.down_Speed(transUnit(info.data_counter.downloadRate, true));
7524 } else {
7525 param.current_Flux(transUnit(0, false));
7526 param.connected_Time(transSecond2Time(0));
7527 param.up_Speed(transUnit(0, true));
7528 param.down_Speed(transUnit(0, true));
7529 }
7530 param.trafficAlertEnable(info.limitVolumeEnable);
7531 if (info.limitVolumeEnable) {
7532 if (info.limitVolumeType == '1') {
7533 param.trafficUsed(transUnit(parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10), false));
7534 param.trafficLimited(transUnit(info.limitDataMonth, false));
7535 } else {
7536 param.trafficUsed(transSecond2Time(info.data_counter.monthlyConnectedTime));
7537 param.trafficLimited(transSecond2Time(info.limitTimeMonth));
7538 }
7539 }
7540 if (languageOld != window.language) {
7541 languageOld = window.language;
7542 num_refresh = 1;
7543 }
7544 if (param.showTraffic()) {
7545 homeUtil.updateEcharts(info);
7546 } else {
7547 homeUtil.allFreeEcharts();
7548 }
7549 homeUtil.refreshStationInfo(param);
7550 },
7551 allFreeEcharts: function () {
7552 var usedData = homeUtil.data.free;
7553 usedData.value = 1;
7554 usedData.selected = false;
7555 usedData.name = libjq.i18n.prop("echarts_no");
7556 chartOptions.series[0].data = [usedData];
7557 chartOptions.title.text = '';
7558 homeUtil.setEcharts(chartOptions, libjq.i18n.prop("echarts_no"));
7559 },
7560 getNetworkType: function (networkType) {
7561 var typeNetworkTmp = networkType.toLowerCase();
7562 if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
7563 typeNetworkTmp = 'limited_service';
7564 }
7565 if (typeNetworkTmp == 'no service') {
7566 typeNetworkTmp = 'no_service';
7567 }
7568 if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
7569 return libjq.i18n.prop("network_type_" + typeNetworkTmp);
7570 } else {
7571 return networkType;
7572 }
7573 },
7574 data: {
7575 full: {
7576 value: 30,
7577 name: '��������',
7578 itemStyle: {
7579 normal: {
7580 color: '#DF4313'
7581 }
7582 }
7583 },
7584 used: {
7585 value: 30,
7586 name: '��ʹ��',
7587 itemStyle: {
7588 normal: {
7589 color: '#8CC916'
7590 }
7591 }
7592 },
7593 left1: {
7594 value: 50,
7595 name: '����ֵ��δʹ��',
7596 itemStyle: {
7597 normal: {
7598 color: '#D8D8D8'
7599 }
7600 }
7601 },
7602 free: {
7603 value: 50,
7604 name: 'δʹ��',
7605 itemStyle: {
7606 normal: {
7607 color: '#D8D8D8'
7608 }
7609 }
7610 },
7611 alert: {
7612 value: 1,
7613 name: '����ֵ',
7614 itemStyle: {
7615 normal: {
7616 color: '#FF5500'
7617 }
7618 }
7619 },
7620 alarm: {
7621 value: 19.7,
7622 name: '������',
7623 itemStyle: {
7624 normal: {
7625 color: '#8CC916'
7626 }
7627 }
7628 },
7629 start: {
7630 value: 50,
7631 name: '����ֵ��δʹ��',
7632 itemStyle: {
7633 normal: {
7634 color: '#D8D8D8'
7635 }
7636 }
7637 },
7638 },
7639 getDataInfo: function (value) {
7640 return {
7641 data: /\d+(.\d+)?/.exec(value)[0],
7642 unit: /[A-Z]{1,2}/.exec(value)[0]
7643 }
7644 },
7645 oldAlarmData: null,
7646 oldUsedData: null,
7647 updateEcharts: function (info) {
7648 var startName = libjq.i18n.prop("echarts_no");
7649 num_refresh++;
7650 if (num_refresh % 10 != 2) {
7651 return false;
7652 }
7653 var total = 0,
7654 used = 0,
7655 reach = 0,
7656 left = 0,
7657 alarm = 0,
7658 left1 = 0;
7659 if (info.limitVolumeEnable) {
7660 startName = libjq.i18n.prop("echarts_used");
7661 chartOptions.series[0].data = [];
7662 if (info.limitVolumeType == '1') {
7663 var limitedDataFormatted = transUnit(info.limitDataMonth, false);
7664 chartOptions.series[0].data = [];
7665 if (info.limitDataMonth == 0) {
7666 var usedData = homeUtil.data.used;
7667 usedData.value = 1;
7668 usedData.selected = false;
7669 usedData.name = libjq.i18n.prop("echarts_used");
7670 chartOptions.series[0].data.push(usedData);
7671 } else {
7672 var dataInfo = homeUtil.getDataInfo(limitedDataFormatted);
7673 total = dataInfo.data * homeUtil.getUnitValue(dataInfo.unit) * 1048576;
7674 used = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
7675 reach = total * info.limitVolumePercent / 100;
7676 if (used >= total) {
7677 var fullData = homeUtil.data.full;
7678 fullData.value = 100;
7679 fullData.name = libjq.i18n.prop("echarts_full");
7680 chartOptions.series[0].data.push(fullData);
7681 startName = libjq.i18n.prop("echarts_full");
7682 } else {
7683 if (reach - used > 0) {
7684 left1 = reach - used;
7685 left = total - reach;
7686 } else {
7687 alarm = used - reach;
7688 left = total - used;
7689 }
7690 var usedData = homeUtil.data.used;
7691 if (reach - used > 0) {
7692 usedData.value = used;
7693 } else {
7694 usedData.value = reach;
7695 }
7696 usedData.name = libjq.i18n.prop("echarts_used");
7697 chartOptions.series[0].data.push(usedData);
7698 if (left1 > 0) {
7699 var left1Data = homeUtil.data.left1;
7700 left1Data.value = left1;
7701 left1Data.name = libjq.i18n.prop("echarts_left1");
7702 chartOptions.series[0].data.push(left1Data);
7703 }
7704 var alertData = homeUtil.data.alert;
7705 alertData.value = total / 200;
7706 alertData.name = libjq.i18n.prop("echarts_alert");
7707 chartOptions.series[0].data.push(alertData);
7708 if (alarm > 0) {
7709 var alarmData = homeUtil.data.alarm;
7710 alarmData.value = alarm;
7711 alarmData.name = libjq.i18n.prop("echarts_alarm");
7712 chartOptions.series[0].data.push(alarmData);
7713 }
7714 var freeData = homeUtil.data.free;
7715 freeData.value = left;
7716 freeData.name = libjq.i18n.prop("echarts_free");
7717 chartOptions.series[0].data.push(freeData);
7718 }
7719 }
7720 } else {
7721 chartOptions.series[0].data = [];
7722 if (info.limitTimeMonth == 0) {
7723 var usedData = homeUtil.data.used;
7724 usedData.value = 1;
7725 usedData.selected = false;
7726 usedData.name = libjq.i18n.prop("echarts_used");
7727 chartOptions.series[0].data.push(usedData);
7728 } else {
7729 total = info.limitTimeMonth;
7730 used = info.data_counter.monthlyConnectedTime;
7731 reach = total * info.limitVolumePercent / 100;
7732 if (used >= total) {
7733 var fullTime = homeUtil.data.full;
7734 fullTime.value = 100;
7735 fullTime.name = libjq.i18n.prop("echarts_full");
7736 chartOptions.series[0].data.push(fullTime);
7737 startName = libjq.i18n.prop("echarts_full");
7738 } else {
7739 if (reach - used > 0) {
7740 left1 = reach - used;
7741 left = total - reach;
7742 } else {
7743 alarm = used - reach;
7744 left = total - used;
7745 }
7746 var usedTime = homeUtil.data.used;
7747 if (reach - used > 0) {
7748 usedTime.value = used;
7749 } else {
7750 usedTime.value = reach;
7751 }
7752 usedTime.name = libjq.i18n.prop("echarts_used");
7753 chartOptions.series[0].data.push(usedTime);
7754 if (left1 > 0) {
7755 var left1Time = homeUtil.data.left1;
7756 left1Time.value = left1;
7757 left1Time.name = libjq.i18n.prop("echarts_left1");
7758 chartOptions.series[0].data.push(left1Time);
7759 }
7760 var alertTime = homeUtil.data.alert;
7761 alertTime.value = total / 200;
7762 alertTime.name = libjq.i18n.prop("echarts_alert");
7763 chartOptions.series[0].data.push(alertTime);
7764 if (alarm > 0) {
7765 var alarmTime = homeUtil.data.alarm;
7766 alarmTime.value = alarm;
7767 alarmTime.name = libjq.i18n.prop("echarts_alarm");
7768 chartOptions.series[0].data.push(alarmTime);
7769 }
7770 var freeTime = homeUtil.data.free;
7771 freeTime.value = left;
7772 freeTime.name = libjq.i18n.prop("echarts_free");
7773 chartOptions.series[0].data.push(freeTime);
7774 }
7775 }
7776 }
7777 } else {
7778 var usedData = homeUtil.data.used;
7779 usedData.value = 1;
7780 usedData.selected = false;
7781 usedData.name = libjq.i18n.prop("echarts_no");
7782 chartOptions.series[0].data = [usedData];
7783 chartOptions.title.text = '';
7784 }
7785 var firstEle = libus.find(chartOptions.series[0].data, function (n) {
7786 return n.name == libjq.i18n.prop("echarts_used");
7787 });
7788 var alarmEle = libus.find(chartOptions.series[0].data, function (n) {
7789 return n.name == libjq.i18n.prop("echarts_alarm");
7790 });
7791 if (!alarmEle) {
7792 alarmEle = {
7793 value: 0
7794 };
7795 }
7796 if (typeof firstEle == "undefined") {
7797 homeUtil.setEcharts(chartOptions, startName);
7798 } else if (homeUtil.oldUsedData != firstEle.value || homeUtil.oldAlarmData != alarmEle.value) {
7799 homeUtil.oldUsedData = firstEle.value;
7800 homeUtil.oldAlarmData = alarmEle.value;
7801 homeUtil.setEcharts(chartOptions, startName);
7802 }
7803 },
7804 getUnitValue: function (unit) {
7805 unit = unit.toUpperCase();
7806 if (unit == 'GB') {
7807 return '1024';
7808 } else if (unit == 'TB') {
7809 return '1048576';
7810 } else {
7811 return '1';
7812 }
7813 },
7814 setEcharts: function (options, startName) {
7815 var startPart = homeUtil.data.start;
7816 startPart.value = 0;
7817 startPart.name = startName;
7818 startPart.selected = false;
7819 var arr = [startPart].concat(options.series[0].data);
7820 options.series[0].data = arr;
7821 traffic_graphic_chart.setOption(options, true);
7822 addTimeout(function () {
7823 traffic_graphic_chart.resize();
7824 }, 1000);
7825 },
7826 refreshStationInfo: function (param) {
7827 param.wirelessDeviceNum(fnc.getStatusInfo().wirelessDeviceNum);
7828 if (num_refresh % 10 == 2) {
7829 fnc.getAttachedCableDevices({}, function (data) {
7830 param.wireDeviceNum(data.attachedDevices.length);
7831 });
7832 }
7833 },
7834 getUnit: function (val) {
7835 if (val == '1024') {
7836 return 'GB';
7837 } else if (val == '1048576') {
7838 return 'TB';
7839 } else {
7840 return 'MB';
7841 }
7842 },
7843 refreshOpmodeInfo: function (param) {
7844 var obj = fnc.getOpMode();
7845 param.isLoggedIn(obj.loginfo == "ok");
7846 var currentMode = checkCableMode(obj.blc_wan_mode);
7847 if (param.opCurMode() && !currentMode) {
7848 var data = fnc.getLoginData();
7849 var state = data.modem_main_state;
7850 if (state == "modem_sim_undetected" || state == "modem_undetected" || state == "modem_sim_destroy" || state == "modem_waitpin" || state == "modem_waitpuk" || state == "modem_imsi_waitnck") {
7851 window.location.reload();
7852 return;
7853 }
7854 }
7855 param.opCurMode(currentMode);
7856 if (currentMode && obj.ethwan_mode == "DHCP") {
7857 param.enableFlag(false);
7858 } else if ((!currentMode && obj.ppp_status != "ppp_disconnected") || (currentMode && obj.rj45_state != "idle" && obj.rj45_state != "dead")) {
7859 param.enableFlag(true);
7860 } else {
7861 param.enableFlag(false);
7862 }
7863 var mode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;
7864 var currentOpMode = "";
7865 switch (mode) {
7866 case "AUTO":
7867 currentOpMode = "opmode_auto";
7868 break;
7869 case "PPPOE":
7870 currentOpMode = "opmode_cable";
7871 break;
7872 case "PPP":
7873 currentOpMode = "opmode_gateway";
7874 break;
7875 default:
7876 break;
7877 }
7878 libjq("#opmode").attr("data-trans", currentOpMode).text(libjq.i18n.prop(currentOpMode));
7879 param.isShowHomeConnect(!currentMode);
7880 param.showTraffic(set.TRAFFIC_SUPPORT && !currentMode);
7881 param.isSupportQuicksetting(set.HAS_QUICK_SETTING && !currentMode);
7882 }
7883 };
7884 function VmHome() {
7885 var target = this;
7886 target.hasSms = set.HAS_SMS;
7887 target.hasPhonebook = set.HAS_PHONEBOOK;
7888 target.isSupportSD = set.SD_CARD_SUPPORT;
7889 target.isCPE = set.PRODUCT_TYPE == 'CPE';
7890 target.hasRj45 = set.RJ45_SUPPORT;
7891 target.notDataCard = set.PRODUCT_TYPE != 'DATACARD';
7892 target.hasParentalControl = set.HAS_PARENTAL_CONTROL;
mj.qu28df13a2025-01-07 19:14:21 -08007893 target.hasUssd = set.HAS_USSD;
w.dengd463b342024-12-20 10:21:38 +08007894 var wifiInfo = fnc.getWifiBasic();
7895 if (set.WIFI_SUPPORT_QR_SWITCH) {
7896 target.showQRCode = set.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;
7897 } else {
7898 target.showQRCode = set.WIFI_SUPPORT_QR_CODE;
7899 }
7900 if(set.WIFI_SUPPORT_QR_CODE){
7901 target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + libjq.now();
7902 } else {
7903 target.qrcodeSrc = './pic/res_blacktrans.png';
7904 }
7905 if (target.hasRj45) {
7906 var opModeObj = checkCableMode(fnc.getOpMode().blc_wan_mode);
7907 target.opCurMode = libko.observable(opModeObj);
7908 target.isShowHomeConnect = libko.observable(!opModeObj);
7909 target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT && !opModeObj);
7910 target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING && !opModeObj);
7911 } else {
7912 target.isShowHomeConnect = libko.observable(true);
7913 target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT);
7914 target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING);
7915 }
7916 if (set.PRODUCT_TYPE == 'DATACARD') {
7917 libjq('#home_image').addClass('data-card');
7918 }
7919 var info = fnc.getConnectionInfo();
7920 target.networkType = libko.observable(homeUtil.getNetworkType(info.networkType));
7921 target.connectStatus = libko.observable(info.connectStatus);
7922 target.canConnect = libko.observable(false);
7923 target.cStatus = libko.computed(function () {
7924 if (target.connectStatus().indexOf('_connected') != -1) {
7925 return connStat.CONNECTED;
7926 } else if (target.connectStatus().indexOf('_disconnecting') != -1) {
7927 return connStat.DISCONNECTING;
7928 } else if (target.connectStatus().indexOf('_connecting') != -1) {
7929 return connStat.CONNECTING;
7930 } else {
7931 return connStat.DISCONNECTED;
7932 }
7933 });
7934 target.current_Flux = libko.observable(transUnit(0, false));
7935 target.connected_Time = libko.observable(transSecond2Time(0));
7936 target.up_Speed = libko.observable(transUnit(0, true));
7937 target.down_Speed = libko.observable(transUnit(0, true));
7938 target.isLoggedIn = libko.observable(false);
7939 target.enableFlag = libko.observable(true);
7940 target.simSerialNumber = libko.observable('');
7941 target.imei = libko.observable('');
7942 target.imsi = libko.observable('');
mj.qu28df13a2025-01-07 19:14:21 -08007943 target.iccid = libko.observable('');
7944 target.cellid = libko.observable('');
w.dengd463b342024-12-20 10:21:38 +08007945 target.ssid = libko.observable('');
7946 target.hasWifi = set.HAS_WIFI;
7947 target.showMultiSsid = libko.observable(set.HAS_MULTI_SSID && wifiInfo.multi_ssid_enable == "1");
7948 target.trafficAlertEnable = libko.observable(false);
7949 target.trafficUsed = libko.observable('');
7950 target.trafficLimited = libko.observable('');
7951 target.wireDeviceNum = libko.observable(fnc.getAttachedCableDevices().attachedDevices.length);
7952 target.wirelessDeviceNum = libko.observable(fnc.getStatusInfo().wirelessDeviceNum);
7953 target.showOpModeWindow = function () {
7954 if (target.enableFlag()) {
7955 return;
7956 }
7957 showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});
7958 };
7959 target.currentOpMode = libko.observable("0");
7960 var popoverShown = false;
7961 libjq('#showDetailInfo').popover({
7962 html: true,
7963 placement: 'top',
7964 trigger: 'focus',
7965 title: function () {
7966 return libjq.i18n.prop('device_info')
7967 },
7968 content: function () {
7969 return getDetailInfoContent();
7970 }
7971 }).on('shown.bs.popover', function () {
7972 popoverShown = true;
7973 }).on('hidden.bs.popover', function () {
7974 popoverShown = false;
7975 });
7976 function fetchDeviceInfo() {
7977 var data = fnc.getDeviceInfo();
7978 target.simSerialNumber(verifyDeviceInfo(data.simSerialNumber));
7979 target.imei(verifyDeviceInfo(data.imei));
7980 target.imsi(verifyDeviceInfo(data.imsi));
mj.qu28df13a2025-01-07 19:14:21 -08007981 target.iccid(verifyDeviceInfo(data.iccid));
7982 target.cellid(verifyDeviceInfo(data.cellid));
w.dengd463b342024-12-20 10:21:38 +08007983 target.ssid(verifyDeviceInfo(data.ssid));
7984 target.showMultiSsid(set.HAS_MULTI_SSID && data.multi_ssid_enable == "1");
7985 return data;
7986 }
7987 fetchDeviceInfo();
7988 function getDetailInfoContent() {
7989 var data = fetchDeviceInfo();
7990 homeUtil.initShownStatus(data);
7991 var addrInfo = homeUtil.wanIpGet(data);
7992 var compiled = libus.template(libjq("#detailInfoTmpl").html());
7993 var tmpl = compiled({
7994 simSerialNumber: verifyDeviceInfo(data.simSerialNumber),
7995 imei: verifyDeviceInfo(data.imei),
7996 imsi: verifyDeviceInfo(data.imsi),
mj.qu28df13a2025-01-07 19:14:21 -08007997 iccid : verifyDeviceInfo(data.iccid),
7998 cellid: verifyDeviceInfo(data.cellid),
w.dengd463b342024-12-20 10:21:38 +08007999 signal: signalFormat(data.signal),
8000 hasWifi: set.HAS_WIFI,
8001 isCPE: set.PRODUCT_TYPE == 'CPE',
8002 hasRj45: set.RJ45_SUPPORT,
8003 showMultiSsid: set.HAS_MULTI_SSID && data.multi_ssid_enable == "1",
8004 ssid: verifyDeviceInfo(data.ssid),
8005 max_access_num: verifyDeviceInfo(data.max_access_num),
8006 m_ssid: verifyDeviceInfo(data.m_ssid),
8007 m_max_access_num: verifyDeviceInfo(data.m_max_access_num),
8008 wifi_long_mode: "wifi_des_" + data.wifiRange,
8009 lanDomain: verifyDeviceInfo(data.lanDomain),
8010 ipAddress: verifyDeviceInfo(data.ipAddress),
8011 showMacAddress: set.SHOW_MAC_ADDRESS,
8012 macAddress: verifyDeviceInfo(data.macAddress),
8013 showIpv4WanIpAddr: homeUtil.initStatus.showIpv4WanIpAddr,
8014 wanIpAddress: addrInfo.wanIpAddress,
8015 showIpv6WanIpAddr: homeUtil.initStatus.showIpv6WanIpAddr,
8016 ipv6WanIpAddress: addrInfo.ipv6WanIpAddress,
8017 sw_version: verifyDeviceInfo(data.sw_version),
8018 hw_version: verifyDeviceInfo(data.hw_version)
8019 });
8020 return libjq(tmpl).translate();
8021 }
8022 target.connectHandler = function () {
8023 if (target.connectStatus() == "ppp_connected") {
8024 showLoading('disconnecting');
8025 fnc.disconnect({}, function (data) {
8026 if (data.result) {
8027 successOverlay();
8028 } else {
8029 errorOverlay();
8030 }
8031 });
8032 } else {
8033 if (fnc.getStatusInfo().roamingStatus) {
8034 showConfirm('dial_roaming_connect', function () {
8035 target.connect();
8036 });
8037 } else {
8038 target.connect();
8039 }
8040 }
8041 };
8042 target.connect = function () {
8043 var statusInfo = fnc.getStatusInfo();
8044 var trafficResult = barStat.getTrafficResult(statusInfo);
8045 if (statusInfo.limitVolumeEnable && trafficResult.showConfirm) {
8046 var confirmMsg = null;
8047 if (trafficResult.usedPercent > 100) {
8048 confirmMsg = {
8049 msg: 'traffic_beyond_connect_msg'
8050 };
8051 barStat.setTrafficAlertPopuped(true);
8052 } else {
8053 confirmMsg = {
8054 msg: 'traffic_limit_connect_msg',
8055 params: [trafficResult.limitPercent]
8056 };
8057 barStat.setTrafficAlert100Popuped(false);
8058 }
8059 showConfirm(confirmMsg, function () {
8060 homeUtil.doConnect();
8061 });
8062 } else {
8063 homeUtil.doConnect();
8064 }
8065 };
8066 fnc.getSignalStrength({}, function (data) {
8067 var signalTxt = signalFormat(convertSignal(data));
8068 libjq("#fresh_signal_strength").text(signalTxt);
8069 if (popoverShown) {
8070 libjq("#popoverSignalTxt").text(signalTxt);
8071 }
8072 });
8073 homeUtil.refreshHomeData(target);
8074 addInterval(function () {
8075 fnc.getSignalStrength({}, function (data) {
8076 var signalTxt = signalFormat(convertSignal(data));
8077 libjq("#fresh_signal_strength").text(signalTxt);
8078 if (popoverShown) {
8079 libjq("#popoverSignalTxt").text(signalTxt);
8080 }
8081 });
8082 homeUtil.refreshHomeData(target);
8083 }, 1000);
8084 if (target.hasRj45) {
8085 homeUtil.refreshOpmodeInfo(target);
8086 addInterval(function () {
8087 homeUtil.refreshOpmodeInfo(target);
8088 }, 1000);
8089 }
8090 target.showNetworkSettingsWindow = function () {
8091 if (target.hasRj45) {
8092 fnc.getOpMode({}, function (data) {
8093 var mode = checkCableMode(data.blc_wan_mode);
8094 if (mode) {
8095 window.location.hash = '#network_set';
8096 } else {
8097 window.location.hash = '#conn_set';
8098 }
8099 });
8100 } else {
8101 window.location.hash = '#conn_set';
8102 }
8103 }
8104 };
8105 return {
8106 init: init
8107 };
8108});
8109
8110
8111define("language","knockout service jquery set underscore".split(" "),
8112 function(ko, service, $, config, _) {
8113
8114 // ��ȡ��ǰ������
8115 function getCurrentLanguage() {
8116 return service.getLanguage();
8117 }
8118
8119 // ��������������������Դ������ҳ���ϵ�body����
8120 // @param {String} current ������:zh-cn
8121 function loadLanguageAndRefresh(current){
8122 window.CURRENT_LANGUAGE = current;
8123 $("body").attr('lang', current);
8124 $.i18n.properties({
8125 name:'Messages',
8126 path:'i18n/',
8127 mode:'map',
8128 cache: true,
8129 language:current,
8130 callback: function() {
8131 jQuery.validator.messages = $.i18n.map;
8132 $('body').translate();
8133 }
8134 });
8135 }
8136
8137 window.language = null;
8138
8139
8140 function LanguageViewModel() {
8141 var target = this;
8142 var currentLan = getCurrentLanguage();
8143 var languages = _.map(config.LANGUAGES, function(item) {
8144 return new Option(item.name, item.value);
8145 });
8146
8147 document.title = config.WEBUI_TITLE;
8148 if($('#webui_title')[0]) {
8149 $('#webui_title').html(config.WEBUI_TITLE);
8150 }
8151
8152 target.languages = ko.observableArray(languages);
8153 target.currentLan = ko.observable(currentLan.Language);
8154 window.language = target.currentLan();
8155
8156 // �л������¼�����
8157 // @event langChangeHandler
8158 target.langChangeHandler = function(info, event) {
8159 clearValidateMsg();
8160
8161 service.setLanguage({Language: target.currentLan()}, function() {
8162 loadLanguageAndRefresh(target.currentLan());
8163 window.language = target.currentLan();
8164 });
8165 };
8166
8167 // ���������б���ˢ�½���
8168 loadLanguageAndRefresh(target.currentLan());
8169 }
8170
8171 // ��ʼ������VM������
8172 function init() {
8173 ko.applyBindings(new LanguageViewModel(), $('#language')[0]);
8174 }
8175
8176 return {
8177 init: init
8178 };
8179});
8180
8181
8182// ��½ ģ��
8183define("entry","jquery knockout set service underscore menu logout CryptoJS".split(" "),
8184 function($, ko,config, service, _, menu, logout, CryptoJS) {
8185
8186
8187 var pageState = {LOGIN:0, WAIT_PIN:1, WAIT_PUK:2, PUK_LOCKED:3, LOGGEDIN:4, LOADING:5};
8188 var timer = loginStatusCheckingTimer();
8189 var loginLockTimer = 0;
8190 var lastLoginStatus = "0";
8191
8192 function loginViewModel() {
8193 var target = this;
8194 var data = service.getLoginData();
8195 var loginStatus = service.getLoginStatus();
8196
8197 target.confirmPIN = ko.observable();
8198 target.leftSeconds = ko.observable(0);
8199 target.loginCount = ko.observable(0);
8200 target.loginSecuritySupport = ko.observable(config.LOGIN_SECURITY_SUPPORT);
8201 target.newPIN = ko.observable();
8202 target.password = ko.observable();
8203 target.PIN = ko.observable();
8204 target.pinNumber = ko.observable(data.pinnumber);
8205 target.PUK = ko.observable();
8206 target.pukNumber = ko.observable(data.puknumber);
8207 target.showEntrance = ko.observable(false);
8208 target.sharePathInvalid = ko.observable(false);
8209 target.uiLoginTimer = ko.observable(300);
8210
8211 // ע��˳�򣬵���ǰ�����޷�ˢ�³�����
8212 target.accountLocked = ko.computed(function () {
8213 return target.loginCount() == config.MAX_LOGIN_COUNT && target.leftSeconds() != '-1';
8214 });
8215
8216 target.leftUnlockTime = ko.computed(function () {
8217 target.leftSeconds();
8218 var formatted = transSecond2Time(target.uiLoginTimer());
8219 return formatted.substring(formatted.indexOf(':') + 1, formatted.length);
8220 });
8221
8222
8223 if(config.SD_CARD_SUPPORT){
8224 service.getSDConfiguration({}, function (data) {
8225 target.showEntrance(data.sd_status == "1" && data.share_status == "1" && data.sd_mode == "0");
8226 if(target.showEntrance()){
8227 service.checkFileExists({
8228 path: data.share_file
8229 }, function (data1) {
8230 if (data1.status == 'exist' || data1.status == 'processing') {
8231 target.sharePathInvalid(false);
8232 } else {
8233 target.sharePathInvalid(true);
8234 }
8235 });
8236 }
8237 });
8238 }
8239
8240 var state = computePageState(loginStatus, data);
8241 target.pageState = ko.observable(state);
8242 if (state == pageState.LOADING) {
8243 addTimeout(refreshPage, 500);
8244 }
8245 setFocus();
8246
8247
8248 // login �¼�����
8249
8250 target.login = function () {
8251 if(config.LOGIN_SECURITY_SUPPORT && target.accountLocked()){
8252 showAlert("password_error_account_lock_time", function () {
8253 setFocus();
8254 });
8255 return false;
8256 }
8257 target.pageState(pageState.LOADING);
8258 window.clearInterval(timer);
8259 var ciphertext = "";
8260 if (config.PASSWORD_ENCODE) {
8261 ciphertext = target.password();
8262 } else {
8263 var kparam = service.getDeviceInfoLow();
8264 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
8265 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
8266 ciphertext = CryptoJS.AES.encrypt(target.password(), tkey, {
8267 iv: tiv,
8268 mode: CryptoJS.mode.CBC,
8269 padding: CryptoJS.pad.ZeroPadding
8270 }).toString();
8271 }
8272 service.login({
8273 password:ciphertext
8274 }, function (info) {
8275 setTimeout(function () {
8276 timer = loginStatusCheckingTimer();
8277 }, 1300);
8278 if (info.result) {
8279 target.pageState(pageState.LOGGEDIN);
8280 if(config.LOGIN_SECURITY_SUPPORT){
8281 target.loginCount(0);
8282 target.uiLoginTimer(300);
8283 clearInterval(loginLockTimer);
8284 }
8285 $("#container").empty();
8286 window.location.hash = "#main";
8287 logout.init();
8288 } else {
8289 target.password("");
8290 if(config.LOGIN_SECURITY_SUPPORT){
8291 target.checkLoginData(function(){
8292 if (target.loginCount() == config.MAX_LOGIN_COUNT) {
8293 showAlert("password_error_five_times", function () {
8294 setFocus();
8295 });
8296 target.startLoginLockInterval();
8297 } else {
8298 showAlert({msg: 'password_error_left', params: [config.MAX_LOGIN_COUNT - target.loginCount()]}, function () {
8299 setFocus();
8300 });
8301 }
8302 });
8303 }else {
8304 showAlert("password_error", function () {
8305 setFocus();
8306 });
8307 }
8308 target.pageState(pageState.LOGIN);
8309 }
8310 });
8311 };
8312
8313
8314
8315
8316 // ��ȡ��¼������Ϣ
8317 target.checkLoginData = function(cb){
8318 service.getLoginData({}, function(r){
8319 var failTimes = parseInt(r.psw_fail_num_str, 10);
8320 target.loginCount(config.MAX_LOGIN_COUNT - failTimes);
8321 target.leftSeconds(r.login_lock_time);
8322 target.uiLoginTimer(r.login_lock_time);
8323 if($.isFunction(cb)){
8324 cb();
8325 } else if (target.loginCount() == config.MAX_LOGIN_COUNT) {
8326 target.startLoginLockInterval();
8327 }
8328 });
8329 };
8330
8331 // ��������ʱ��ʱ����
8332 target.startLoginLockInterval = function () {
8333 loginLockTimer = setInterval(function () {
8334 service.getLoginData({}, function (data) {
8335 if (data.login_lock_time <= 0 || data.psw_fail_num_str == 5) {
8336 target.loginCount(0);
8337 clearInterval(loginLockTimer);
8338 }
8339 if(target.leftSeconds() != data.login_lock_time){
8340 target.leftSeconds(data.login_lock_time);
8341 target.uiLoginTimer(data.login_lock_time);
8342 } else {
8343 target.uiLoginTimer(target.uiLoginTimer() > 0 ? target.uiLoginTimer() - 1 : 0);
8344 }
8345 });
8346 }, 1000);
8347 };
8348
8349 target.checkLoginData();
8350
8351
8352
8353 // ��֤����PIN�¼�����
8354 target.enterPIN = function () {
8355 target.pageState(pageState.LOADING);
8356 var pin = target.PIN();
8357 service.enterPIN({
8358 PinNumber:pin
8359 }, function (data) {
8360 if (!data.result) {
8361 showAlert("pin_error", function () {
8362 refreshPage();
8363 });
8364 target.PIN('');
8365 } else {
8366 refreshPage();
8367 }
8368 });
8369 };
8370
8371 function setFocus(){
8372 setTimeout(function () {
8373 var txtAdmin = $('#txtAdmin:visible');
8374 var txtPIN = $('#txtPIN:visible');
8375 var txtPUK = $('#txtPUK:visible');
8376 if (txtAdmin.length > 0) {
8377 txtAdmin.focus();
8378 } else if (txtPIN.length > 0) {
8379 txtPIN.focus();
8380 } else if (txtPUK.length > 0) {
8381 txtPUK.focus();
8382 }
8383 }, 100);
8384 }
8385
8386
8387 // ˢ��ҳ��״̬
8388 function refreshPage() {
8389 var data = service.getLoginData();
8390 var loginStatus = service.getLoginStatus();
8391 var state = computePageState(loginStatus, data);
8392 if (state == pageState.LOADING) {
8393 addTimeout(refreshPage, 500);
8394 } else {
8395 target.pageState(state);
8396 target.pinNumber(data.pinnumber);
8397 target.pukNumber(data.puknumber);
8398 }
8399 setFocus();
8400 }
8401
8402 // ����PUK������PIN�¼�����
8403 target.enterPUK = function () {
8404 target.pageState(pageState.LOADING);
8405 var newPIN = target.newPIN();
8406 var confirmPIN = target.confirmPIN();
8407 var params = {};
8408 params.PinNumber = newPIN;
8409 params.PUKNumber = target.PUK();
8410 service.enterPUK(params, function (data) {
8411 if (!data.result) {
8412 showAlert("puk_error", function () {
8413 refreshPage();
8414 });
8415 target.PUK('');
8416 target.newPIN('');
8417 target.confirmPIN('');
8418 } else {
8419 refreshPage();
8420 }
8421 });
8422 };
8423
8424
8425
8426 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8427 function checkPinAfterLogin(loginStatus, data) {
8428 if (loginStatus.status == "loggedIn") {
8429 var currentState = data.modem_main_state; // cov_2
8430 if (currentState == "modem_waitpin") {
8431 return pageState.WAIT_PIN;
8432 } else if ((currentState == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {
8433 return pageState.WAIT_PUK;
8434 } else if ((data.puknumber == 0 || currentState == "modem_sim_destroy")
8435 && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
8436 return pageState.PUK_LOCKED;
8437 } else {
8438 return pageState.LOGGEDIN;
8439 }
8440 } else {
8441 var currentState = data.modem_main_state;
8442 if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8443 return pageState.LOADING;
8444 } else {
8445 return pageState.LOGIN;
8446 }
8447 }
8448 }
8449
8450 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8451 function computePageState(loginStatus, data) {
8452 //PX-880 �ȵ�¼�ٽ���PIN��֤������router����ԭ�򣬵�¼����PIN��֤���ڵ�¼ҳ�����У������ݿ�����֤����һ�¡�
8453 if (config.LOGIN_THEN_CHECK_PIN) {
8454 return checkPinAfterLogin(loginStatus, data);
8455 } else {
8456 return loginAfterCheckPin(loginStatus, data);
8457 }
8458 }
8459
8460 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8461 function loginAfterCheckPin(loginStatus, data) {
8462 if (loginStatus.status == "loggedIn") {
8463 return pageState.LOGGEDIN;
8464 } else {
8465 var currentState = data.modem_main_state;
8466 if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8467 return pageState.LOADING;
8468 } else if (currentState == "modem_waitpin") {
8469 return pageState.WAIT_PIN;
8470 } else if ((currentState == "modem_waitpuk" || parseInt(data.pinnumber) === 0) && (parseInt(data.puknumber) != 0)) {
8471 return pageState.WAIT_PUK;
8472 } else if ((parseInt(data.puknumber) === 0 || currentState == "modem_sim_destroy") && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
8473 return pageState.PUK_LOCKED;
8474 } else {
8475 return pageState.LOGIN;
8476 }
8477 }
8478 }
8479 }
8480
8481
8482 // ���鵱ǰwindow.location.hash���쳣����ת��index.html
8483 function gotoLogin() {
8484 if (window.location.hash != config.defaultRoute && _.indexOf(config.GUEST_HASH, window.location.hash) == -1) {
8485 if (!manualLogout && lastLoginStatus == "1") {
8486 manualLogout = false;
8487 lastLoginStatus = 'UNREAL';
8488 showAlert('need_login_again', function () {
8489 window.location = "index.html";
8490 });
8491 } else if (lastLoginStatus == 'UNREAL') {
8492 //do nothing, only popup need_login_again alert one time
8493 return;
8494 } else {
8495 window.location = "index.html";
8496 }
8497 }
8498 }
8499
8500 // ��ʱ������¼״̬
8501 function loginStatusCheckingTimer() {
8502 return setInterval(function () {
8503 var info = service.getStatusInfo();
8504 if (!info.isLoggedIn) {
8505 gotoLogin();
8506 return;
8507 }
8508 lastLoginStatus = service.getStatusInfo().isLoggedIn ? "1" : "0";
8509 }, 1000);
8510 }
8511
8512 function init() {
8513 var info = service.getStatusInfo();
8514 if (info.isLoggedIn) {
8515 window.location.hash = '#main';
8516 return;
8517 }
8518
8519 var container = $('#container')[0];
8520 ko.cleanNode(container);
8521 var fwVm = new loginViewModel();
8522 ko.applyBindings(fwVm, container);
8523
8524 $('#frmLogin').validate({
8525 submitHandler:function () {
8526 fwVm.login();
8527 },
8528 rules: {
8529 txtAdmin: 'login_password_length_check'
8530 }
8531 });
8532 $('#frmPIN').validate({
8533 submitHandler:function () {
8534 fwVm.enterPIN();
8535 },
8536 rules:{
8537 txtPIN:"pin_check"
8538 }
8539 });
8540 $('#frmPUK').validate({
8541 submitHandler:function () {
8542 fwVm.enterPUK();
8543 },
8544 rules:{
8545 txtNewPIN:"pin_check",
8546 txtConfirmPIN:{equalToPin:"#txtNewPIN"},
8547 txtPUK:"puk_check"
8548 }
8549 });
8550 }
8551
8552
8553 return {
8554 init:init,
8555 gotoLogin:gotoLogin
8556 };
8557 });
8558
8559
8560// Logout �
8561define("logout","set service knockout underscore jquery".split(" "),
8562 function (config, service, ko, _, $) {
8563
8564 function logoutViewModel() {
8565 var target = this;
8566 // ��ȡ�Ƿ���¼
8567 var loginFlag = function () {
8568 var loginInfo = service.getLoginStatus();
8569 return (loginInfo.status == "loggedIn");
8570 }
8571 ();
8572 target.loggedIn = ko.observable(loginFlag);
8573
8574 // �˳�ϵͳ
8575 target.logout = function () {
8576 showConfirm("confirm_logout", function () {
8577 manualLogout = true;
8578 service.logout({}, setLocation());
8579 });
8580 };
8581
8582 // �Ƿ���ʾ�˳���ť
8583 target.showLogout = function () {
8584 if (config.HAS_LOGIN) {
8585 return target.loggedIn();
8586 } else {
8587 return false;
8588 }
8589 };
8590 }
8591 function setLocation() {
8592 window.location = 'index.html';
8593 }
8594 function initialize() {
8595 var fwVm = new logoutViewModel();
8596 bindContainer(fwVm);
8597 }
8598 function bindContainer(fwVm) {
8599 var con = $('#logout')[0];
8600 ko.cleanNode(con);
8601 ko.applyBindings(fwVm, con);
8602 }
8603 return {
8604 init: initialize
8605 };
8606});
8607
8608// operation mode �
8609define("opmode","knockout service jquery set underscore".split(" "),
8610
8611 function (ko, service, $, config, _) {
8612
8613 function currentOperationModeViewMode(){
8614 var target = this;
8615 target.isLoggedIn = ko.observable(false);
8616 target.enableFlag = ko.observable(false);
8617
8618 target.showOpModeWindow = function () {
8619 showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {
8620 });
8621 };
8622 target.currentOpMode = ko.observable("0");
8623
8624 service.getOpMode({}, function(info){
8625 target.isLoggedIn(info.loginfo == "ok");
8626 if (info.opms_wan_mode != "PPP" && info.rj45_state != "idle" && info.rj45_state != "dead") {
8627 target.enableFlag(false);
8628 } else if (info.opms_wan_mode == "PPP" && info.ppp_status != "ppp_disconnected") {
8629 target.enableFlag(false);
8630 } else if(info.opms_wan_mode == "DHCP"){
8631 target.enableFlag(true);
8632 } else {
8633 target.enableFlag(true);
8634 }
8635
8636 var opmsWanMode = (info.opms_wan_mode == "DHCP" || info.opms_wan_mode == "STATIC") ? "PPPOE" : info.opms_wan_mode;
8637
8638 var currentOperationMode = "";
8639 switch(opmsWanMode){
8640 case "BRIDGE":
8641 currentOperationMode = "opmode_bridge";
8642 break;
8643 case "PPP":
8644 currentOperationMode = "opmode_gateway";
8645 break;
8646 case "PPPOE":
8647 currentOperationMode = "opmode_cable";
8648 break;
8649 default:
8650 break;
8651 }
8652 $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
8653 });
8654 // ��ʱ��ѯ����ģʽ����״̬�����ý���״̬
8655 setInterval(function(){
8656 var object = service.getConnectionInfo();
8657 if(object.opms_wan_mode == "DHCP") {
8658 target.enableFlag(true);
8659 } 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")) {
8660 target.enableFlag(false);
8661 } else {
8662 target.enableFlag(true);
8663 }
8664 }, 1000);
8665 }
8666
8667 function init() {
8668 var container = $('#currentOpMode')[0];
8669 ko.cleanNode(container);
8670 var fwVm = new currentOperationModeViewMode();
8671 ko.applyBindings(fwVm, container);
8672 }
8673
8674 return {
8675 init:init
8676 };
8677});
8678
8679// operation mode popup�
8680
8681define("opmode_popup","knockout service jquery set underscore".split(" "),
8682
8683 function (ko, service, $, config, _) {
8684
8685 function operationModeViewMode() {
8686 var target = this;
8687 var currentSelectedOperationMode = "";
8688 target.selectedMode = ko.observable("0");
8689
8690 // ��ʼ������ģʽ��ʾ
8691 service.getOpMode({}, function(info){
8692 if(info.blc_wan_mode == "AUTO_PPP"){
8693 currentSelectedOperationMode = "AUTO";
8694 }else if(info.blc_wan_mode == "AUTO_PPPOE"){
8695 currentSelectedOperationMode = "AUTO";
8696 }else if(info.blc_wan_mode == "PPPOE"){
8697 currentSelectedOperationMode = "PPPOE";
8698 }else{
8699 currentSelectedOperationMode = info.blc_wan_mode;
8700 }
8701 target.selectedMode(currentSelectedOperationMode);
8702 });
8703
8704 // ģʽ����/�л�
8705 target.changeOpMode = function(){
8706 var userSelectedOperationMode = $('input:radio[name="opMode"]:checked').val();
8707 var messageText = "";
8708 if(userSelectedOperationMode == currentSelectedOperationMode) {
8709 hidePopupSettingWindow();
8710 return;
8711 }
8712 if(userSelectedOperationMode == "LTE_BRIDGE"){
8713 messageText = "opmode_msg3";
8714 }else{
8715 messageText = "opmode_msg2";
8716 }
8717 showConfirm(messageText, function(){
8718 showLoading();
8719 service.SetOperationMode({
8720 opMode: userSelectedOperationMode
8721 },function(info){
8722 if (info && info.result == "success") {
8723 var currentOperationMode = "";
8724 switch(userSelectedOperationMode){
8725 case "AUTO":
8726 currentOperationMode = "opmode_auto"
8727 break;
8728 case "PPP":
8729 currentOperationMode = "opmode_gateway";
8730 break;
8731 case "PPPOE":
8732 currentOperationMode = "opmode_cable";
8733 break;
8734 default:
8735 break;
8736 }
8737 $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
8738 successOverlay();
8739 } else {
8740 errorOverlay();
8741 }
8742 });
8743 });
8744
8745 }
8746
8747 }
8748
8749 function init() {
8750 var fwVm = new operationModeViewMode();
8751 ko.applyBindings(fwVm, $('#popupSettingWindow')[0]);
8752
8753 $("#opmode_form").validate({
8754 submitHandler: function(){
8755 fwVm.changeOpMode();
8756 }
8757 });
8758 }
8759
8760 return {
8761 init:init
8762 };
8763});
8764
8765define("router","underscore jquery menu set service".split(" "),
8766 function (_, $, menu, config, service) {
8767 var currentHash = '';
8768 var container = $('#container');
8769
8770 //�뿪����ʱ�����Ƿ��������޸ģ�����������ʾ
8771 checkFormContentModify = function (href) {
8772 if (config.CONTENT_MODIFIED.modified && window.location.hash != href) {
8773 if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {
8774 config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
8775 config.resetContentModifyValue();
8776 window.location.hash = href;
8777 } else {
8778 showConfirm(config.CONTENT_MODIFIED.message, {
8779 ok: function () {
8780 config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
8781 config.resetContentModifyValue();
8782 window.location.hash = href;
8783 },
8784 no: function () {
8785 var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);
8786 if (!result) {
8787 window.location.hash = href;
8788 config.resetContentModifyValue();
8789 }
8790 }
8791 });
8792 }
8793 return false;
8794 } else {
8795 return true;
8796 }
8797 };
8798
8799 //��ʱ�鿴SIM����״̬������ǰSIM��״̬��Ϊ����״̬��δ��ʾnosimcardҳ�棬����ʾnosimcardҳ��,�Ա��ⲻ�ر�webui�����²����豸�󣬲����ж�SIM��״̬������
8800 function checkSimCardStatus() {
8801 setInterval(function () {
8802 var data = service.getStatusInfo();
8803 var match = menu.findMenu();
8804 if (match.length == 0) {
8805 return false;
8806 }
8807 var requirePinHash = ["phonebook", "sms_list"];
8808 var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
8809 if (match[0].checkSIMStatus === true) {
8810 var simstatus = data.simStatus == "modem_sim_undetected"
8811 || data.simStatus == "modem_sim_destroy" || data.simStatus == "modem_waitpin"
8812 || data.simStatus == "modem_waitpuk";
8813 var netlockstatus = data.simStatus == "modem_imsi_waitnck";
8814 if (data.isLoggedIn && (
8815 ($('#div-nosimcard')[0] == undefined && simstatus)
8816 || ($('#div-network-lock')[0] == undefined && netlockstatus)
8817 || (($('#div-nosimcard')[0] != undefined || $('#div-network-lock')[0] != undefined) && data.simStatus == "modem_init_complete"))) {
8818 fixedLoadResources(match[0], data.simStatus, isRequirePin);
8819 }
8820 }
8821 }, 1000);
8822 }
8823
8824 //������¼ҳ�汳��
8825 function checkLoginPageBg() {
8826 var h = window.location.hash;
8827 if (h == '#entry' || _.indexOf(config.GUEST_HASH, h) != -1) {
8828 $("#manageContainer").attr("style", "margin-top:-36px;");
8829 } else {
8830 $("#manageContainer").attr("style", "margin-top:0px;");
8831 }
8832
8833 if (window.location.hash == '#entry') {
8834 $("#mainContainer").addClass('loginBackgroundBlue');
8835 } else {
8836 var mainContainer = $("#mainContainer");
8837 if (mainContainer.hasClass('loginBackgroundBlue')) {
8838 $("#container").css({
8839 margin: 0
8840 });
8841 mainContainer.removeClass('loginBackgroundBlue').height('auto');
8842 }
8843 }
8844 }
8845
8846 function fixedLoadResources(menuItem, simStatus, isRequirePin) {
8847 var item = {};
8848 $.extend(item, menuItem);
8849 //û��SIM��ʱ������homeҳ�治��������
8850 //���类��ʱ��homeҳ����ʾ����ҳ��
8851 if (simStatus == "modem_sim_undetected" || simStatus == "modem_sim_destroy") {
8852 if (!isRequirePin) {
8853 item.path = "sim_abnormal";
8854 }
8855 } else if (simStatus == "modem_waitpin" || simStatus == "modem_waitpuk") {
8856 item.path = "sim_abnormal";
8857 } else if (simStatus == "modem_imsi_waitnck") {
8858 item.path = "locknet";
8859 }
8860 //load tmpl and controller js
8861 loadResources(item);
8862 }
8863
8864 //���ݲ˵�����item���ض�Ӧ����Դ
8865 function loadResources(item) {
8866 var pId = item.path.replace(/\//g, '_');
8867 var $body = $('body').removeClass();
8868 if (pId != 'entry' && pId != 'main') {
8869 $body.addClass('beautiful_bg page_' + pId);
8870 } else {
8871 $body.addClass('page_' + pId);
8872 }
8873 clearTimer();
8874 hideLoading();
8875 var tmplPath = 'text!tmpl/' + item.path + '.html';
8876 //TODO: prevent first menu click cover the second menu content, need test with device
8877 require([tmplPath, item.path], function (tmpl, viewModel) {
8878 container.stop(true, true);
8879 container.hide();
8880 container.html(tmpl);
8881 viewModel.init();
8882 //support backward/forward
8883 menu.refreshMenu();
8884 $('#container').translate();
8885 menu.activeSubMenu();
8886
8887 $("form").attr("autocomplete", "off");
8888 container.fadeIn();
8889 });
8890 }
8891 //�ȶ�hash״̬, �����仯�������µ�hashƥ���˵�����,ƥ�䲻��ʱ��ת��homeҳ��, ƥ����ʱ��¼hashֵ����̬���ض�Ӧ����Դ�ļ�
8892 function hashCheck() {
8893 if (window.location.hash != currentHash) {
8894 //������½����������, ��½�û����ʷǵ�¼�û�ʱҳ�治��ת
8895 var info = service.getStatusInfo();
8896 if (window.location.hash == config.defaultRoute || _.indexOf(config.GUEST_HASH, window.location.hash) != -1) {
8897 if (info.isLoggedIn) {
8898 window.location.hash = currentHash == "" ? "#main" : currentHash;
8899 return;
8900 }
8901 }
8902
8903 var match = menu.findMenu();
8904
8905 if (match.length == 0) {
8906 window.location.hash = config.defaultRoute;
8907 } else {
8908 //��¼ʱ���鹤��ģʽ������ģʽ������������Ҫ����SIM��״̬�����¼���,����ģʽ�������治��Ҫ����SIM��״̬�����¼���
8909 if (config.RJ45_SUPPORT && window.location.hash == "#main") {
8910 if ((match[0].checkSIMStatus && checkCableMode(info.blc_wan_mode)) || (!match[0].checkSIMStatus && !checkCableMode(info.blc_wan_mode))) {
8911 window.location.reload();
8912 return;
8913 }
8914 }
8915 //TODO: �����˵�����Ӧ�����˵���һ����л�ʱ�����¼�������, ��TODO: click the same menu ʵ�ַ�ʽ����
8916 var oldMenu = menu.findMenu(currentHash);
8917 currentHash = match[0].hash;
8918 if (currentHash == "#entry") {
8919 $('#indexContainer').addClass('login-page-bg');
8920 menu.rebuild();
8921 } else {
8922 $('#indexContainer').removeClass('login-page-bg');
8923 }
8924
8925 if (oldMenu.length != 0 && match[0].path == oldMenu[0].path && match[0].level != oldMenu[0].level && match[0].level != '1' && oldMenu[0].level != '1') {
8926 return;
8927 }
8928
8929 checkLoginPageBg();
8930 var requirePinHash = ["phonebook", "sms_list"];
8931 var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
8932 if (match[0].checkSIMStatus === true || isRequirePin) {
8933 //simStatus is undefined when refreshing page
8934 if (info.simStatus == undefined) {
8935 showLoading('waiting');
8936 function checkSIM() {
8937 var data = service.getStatusInfo();
8938 if (data.simStatus == undefined || $.inArray(data.simStatus, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8939 addTimeout(checkSIM, 500);
8940 } else {
8941 fixedLoadResources(match[0], data.simStatus, isRequirePin);
8942 hideLoading();
8943 }
8944 }
8945 checkSIM();
8946 } else {
8947 fixedLoadResources(match[0], info.simStatus, isRequirePin);
8948 }
8949 } else {
8950 loadResources(match[0]);
8951 }
8952 }
8953 }
8954 }
8955
8956 //Ĭ������ҳ��Ϊ#main, ��ʱ����hash״̬
8957 function init() {
8958 checkSimCardStatus();
8959 window.location.hash = window.location.hash || "#main";
8960 //if support onhashchange then use. If ie8 in ie7 mode, it doesn't trigger onhashchange.
8961 if (('onhashchange' in window) && ((typeof document.documentMode === 'undefined') || document.documentMode == 8)) {
8962 window.onhashchange = hashCheck;
8963 hashCheck();
8964 } else {
8965 setInterval(hashCheck, 200);
8966 }
8967
8968 //�����޸���ҳ������, �뿪ʱ������ʾ
8969 $("a[href^='#']").die('click').live('click', function () {
8970 var $this = $(this);
8971 config.CONTENT_MODIFIED.checkChangMethod();
8972 return checkFormContentModify($this.attr('href'));
8973 });
8974 }
8975
8976 return {
8977 init: init
8978 };
8979});
8980
8981// statusBar �
8982
8983define("statusBar", "knockout jquery underscore service set menu tooltip".split(" "),
8984
8985 function (ko, $, _, service, config, menu, tooltip) {
8986
8987 var sv__hasCheckedSMSCapacity = false;
8988 var sv__initSMSCompleted = false;
8989 var sv_newSMSMessageInDealing = false;
8990 var sv_fotaUpdateCancel = null;
8991 var sv_batteryCheckTimer = 0;
8992 var sv_dbMessageIds = [];
8993 var sv_fotaResultAlertPopuped = false;
8994 var sv_isFirstLoadNewMessage = true;
8995 var isLoggedIn = true;
8996 var sv_messagePopStack = {};
8997 var sv_newMessagePopTemplate = null;
8998 var sv_resetTrafficAlertPopuped = false;
8999 var sv_simMessageListTemplate = null;
9000 var sv_smsListTemplate = null;
9001 var sv_trafficAlertPopuped_100 = false;
9002 var sv_trafficAlertPopuped = false;
9003 var sv_timer = 0;
9004
9005 // ��ȡ״̬��Ϣ�������硢SIM��WIFI��
9006 var getCurrentStatusInfo = function () {
9007 return service.getStatusInfo();
9008 };
9009
9010 function statusViewModel() {
9011 var target = this;
9012 var info = getCurrentStatusInfo();
9013 var roamStatus = info.roamingStatus ? true : false;
9014 var $langLogoBar = $("#langLogoBar");
9015
9016
9017 // �������������¼�����
9018 function sf_connect() {
9019 showLoading("connecting");
9020 service.connect({}, function (data) {
9021 if (data.result) {
9022 refreshWifiConnectStatus(target, data.status);
9023 }
9024 successOverlay();
9025 }, function (data) {
9026 errorOverlay();
9027 });
9028 }
9029 // �Ͽ������¼�����
9030 function sf_disconnect() {
9031 showLoading("disconnecting");
9032 service.disconnect({}, function (data) {
9033 if (data.result) {
9034 refreshWifiConnectStatus(target, data.status);
9035 }
9036 successOverlay();
9037 }, function (data) {
9038 errorOverlay();
9039 });
9040 }
9041
9042 if(info.isLoggedIn){
9043 if(!$langLogoBar.hasClass("langborderBg")){
9044 $langLogoBar.addClass("langborderBg");
9045 }
9046 $("#statusBar:hidden").show();
9047 } else {
9048 if($langLogoBar.hasClass("langborderBg")){
9049 $langLogoBar.removeClass("langborderBg");
9050 }
9051 $("#statusBar:visible").hide();
9052 }
9053
9054
9055 //target.attachedDevices = ko.observable(info.attachedDevices);
9056 target.batteryLevel = ko.observable(info.batteryLevel + '%');
9057 target.batteryPers = ko.observable(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
9058 target.batteryStatus = ko.observable(info.batteryStatus);
9059 target.connectionCssClass = ko.observable("");
9060 target.connectStatus = ko.observable(info.connectStatus);
9061 target.connectStatusText = ko.observable();
9062 target.connectStatusTrans = ko.observable();
9063 target.hasWifi = ko.observable(config.HAS_WIFI);
9064 target.hasBattery = ko.observable(config.HAS_BATTERY);
9065 target.isLoggedIn = ko.observable(info.isLoggedIn);
9066 target.isShowConnectionIcon = ko.observable(false);
9067 target.isShowFotaNewversionIcon = ko.observable(info.new_version_state && info.fota_package_already_download != "yes" && !config.isShowFotaIcon);
9068 target.isShowRj45ConnectionIcon = ko.observable(false);
9069 target.networkOperator = ko.observable(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,roamStatus));
9070 target.networkType = ko.observable(getNetworkType(info.networkType));
9071 target.pinStatus = ko.observable(info.pinStatus);
9072 target.pinStatusText = ko.observable();
9073 target.rj45ConnectionCssClass = ko.observable("");
9074 target.roamingStatus = ko.observable(info.roamingStatus ? "R" : "");
9075 target.showAttachedDevices = ko.observable(info.wifiStatus);
9076 target.showSmsDeleteConfirm = ko.observable(false);
9077 target.smsUnreadCount = ko.observable(0);
9078 target.simStatus = ko.observable(sf_convertSimStatusToImage(info.simStatus));
9079 target.signalCssClass = ko.observable(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
9080 target.updateType = ko.observable(service.getUpdateType().update_type);
9081 target.wifiStatusCssClass = ko.observable(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
9082 target.wifiStatusImg = ko.observable(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
9083
9084 sf_getConnectionCssClass(target, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
9085
9086 target.connect = sf_connect;
9087 target.disconnect = sf_disconnect;
9088 }
9089
9090 function sf_gotoSmsList(){
9091 var s_href = '#msg_main';
9092 if(window.location.hash == '#msg_main'){
9093 s_href = '#msg_list';
9094 }
9095 config.CONTENT_MODIFIED.checkChangMethod();
9096 if(checkFormContentModify(s_href)){
9097 window.location.hash = s_href;
9098 }
9099 }
9100
9101 gotoSmsList = sf_gotoSmsList;
9102
9103 function sf_getNetWorkProvider(i_spnB1Flag, i_spnNameData, i_spnB2Flag, i_networkProvider, i_roamStatus) {
9104 if (i_spnNameData == "") {
9105 return i_networkProvider;
9106 } else {
9107 i_spnNameData = decodeMessage(i_spnNameData);
9108 if (i_spnB1Flag == "0" && i_spnB2Flag == "0") {
9109 if (i_roamStatus) {//����
9110 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9111 } else {//������
9112 return i_spnNameData;
9113 }
9114 }else if (i_spnB1Flag == "1" && i_spnB2Flag == "1") {
9115 if (i_roamStatus) {//����
9116 return i_networkProvider;
9117 } else {//������
9118 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9119 }
9120 } else if (i_spnB1Flag == "1") {
9121 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9122 } else if (i_spnB2Flag == "1") {
9123 if (i_roamStatus) {//����
9124 return i_networkProvider;
9125 } else {//������
9126 return i_spnNameData;
9127 }
9128 }
9129 return "";
9130 }
9131 }
9132
9133 // �����¶���Ϣ��ʾ����������������
9134 function sf_addNewMessage(i_message, i_isUpdate, i_type){
9135 config.smsMaxId = i_message.id;
9136 var now = $.now();
9137 sv_messagePopStack["m" + now] = now;
9138 var name = i_message.number;
9139 if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
9140 sv_isFirstLoadNewMessage = false;
9141 if(config.HAS_PHONEBOOK){
9142 sf_getPhoneBooks();
9143 }else{
9144 config.phonebook = [];
9145 }
9146 }
9147 for(i in config.phonebook){
9148 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9149 name = config.phonebook[i].pbm_name;
9150 break;
9151 }
9152 }
9153 var s_newMsg = {
9154 mark : "m" + now,
9155 name: name,
9156 title: $.i18n.prop("sms"),
9157 titleTrans: "sms",
9158 tag: i_message.tag,
9159 content : i_message.content,
9160 datetime : i_message.time
9161 };
9162 if(sv_newMessagePopTemplate == null){
9163 sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
9164 }
9165 $(".bubbleItem:not(.report)", "#buttom-bubble").remove();
9166 $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
9167 if((window.location.hash == "#msg_main" || window.location.hash == "#msg_list") && i_type == "1"){
9168 //sf_dealChosenNumber(s_newMsg.name, i_message.number);
9169 var s_inChating = config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
9170 var s_itemId = getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
9171 var item = $("#smslist-item-" + s_itemId);
9172 if(item && item.length > 0){
9173 // �Ѵ������ݣ��������ݵ���˳��
9174 for(var i = 0; config.listMsgs && i < config.listMsgs.length; i++){
9175 if(getLastNumber(config.listMsgs[i].number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9176 config.listMsgs[i].id = i_message.id;
9177 config.listMsgs[i].latestId = i_message.id;
9178 config.listMsgs[i].latestSms = i_message.content;
9179 config.listMsgs[i].latestTime = i_message.time;
9180 if(!i_isUpdate){
9181 config.listMsgs[i].newCount++;
9182 config.listMsgs[i].totalCount++;
9183 }
9184 break;
9185 }
9186 }
9187 item.find(".smslist-item-checkbox p.checkbox").attr("id", i_message.id);
9188 item.find(".smslist-item-checkbox input:checkbox").val(i_message.id).attr("id", "checkbox" + i_message.id);
9189 if(!i_isUpdate){
9190 var s_itemCount = item.find(".smslist-item-total-count").text();
9191 s_itemCount = Number(s_itemCount.substring(1, s_itemCount.length - 1));
9192 item.find(".smslist-item-total-count").text("(" + (s_itemCount + 1) + ")");
9193 if(!config.currentChatObject || config.currentChatObject != getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9194 var s_newNum = item.find(".smslist-item-new-count").removeClass("hide");
9195 if(s_newNum && s_newNum.text().length > 0){
9196 s_newNum.text(Number(s_newNum.text()) + 1);
9197 }else{
9198 s_newNum.text(1);
9199 }
9200 }
9201 }
9202 if(item.find(".smslist-item-draft-flag").length > 0){
9203 if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
9204 item.find(" td:nth-child(2)").removeClass("font-weight-bold");
9205 } else {
9206 item.find(" td:nth-child(2)").addClass("font-weight-bold");
9207 }
9208 }else{
9209 var msgContent = item.find(".smslist-item-msg").text(i_message.content);
9210 msgContent.closest('td').prop('title', i_message.content);
9211 item.find("span.clock-time").text(i_message.time);
9212 if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
9213 msgContent.closest('tr').removeClass("font-weight-bold");
9214 } else {
9215 msgContent.closest('tr').addClass("font-weight-bold");
9216 }
9217 }
9218 item.find(".smslist-item-repeat span").die().click(function() {
9219 forwardClickHandler(i_message.id);
9220 });
9221
9222 var s_tmpItem = item;
9223 item.hide().remove();
9224 $("#smslist-table").prepend(s_tmpItem.show());
9225 } else {
9226 // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
9227 var s_theName = "";
9228 if(config.phonebook && config.phonebook.length > 0) {
9229 for(i in config.phonebook){
9230 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9231 s_theName = config.phonebook[i].pbm_name;
9232 break;
9233 }
9234 }
9235 }
9236 var s_theNewMessage = {
9237 id : i_message.id,
9238 name : s_theName,
9239 number : i_message.number,
9240 latestId :i_message.id,
9241 totalCount : 1,
9242 newCount : s_inChating ? 0 : 1,
9243 latestSms : i_message.content,
9244 latestTime : i_message.time,
9245 checked : false,
9246 hasDraft : false,
9247 itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
9248 };
9249 if(sv_smsListTemplate == null){
9250 sv_smsListTemplate = $.template("smsTableTmpl", $("#smsTableTmpl"));
9251 }
9252 $.tmpl("smsTableTmpl", {data: [s_theNewMessage]}).prependTo("#smslist-table");
9253 }
9254 if(config.HAS_PHONEBOOK){
9255 $(".sms-add-contact-icon").removeClass("hide");
9256 }else{
9257 $(".sms-add-contact-icon").addClass("hide");
9258 }
9259 if(s_inChating){
9260 var talkItem = $("#talk-item-" + i_message.id, "#chatlist");
9261 if (talkItem && talkItem.length > 0) {// ���¼�����������
9262 $(".J_content pre", talkItem).html(dealContent(i_message.content));
9263 $(".time .smslist-item-time", talkItem).text(i_message.time);
9264 $(".smslist-item-repeat", talkItem).die().click(
9265 function() {
9266 forwardClickHandler(i_message.id);
9267 });
9268 $(".smslist-item-delete", talkItem).die().click(
9269 function() {
9270 deleteSingleItemClickHandler(i_message.id);
9271 });
9272 } else {// �����µĻظ�����
9273 $("#smsOtherTmpl").tmpl(i_message).appendTo("#chatlist");
9274 $(".clear-container", "#chatpanel").animate({
9275 scrollTop : $("#chatlist").height()
9276 });
9277 }
9278 if (!config.SMS_SET_READ_WHEN_COMPLETE) {
9279 service.setSmsRead({ids: [i_message.id]}, $.noop);
9280 } else if (config.SMS_SET_READ_WHEN_COMPLETE && i_message.receivedAll) {
9281 service.setSmsRead({ids: [i_message.id]}, $.noop);
9282 }
9283 }
9284 enableCheckbox($("#smslist-checkAll"));
9285 }
9286 if(window.location.hash == "#msg_sim" && i_type == "0"){
9287 // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
9288 var s_theName = "";
9289 if(config.phonebook && config.phonebook.length > 0) {
9290 for(i in config.phonebook){
9291 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9292 s_theName = config.phonebook[i].pbm_name;
9293 break;
9294 }
9295 }
9296 }
9297 var s_theNewMessage = {
9298 id : i_message.id,
9299 name : s_theName,
9300 number : i_message.number,
9301 content : i_message.content,
9302 time : i_message.time,
9303 tag: i_message.tag,
9304 checked : false,
9305 itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
9306 };
9307 if(i_isUpdate){
9308 var s_item = $(".simMsgList-item-class-" + s_theNewMessage.id);
9309 s_item.hide().remove();
9310 }
9311 if(sv_simMessageListTemplate == null){
9312 sv_simMessageListTemplate = $.template("ssimMessageListTemplate", $("#simMessageListTemplate"));
9313 }
9314 $.tmpl("simMessageListTemplate", {data: [s_theNewMessage]}).prependTo("#simMsgList_container");
9315 }
9316 }
9317
9318 function sf_checkBatteryStatusForFota(){
9319 var s_state = service.getCurrentUpgradeState();
9320 if(s_state.current_upgrade_state == 'low_battery'){
9321 showInfo('ota_low_battery');
9322 clearInterval(sv_batteryCheckTimer);
9323 }
9324 }
9325
9326 // ��SIM��״̬ת��Ϊ��Ӧ����������
9327 function sf_convertSimStatusToImage(i_status) {
9328 var s_image;
9329 switch (i_status) {
9330 case "modem_destroy":
9331 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
9332 break;
9333 case "modem_imsi_waitnck":
9334 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitnck");
9335 break;
9336 case "modem_init_complete":
9337 s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
9338 break;
9339 case "modem_sim_destroy":
9340 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
9341 break;
9342 case "modem_sim_undetected":
9343 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_undetected");
9344 break;
9345 case "modem_undetected":
9346 s_image = "./pic/simcard_undetected.png";
9347 break;
9348 case "modem_waitpin":
9349 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpin");
9350 break;
9351 case "modem_waitpuk":
9352 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpuk");
9353 break;
9354
9355 default:
9356 s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
9357 break;
9358 }
9359 return s_image;
9360 }
9361
9362 function sf_dealChosenNumber(i_choosenName, i_choosenNum) {
9363 setTimeout(function () {
9364 var s_choosen = $("#chosenUserSelect");
9365 var s_options = $("option", s_choosen);
9366 for (var index = 0; index < s_options.length; index++) {
9367 if (getLastNumber(i_choosenNum, config.SMS_MATCH_LENGTH) == s_options[index].value) {
9368
9369 s_options[index].text = i_choosenName + '/' + i_choosenNum;
9370 s_options[index].value = i_choosenNum;
9371
9372 break;
9373 }
9374 }
9375 s_choosen.trigger("liszt:updated");
9376 }, 0);
9377 }
9378
9379 // ˫�첽��ȡ�豸����sim�����ö���Ϣ���������ϲ�
9380 function sf_dealPhoneBooksResult(i_books){
9381 if($.isArray(i_books.pbm_data) && i_books.pbm_data.length > 0){
9382 config.phonebook = i_books.pbm_data;
9383 }
9384 }
9385
9386 // �������µ�5������Ϣ����δ���ӵ������б��еĵ�����ʾ
9387 function sf_filterNewMessage(i_messages, i_type){
9388 if(!config.dbMsgs){
9389 config.dbMsgs = [];
9390 }
9391 if(sv_dbMessageIds.length == 0){
9392 $.each(config.dbMsgs, function(index_1, i_element){
9393 sv_dbMessageIds.push(i_element.id);
9394 });
9395 }
9396 $.each(i_messages, function(index_2, i_element){
9397 if($.inArray(i_element.id, sv_dbMessageIds) == -1){//�����¶���
9398 sv_dbMessageIds.push(i_element.id);
9399 config.dbMsgs.push(i_element);
9400 if(i_element.tag == '1'){
9401 sf_addNewMessage(i_element, false, i_type);
9402 }
9403 }else{
9404 for(var index = 0; index < config.dbMsgs.length; index++){//���¼�������
9405 if(config.dbMsgs[index].id == i_element.id && config.dbMsgs[index].content != i_element.content && i_element.tag == '1'){
9406 config.dbMsgs[index].content = i_element.content;
9407 sf_addNewMessage(i_element, true, i_type);
9408 break;
9409 }
9410 }
9411 }
9412 });
9413 }
9414
9415 // ������ת��Ϊ��ӦͼƬ
9416 function sf_getBatteryLevelImage(pers, i_status) {
9417 var s_Image = null;
9418 if ("0" == i_status) {
9419 if ("1" == pers) {
9420 s_Image = "pic/power_one.png";
9421 } else if ("2" == pers) {
9422 s_Image = "pic/power_two.png";
9423 } else if ("3" == pers) {
9424 s_Image = "pic/power_three.png";
9425 } else if ("4" == pers) {
9426 s_Image = "pic/power_full.png";
9427 } else { //"5" == pers || "0" == pers
9428 s_Image = "pic/power_out.png";
9429 }
9430 } else {
9431 s_Image = "pic/power_charging.gif";
9432 }
9433 return s_Image;
9434 }
9435
9436 // ��ȡ����״̬��CSS��ʽ
9437 function sf_getConnectionCssClass(i_fwVm, i_status, i_data_counter, i_wifiSSID, i_wifiStatus, i_rj45Status) {
9438
9439 var s_rj45ConnectionStatus = "icon_connection ";
9440 var s_connectionStatus = "icon_connection ";
9441
9442 if(i_rj45Status == "connect"){
9443 s_rj45ConnectionStatus += "connecting";
9444 }else if(i_rj45Status == "working"){
9445 s_rj45ConnectionStatus += "rj45_connected";
9446 }else{
9447 s_rj45ConnectionStatus += "disconnect";
9448 }
9449
9450 if (i_status == "ppp_connecting" || i_status == "wifi_connecting") {
9451 s_connectionStatus += "connecting";
9452 } else if(i_status == "ppp_connected") {//CPE ppp_statusΪnone ready��ֵ
9453 if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate != '0') {
9454 s_connectionStatus += "connectionBoth";
9455 } else if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate == '0') {
9456 s_connectionStatus += "connectionUp";
9457 } else if (i_data_counter.uploadRate == '0' && i_data_counter.downloadRate != '0') {
9458 s_connectionStatus += "connectionDown";
9459 } else {
9460 s_connectionStatus += "connectionNone";
9461 }
9462 } else if (i_status == "ppp_disconnected") {
9463 if (i_wifiSSID && i_wifiStatus == "connect") {
9464 service.getHotspotList({}, function (data) {
9465 var s_cssName = "icon_connection ";
9466 var s_css = "connecting ";
9467 for (var i = 0, len = data.hotspotList.length; i < len; i++) {
9468 if (data.hotspotList[i].connectStatus == "1") {
9469 s_css = "wifi_connected";
9470 break;
9471 }
9472 }
9473 s_cssName += s_css;
9474 i_fwVm.connectionCssClass(s_cssName);
9475 });
9476 i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
9477 return;
9478 } else if (i_wifiSSID && (i_wifiStatus == "connecting" || i_wifiStatus =="dhcping")) {
9479 s_connectionStatus += "connecting";
9480 } else {
9481 s_connectionStatus += "disconnect";
9482 }
9483 } else {
9484 s_connectionStatus += "disconnect";
9485 }
9486
9487 i_fwVm.connectionCssClass(s_connectionStatus);
9488 i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
9489 }
9490
9491 // ��ȡ�绰����Ϣ
9492 function sf_getPhoneBooks() {
9493 var s_books = service.getPhoneBooks({
9494 page : 0,
9495 data_per_page : 2000,
9496 orderBy : "id",
9497 isAsc : false
9498 });
9499 sf_dealPhoneBooksResult(s_books);
9500 }
9501
9502 // ��ȡ�ź�����CSS��ʽ
9503 function sf_getSignalCssClass(siganl, networkType, simStatus) {
9504 networkType = networkType.toLowerCase();
9505 simStatus = simStatus ? simStatus.toLowerCase() : '';
9506 if(networkType == '' || networkType == 'limited_service' || networkType == 'no_service' || networkType == 'limited service' || networkType == 'no service'
9507 || simStatus != 'modem_init_complete'){
9508 siganl = '_none';
9509 }
9510 return "signal signal" + siganl;
9511 }
9512
9513 function sf_getWifiStatusCssClass(i_status, i_deviceSize) {
9514 if (i_status) {
9515 if (i_deviceSize == 0) {
9516 return "wifi_status0";
9517 } else {
9518 return "wifi_status" + i_deviceSize;
9519 }
9520 } else {
9521 return "wifi_status_off";
9522 }
9523 }
9524
9525 // ����wifi״̬��ȡwifi��ͼƬ��Դ
9526 function sf_getWifiStatusImage(i_status, i_deviceSize) {
9527 if (i_status) {
9528 if (i_deviceSize == 0) {
9529 return "./pic/wlan0.png";
9530 } else {
9531 return "./pic/wlan" + i_deviceSize + ".png";
9532 }
9533 } else {
9534 return "./pic/wlan_off.png";
9535 }
9536 }
9537
9538 // ��ȡ��������������С���������ؽ���
9539 function sf_refreshFotaDownloadProgress(){
9540 service.getPackSizeInfo({}, function (data) {
9541 var percents;
9542 if (parseInt(data.fota_pkg_total_size) == 0) {
9543 percents = 0;
9544 } else {
9545 percents = parseInt(parseInt(data.fota_dl_pkg_size) * 100 / parseInt(data.fota_pkg_total_size));
9546 }
9547 if (percents > 100) {
9548 percents = 100;
9549 }
9550 if (percents >= 0) {
9551 if (percents > 95) {
9552 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
9553 }
9554 setProgressBar(percents);
9555 }
9556 });
9557 }
9558
9559 // �������ŷ��ͱ���
9560 function sf_responseSmsReport(){
9561 if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
9562
9563 sv_isFirstLoadNewMessage = false;
9564
9565 if(config.HAS_PHONEBOOK){
9566 sf_getPhoneBooks();
9567 }else{
9568 config.phonebook = [];
9569 }
9570 }
9571 service.getSMSDeliveryReport({
9572 page: 0,
9573 smsCount: 10
9574 }, function(data){
9575 var s_messages = data.messages;
9576 var s_nums = [];
9577 $.each(s_messages, function(i, i_message){
9578 if($.inArray(i_message.number, s_nums) == -1){
9579 s_nums.push(i_message.number);
9580 window.setTimeout(function(){
9581 var s_now = $.now();
9582 sv_messagePopStack["m" + s_now] = s_now;
9583 i_message.name = i_message.number;
9584 for(i in config.phonebook){
9585 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9586 i_message.name = config.phonebook[i].pbm_name;
9587 break;
9588 }
9589 }
9590 var s_msgContent = $.i18n.prop("sms_delivery_report_" + i_message.content);
9591
9592 var s_newMsg = {
9593 mark : "m" + s_now,
9594 name: i_message.name,
9595 title: $.i18n.prop("sms_report"),
9596 titleTrans: "sms_report",
9597 content : s_msgContent,
9598 datetime : i_message.time,
9599 report : 'report'
9600 };
9601
9602 if(sv_newMessagePopTemplate == null){
9603 sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
9604 }
9605
9606 $(".report", "#buttom-bubble").remove();
9607 $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
9608 }, 100);
9609 }
9610 });
9611 }, function(){
9612 //No Deal
9613 });
9614 }
9615
9616 function sf_simStatusInvalid(simStatus){
9617 return simStatus == 'modem_sim_undetected' || simStatus == 'modem_undetected' || simStatus == 'modem_sim_destroy'
9618 || simStatus == 'modem_waitpin' || simStatus == 'modem_waitpuk' || simStatus == 'modem_imsi_waitnck';
9619 }
9620
9621 // ��ʾFOTA������ǰ״̬
9622 function sf_showFotaCurrentStatus() {
9623 sv_fotaUpdateCancel = true;
9624 var r = service.getNewVersionState();
9625
9626 function showProgress() {
9627 var upgradingState = ["downloading"];
9628 var info = service.getCurrentUpgradeState();
9629 if(info.current_upgrade_state.toLowerCase() == "idle") {
9630 addTimeout(showProgress, 1000);
9631 } else if(($.inArray(info.current_upgrade_state, upgradingState) != -1)&&(r.fota_new_version_state != "already_has_pkg")) {
9632 hideLoading();
9633 sf_showFotaUpgradeStatus();
9634 }
9635 }
9636 if (!($("#progress").is(":visible"))) {
9637 showProgress();
9638 }
9639 var times = 0;
9640 var getOTAUpgradeState = function () {
9641 var data = null;
9642 if (times <= 3) {
9643 times = times + 1;
9644 data = service.getCurrentUpgradeState();
9645 } else {
9646 data = getCurrentStatusInfo();
9647 }
9648 var state = data.current_upgrade_state;
9649 if(sv_fotaUpdateCancel && isLoggedIn == true){
9650
9651 if(r.fota_new_version_state == "already_has_pkg"){
9652 if(state == 'low_battery'){
9653 hideProgressBar();
9654 sv_fotaUpdateCancel = false;
9655 service.removeTimerThings('fota_current_upgrade_state',function(){});
9656 showInfo('ota_pkg_low_battery');
9657 window.clearTimeout(sv_timer);
9658 return;
9659 }else if(state == 'prepare_install'){
9660 hideProgressBar();
9661 sv_fotaUpdateCancel = false;
9662 service.removeTimerThings('fota_current_upgrade_state',function(){});
9663 showInfo('ota_pkg_download_success');
9664 window.clearTimeout(sv_timer);
9665 sv_batteryCheckTimer = setInterval(function () {
9666 sf_checkBatteryStatusForFota();
9667 }, 1000);
9668 return;
9669 }
9670 }else if(state == 'downloading') {
9671 sf_refreshFotaDownloadProgress();
9672 }else if(state == 'download_failed') {
9673 hideProgressBar();
9674 sv_fotaUpdateCancel = false;
9675 showAlert('ota_download_failed');
9676 window.clearTimeout(sv_timer);
9677 return;
9678 }else if(state == 'low_battery'){
9679 hideProgressBar();
9680 sv_fotaUpdateCancel = false;
9681 service.removeTimerThings('fota_current_upgrade_state',function(){});
9682 showInfo('ota_low_battery');
9683 window.clearTimeout(sv_timer);
9684 return;
9685 }else if(state == 'prepare_install'){
9686 hideProgressBar();
9687 sv_fotaUpdateCancel = false;
9688 service.removeTimerThings('fota_current_upgrade_state',function(){});
9689 showInfo('ota_download_success');
9690 window.clearTimeout(sv_timer);
9691 sv_batteryCheckTimer = setInterval(function () {
9692 sf_checkBatteryStatusForFota();
9693 }, 1000);
9694 return;
9695 }else{
9696 sv_fotaUpdateCancel = false;
9697 hideProgressBar();
9698 window.clearTimeout(sv_timer);
9699 return;
9700 }
9701 sv_timer = window.setTimeout(getOTAUpgradeState , 1000);
9702 }
9703 };
9704
9705 if(sv_fotaUpdateCancel && isLoggedIn == true){
9706 sv_timer = window.setTimeout(getOTAUpgradeState , 100);
9707 }else{
9708 window.clearTimeout(sv_timer);
9709 }
9710 }
9711
9712 // ��ʾFota��������
9713 function sf_showFotaUpdateResult(i_otaResult) {
9714 if ((!($("#loading").is(":visible"))) && (!($("#confirm").is(":visible")))) {
9715 var s_message = i_otaResult ? "ota_update_success" : "ota_update_failed";
9716 sv_fotaResultAlertPopuped = true;
9717 showAlert(s_message, function () {
9718 sv_fotaResultAlertPopuped = false;
9719 if (config.UPGRADE_TYPE == "OTA") {
9720 service.clearUpdateResult({}, $.noop());
9721 }
9722 });
9723 } else {
9724 window.setTimeout(function () {
9725 sf_showFotaUpdateResult(i_otaResult)
9726 }, 1000);
9727 }
9728 }
9729
9730 // ��ʾ��ǰ����״̬
9731 function sf_showFotaUpgradeStatus() {
9732 var s_data = service.getMandatory();
9733 var s_isMandatory = s_data.is_mandatory;
9734 var s_sizeInfo =service.getPackSizeInfo();
9735 var s_percents;
9736
9737 if (parseInt(s_sizeInfo.fota_pkg_total_size) == 0) {
9738 s_percents = 0;
9739 } else {
9740 s_percents = parseInt(parseInt(s_sizeInfo.fota_dl_pkg_size) * 100 / parseInt(s_sizeInfo.fota_pkg_total_size));
9741 }
9742 if (s_percents > 100) {
9743 s_percents = 100;
9744 }
9745
9746 if (s_isMandatory) {
9747 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
9748 } else {
9749 var cancelHtml = "";
9750 if (config.UPGRADE_TYPE == "OTA") {
9751 cancelHtml = "<br/><br/><button id='btnStopUpgrade' onclick='stopOTAUpgrade();' class='btn-1 btn-primary'>" + $.i18n.prop("cancel") + "</button>";
9752 }
9753 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning") + cancelHtml);
9754 }
9755
9756 //setProgressBar(0);
9757 if (s_percents >= 0) {
9758 setProgressBar(s_percents);
9759 }
9760 }
9761
9762
9763
9764
9765
9766 function sf_startFotaUpgrade(){
9767 service.setUpgradeSelectOp({selectOp:'1'},function(result){
9768 if (result.result == "success"){
9769 sf_showFotaCurrentStatus();
9770 }});
9771 }
9772
9773 function cancelFotaUpgrade(){
9774 service.setUpgradeSelectOp({selectOp:'0'},function(result){ });
9775 }
9776
9777
9778 function refreshFotaStatusForUserSelector(choice){
9779 var info = getCurrentStatusInfo();
9780 if(choice){
9781 var modeData = service.getOpMode();
9782 if (!checkConnectedStatus(info.connectStatus, modeData.rj45_state, info.connectWifiStatus)) {
9783 showAlert("ota_network_disconnected");
9784 return;
9785 }
9786
9787 if(info.fota_user_selector == 'none'){
9788 sf_startFotaUpgrade();
9789 }else if(info.fota_user_selector == 'accept'){
9790 sf_showFotaCurrentStatus();
9791 }else if(info.fota_user_selector == 'cancel'){
9792 showAlert("ota_have_cancel");
9793 }else if(info.fota_user_selector == 'downloading_cancel'){
9794 showAlert("ota_have_cancel");
9795 }
9796 }else{
9797 if(info.fota_user_selector == 'none'){
9798 cancelFotaUpgrade();
9799 }else if(info.fota_user_selector == 'accept'){
9800 sf_showFotaCurrentStatus();
9801 }else if(info.fota_user_selector == 'cancel'){
9802 // todo:
9803 }else if(info.fota_user_selector == 'downloading_cancel'){
9804 // todo:
9805 }
9806 }
9807 }
9808
9809
9810 // ��ʾ���°汾�������ж��Ƿ�������ʾ
9811 function showFotaStatusForUserToConfirm(upgradeState) {
9812 var upgState = upgradeState.current_upgrade_state;
9813 if (upgState == 'upgrade_pack_redownload') {
9814 showConfirm("ota_interrupted", {ok: function () {
9815 refreshFotaStatusForUserSelector(1);
9816 }, no: function () {
9817 refreshFotaStatusForUserSelector(0);
9818 }});
9819 } else {
9820 var upgradingState = ["prepare_install", "low_battery",
9821 "connecting_server", "connect_server_success", "downloading", "accept"];
9822 if ($.inArray(upgState, upgradingState) != -1) {
9823 sf_showFotaCurrentStatus();
9824 } else {
9825
9826 showConfirm($.i18n.prop('ota_new_version'), {ok: function () {
9827 refreshFotaStatusForUserSelector(1);
9828 config.ISNOW_NOTICE = false;
9829 }, no: function () {
9830 refreshFotaStatusForUserSelector(0);
9831 config.ISNOW_NOTICE = false;
9832 }});
9833 }
9834 }
9835 }
9836
9837 showOTAAlert = function () {
9838 config.ISNOW_NOTICE = true;
9839 var is_mandatory = service.getMandatory().is_mandatory;
9840 if (is_mandatory) {
9841 sf_showFotaCurrentStatus();
9842 } else {
9843 var upgradeState = {};
9844 upgradeState = service.getCurrentUpgradeState();
9845 showFotaStatusForUserToConfirm(upgradeState);
9846 }
9847 };
9848
9849 // ��ֹFota����
9850 stopOTAUpgrade = function () {
9851 service.setUpgradeSelectOp({selectOp:'2'},function(result){ });
9852 sv_fotaUpdateCancel = false;
9853 window.clearTimeout(sv_timer);
9854 hideLoading();
9855 showAlert('ota_cancel');
9856 };
9857
9858 // �������������Ƿ����ѹ�
9859 function setTrafficAlertPopuped(val){
9860 sv_trafficAlertPopuped = !!val;
9861 sv_trafficAlertPopuped_100 = !!val;
9862 if(!val){
9863 sv_resetTrafficAlertPopuped = true;
9864 }
9865 }
9866
9867 function setTrafficAlert100Popuped(val){
9868 sv_trafficAlertPopuped_100 = !!val;
9869 if(!val){
9870 sv_resetTrafficAlertPopuped = true;
9871 }
9872 }
9873
9874 // ���������ṹ
9875 function getTrafficResult(info){
9876 var s_trafficResult = {
9877 showConfirm : false,
9878 limitPercent : info.limitVolumePercent
9879 };
9880 if(info.limitVolumeType == '1'){
9881 var monthlyTraffic = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
9882 s_trafficResult.usedPercent = monthlyTraffic / info.limitVolumeSize * 100;
9883 if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
9884 s_trafficResult.showConfirm = true;
9885 s_trafficResult.type = 'data';
9886 }
9887 }else{
9888 s_trafficResult.usedPercent = info.data_counter.monthlyConnectedTime / info.limitVolumeSize * 100;
9889 if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
9890 s_trafficResult.showConfirm = true;
9891 s_trafficResult.type = 'time';
9892 }
9893 }
9894 return s_trafficResult;
9895 }
9896
9897 // ��ʼ�� ViewModel����������ͼ����
9898 function init() {
9899 if(config.PRODUCT_TYPE == 'DATACARD') {
9900 $('#statusBar').addClass('padding-right-90');
9901 $('#language').addClass('data-card-language');
9902 }
9903 //preload img
9904 var imgAlert = $('<img />').attr('src', 'pic/res_alert.png');
9905 var imgConfirm = $('<img />').attr('src', 'pic/res_confirm.png');
9906 var imgInfo = $('<img />').attr('src', 'pic/res_info.png');
9907
9908 window.setTimeout(function () {
9909
9910 var fwVm = new statusViewModel();
9911
9912 ko.applyBindings(fwVm, $('#statusBar')[0]);
9913
9914 window.setInterval(function () {
9915 var info = getCurrentStatusInfo();
9916 var s_roamStatus = info.roamingStatus ? true : false;
9917 var $langLogoBar = $("#langLogoBar");
9918 isLoggedIn = info.isLoggedIn;
9919
9920
9921 //fwVm.attachedDevices(info.attachedDevices);
9922 fwVm.batteryLevel(info.batteryLevel + '%');
9923 fwVm.batteryPers(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
9924 fwVm.batteryStatus(info.batteryStatus);
9925 fwVm.isShowFotaNewversionIcon(info.new_version_state && info.fota_user_selector && info.fota_package_already_download != "yes" && config.ISNOW_NOTICE && fwVm.updateType() == 'mifi_fota');
9926 fwVm.isShowRj45ConnectionIcon(config.RJ45_SUPPORT);
9927 fwVm.networkOperator(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,s_roamStatus));
9928 fwVm.networkType(getNetworkType(info.networkType));
9929 fwVm.pinStatus(info.pinStatus);
9930 fwVm.roamingStatus(info.roamingStatus ? "R" : "");
9931 fwVm.showAttachedDevices(info.wifiStatus);
9932 fwVm.simStatus(sf_convertSimStatusToImage(info.simStatus));
9933 fwVm.signalCssClass(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
9934 fwVm.isLoggedIn(info.isLoggedIn);
9935 fwVm.wifiStatusCssClass(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
9936 fwVm.wifiStatusImg(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
9937
9938 if(config.HAS_SMS ){
9939 if(!sv__hasCheckedSMSCapacity && info.isLoggedIn){
9940 checkSMSCapacity(info.smsUnreadCount);
9941 } else {
9942 fwVm.smsUnreadCount(info.smsUnreadCount);
9943 }
9944 }
9945
9946 sf_getConnectionCssClass(fwVm, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
9947 refreshWifiConnectStatus(fwVm, info.connectStatus,info.connectWifiSSID,info.connectWifiStatus);
9948 checkTrafficLimitAlert(fwVm, info);
9949 updateStatusBarTrans({simStatus: info.simStatus, wifiStatus: info.wifiStatus, deviceSize: info.wirelessDeviceNum, networkType: info.networkType});
9950
9951 if(info.isLoggedIn){
9952 $("#statusBar:hidden").show();
9953 } else {
9954 $("#statusBar:visible").hide();
9955 }
9956 }, 500);
9957
9958 if(config.HAS_SMS){
9959 window.setInterval(function(){
9960 if(fwVm.isLoggedIn()){
9961 checkSMSCapacity();
9962 }
9963 }, 10000);
9964 checkSmsModelReady();
9965 }
9966
9967 window.setInterval(function() {
9968 var data = getCurrentStatusInfo();
9969 var upgradingState = ["prepare_install", "low_battery", "download_success","downloading"];
9970
9971 if (fwVm.isLoggedIn() == true && !($("#progress").is(":visible")) && data.defaultWanName != ""){
9972 if ($.inArray(data.current_upgrade_state, upgradingState) != -1){
9973 if(null == sv_fotaUpdateCancel){
9974 if(!data.is_mandatory){
9975 $.modal.close();
9976 }
9977 sf_showFotaCurrentStatus();
9978 }else if(false == sv_fotaUpdateCancel){
9979 sv_fotaUpdateCancel = null;
9980 }
9981 }
9982 }
9983 }, 1000);
9984
9985 var checkFotaUpgradeResult = function () {
9986 var info = service.getStatusInfo();
9987 if (info.isLoggedIn) {
9988 service.getUpgradeResult({}, function (data) {
9989 if (data.upgrade_result == "success") {
9990 sf_showFotaUpdateResult(true);
9991 } else if (data.upgrade_result == "fail") {
9992 sf_showFotaUpdateResult(false);
9993 } else {
9994 window.setTimeout(checkFotaUpgradeResult, 1000);
9995 }
9996 }, function () {
9997 window.setTimeout(checkFotaUpgradeResult, 1000);
9998 });
9999 } else {
10000 window.setTimeout(checkFotaUpgradeResult, 1000);
10001 }
10002 };
10003 if(fwVm.updateType() == "mifi_fota"){
10004 checkFotaUpgradeResult();
10005 window.setInterval(function () {
10006 var info = getCurrentStatusInfo();
10007 if (info.isLoggedIn && info.defaultWanName != "") {
10008 if(info.new_version_state && info.fota_package_already_download != "yes" && !config.ALREADY_NOTICE){
10009 service.getUpgradeResult({}, function (data) {
10010 if (data.upgrade_result == "success") {
10011 sf_showFotaUpdateResult(true);
10012 } else if (data.upgrade_result == "fail") {
10013 sf_showFotaUpdateResult(false);
10014 } else {
10015 if(sv_fotaResultAlertPopuped == false){
10016 config.ALREADY_NOTICE = true;
10017 showOTAAlert();
10018 }
10019 }
10020 });
10021 }
10022 }
10023 }, 1000);
10024 }
10025 function checkSMSCapacity(unreadCount){
10026 service.getSmsCapability({}, function(info){
10027 var showSmsConfirm = false;
10028 if(info.nvTotal != 0 && info.nvUsed >= info.nvTotal){
10029 $("#sms_unread_count").attr("tipTitle", "sms_capacity_is_full");
10030 showSmsConfirm = true;
10031 } else if(info.nvTotal != 0 && info.nvUsed + 5 >= info.nvTotal) {
10032 $("#sms_unread_count").attr("tipTitle", "sms_capacity_will_full");
10033 showSmsConfirm = true;
10034 } else {
10035 $("#sms_unread_count").attr("tipTitle", "sms_unread_count");
10036 }
10037 fwVm.showSmsDeleteConfirm(showSmsConfirm);
10038 if(typeof unreadCount != "undefined"){
10039 fwVm.smsUnreadCount(unreadCount);
10040 }
10041 sv__hasCheckedSMSCapacity = true;
10042 });
10043 }
10044 }, 1200);
10045
10046 tooltip.init();
10047
10048 // ������Ϣģ����ʼ��״̬
10049 function checkSmsModelReady(){
10050 var info = getCurrentStatusInfo();
10051 if(info.isLoggedIn){
10052 service.getSMSReady({}, function (data) {
10053 if (data.sms_cmd_status_result == "1") {
10054 window.setTimeout(function(){checkSmsModelReady();}, 1000);
10055 } else {
10056 sv__initSMSCompleted = true;
10057 }
10058 });
10059 } else {
10060 window.setTimeout(function(){checkSmsModelReady();}, 1000);
10061 }
10062 }
10063
10064 // ������������״̬
10065 checkTrafficLimitAlert = function(fwVm, info){
10066 if(window.location.hash == '#entry'){
10067 return false;
10068 }
10069 var APStationEnabled = config.AP_STATION_SUPPORT ? service.getStatusInfo().ap_station_enable : 'undefined';
10070 var trafficResult = getTrafficResult(info);
10071 var inShow = $("#confirm-container:visible").length > 0;
10072 var notPPP = (config.PRODUCT_TYPE == 'CPE' && checkCableMode(info.blc_wan_mode)) ? true : false;
10073
10074 // ��ȡAp Stationʹ��״̬���������ѷ�ʽ
10075 if (config.AP_STATION_SUPPORT && (typeof APStationEnabled == "undefined" || APStationEnabled === '')) {
10076 service.refreshAPStationStatus({}, $.noop());
10077 return false;
10078 }
10079 APStationEnabled = APStationEnabled == 1;
10080
10081 if (!info.isLoggedIn || inShow || (sv_trafficAlertPopuped && sv_trafficAlertPopuped_100) || !info.limitVolumeEnable || (!APStationEnabled && !(info.connectStatus == "ppp_connected")) || notPPP) {
10082 return false;
10083 }
10084
10085 if(sv_resetTrafficAlertPopuped){
10086 window.setTimeout(function () {
10087 sv_resetTrafficAlertPopuped = false;
10088 }, 2000);
10089 return false;
10090 }
10091
10092 if(trafficResult.showConfirm){
10093
10094 var confirmMessage = null;
10095
10096 if(trafficResult.usedPercent > 100 && !sv_trafficAlertPopuped_100){
10097
10098 sv_trafficAlertPopuped = true;
10099 sv_trafficAlertPopuped_100 = true;
10100
10101 confirmMessage = {msg: APStationEnabled ? 'traffic_beyond_msg' : 'traffic_beyond_disconnect_msg'};
10102
10103 } else if (!sv_trafficAlertPopuped) {
10104
10105 sv_trafficAlertPopuped = true;
10106 sv_trafficAlertPopuped_100 = false;
10107 confirmMessage = {msg: APStationEnabled ? 'traffic_limit_msg' : 'traffic_limit_disconnect_msg',
10108 params: [trafficResult.limitPercent]};
10109 }
10110
10111 if (confirmMessage != null) {
10112 if (APStationEnabled) {
10113 showAlert(confirmMessage);
10114 } else {
10115 showConfirm(confirmMessage, function () {
10116 showLoading("disconnecting");
10117 service.disconnect({}, function (data) {
10118 if (data.result) {
10119 successOverlay();
10120 } else {
10121 errorOverlay();
10122 }
10123 });
10124 });
10125 }
10126 }
10127 }
10128 return true;
10129 };
10130
10131 // ����״̬�е�tooltip
10132 function updateStatusBarTrans(status){
10133 $("#statusItemSimStatus").attr("tipTitle", "sim_status_" + status.simStatus);
10134 if (status.wifiStatus) {
10135 if (status.deviceSize == 0) {
10136 $("#wifi_status").attr("tipTitle","wifi_status_on");
10137 } else {
10138 $("#wifi_status").attr("tipTitle","wifi_status" + status.deviceSize);
10139 }
10140 } else {
10141 $("#wifi_status").attr("tipTitle","wifi_status_off");
10142 }
10143 }
10144
10145
10146 // ˢ��wifi��������״̬
10147 function refreshWifiConnectStatus(fwVm, status, wifiSSID, wifiStatus) {
10148 fwVm.connectStatus(status);
10149 if (status == "ppp_disconnecting") {
10150 fwVm.connectStatusTrans("disconnecting");
10151 fwVm.connectStatusText($.i18n.prop("disconnecting"));
10152 } else if (status == "ppp_connecting") {
10153 fwVm.connectStatusTrans("connecting");
10154 fwVm.connectStatusText($.i18n.prop("connecting"));
10155 } else if (status == "ppp_connected") {
10156 fwVm.connectStatusTrans("connected");
10157 fwVm.connectStatusText($.i18n.prop("connected"));
10158 } else if(wifiSSID){
10159 if(wifiStatus =="dhcping" || wifiStatus =="connecting"){
10160 fwVm.connectStatus("wifi_connecting");
10161 fwVm.connectStatusTrans("connecting");
10162 fwVm.connectStatusText($.i18n.prop("connecting"));
10163 }else if(wifiStatus =="connect"){
10164 fwVm.connectStatus("wifi_connect");
10165 fwVm.connectStatusTrans("connected");
10166 fwVm.connectStatusText($.i18n.prop("connected"));
10167 }else{
10168 fwVm.connectStatus("ppp_disconnected");
10169 fwVm.connectStatusTrans("disconnected");
10170 fwVm.connectStatusText($.i18n.prop("disconnected"));
10171 }
10172 }else{
10173 fwVm.connectStatusTrans("disconnected");
10174 fwVm.connectStatusText($.i18n.prop("disconnected"));
10175 }
10176 }
10177
10178 // ��ȡ��ǰ����״̬
10179 getNetworkType = function(networkType) {
10180 var networkTypeTmp = networkType.toLowerCase();
10181 if (networkTypeTmp == '' || networkTypeTmp == 'limited service') {
10182 networkTypeTmp = 'limited_service';
10183 }
10184 if(networkTypeTmp == 'no service') {
10185 networkTypeTmp = 'no_service';
10186 }
10187 if (networkTypeTmp == 'limited_service' || networkTypeTmp == 'no_service') {
10188 $("#networkType", "#statusBar").attr("data-trans", "network_type_" + networkTypeTmp);
10189 return $.i18n.prop("network_type_" + networkTypeTmp);
10190 } else {
10191 $("#networkType", "#statusBar").removeAttr("data-trans");
10192 return networkType;
10193 }
10194 };
10195
10196 if(config.HAS_SMS && menu.checkIsMenuExist("sms_list")){
10197 window.setInterval(function () {
10198 var info = getCurrentStatusInfo();
10199 if(window.location.hash == "#entry" || sf_simStatusInvalid(info.simStatus)){
10200 return;
10201 }
10202 for(key in sv_messagePopStack){
10203 var val = sv_messagePopStack[key];
10204 if($.now() - val > 5000){
10205 delete(sv_messagePopStack["m" + val]);
10206 var node = $(".bubbleItem#m" + val, "#buttom-bubble");
10207 node.fadeOut(1000, function(){
10208 $(this).remove();
10209 });
10210 }
10211 }
10212 if(info.isLoggedIn){
10213 if(info.newSmsReceived && !sv_newSMSMessageInDealing){
10214 sv_newSMSMessageInDealing = true;
10215 service.resetNewSmsReceivedVar();
10216 sf_checkNewMessages();
10217 }
10218 if(info.smsReportReceived){
10219 service.resetSmsReportReceivedVar();
10220 sf_responseSmsReport();
10221 }
10222 }
10223 }, 1000);
10224
10225 if(config.SMS_DATABASE_SORT_SUPPORT){
10226 window.setInterval(function(){
10227 if(menu.checkIsMenuExist("sms_list")){
10228 var info = getCurrentStatusInfo();
10229 if(info.isLoggedIn && sv__initSMSCompleted && !sv_newSMSMessageInDealing && !sf_simStatusInvalid(info.simStatus)){
10230 sv_newSMSMessageInDealing = true;
10231 sf_checkNewMessages();
10232 }
10233 }
10234 }, 20001);
10235 }
10236 }
10237
10238 function sf_checkNewMessages(){
10239
10240 var s_tags = 1;
10241 var s_smsCount = 5;
10242
10243 if(!config.dbMsgs || config.dbMsgs.length == 0){
10244 s_smsCount = 500;
10245 s_tags = 10;
10246 }
10247 service.getSMSMessages({
10248 page : 0,
10249 smsCount : s_smsCount,
10250 nMessageStoreType : 0,
10251 tags : s_tags,
10252 orderBy : "order by id desc"
10253 }, function(data){
10254 if(data && data.messages){
10255 sf_filterNewMessage(data.messages, 0);
10256 }
10257 sv_newSMSMessageInDealing = false;
10258 });
10259 service.getSMSMessages({
10260 page : 0,
10261 smsCount : s_smsCount,
10262 nMessageStoreType : 1,
10263 tags : s_tags,
10264 orderBy : "order by id desc"
10265 }, function(data){
10266 if(data && data.messages){
10267 sf_filterNewMessage(data.messages, 1);
10268 }
10269 sv_newSMSMessageInDealing = false;
10270 });
10271 }
10272
10273 if(config.HAS_SMS){
10274 $(".bubbleItem", "#buttom-bubble").live("mouseover", function(){
10275 var $this = $(this);
10276 delete(sv_messagePopStack[$this.attr("id")]);
10277 }).live("mouseout", function(){
10278 var $this = $(this);
10279 var now = $.now();
10280 sv_messagePopStack["m" + now] = now;
10281 $this.attr("id", "m" + now);
10282 $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").data("targetid", "m" + now);
10283 });
10284
10285 $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").die().live("click", function(){
10286 var id = $(this).data("targetid");
10287 delete(sv_messagePopStack[id]);
10288 var node = $(".bubbleItem#" + id, "#buttom-bubble");
10289 node.fadeOut(1000, function(){
10290 $(this).remove();
10291 });
10292 });
10293 }
10294 }
10295
10296
10297 return {
10298 init:init,
10299 setTrafficAlertPopuped: setTrafficAlertPopuped,
10300 setTrafficAlert100Popuped: setTrafficAlert100Popuped,
10301 getTrafficResult: getTrafficResult,
10302 showOTAAlert:showOTAAlert
10303 };
10304});
10305
10306// ����ͳ������ģ��
10307define("status_traffic_alert","jquery knockout service statusBar echarts".split(" "),
10308
10309 function ($, ko, service, status, echarts) {
10310
10311 var sv_trafficGraph = null;
10312 var sv_sourceData = null;
10313 var sv_usedDataModified = false;
10314 var sv_usedTimeModified = false;
10315
10316 var sv_trafficStaticalInfo = {
10317 // ����ͼ��ʼֵ
10318 data: {
10319 alarm: {
10320
10321 itemStyle: {
10322 normal: {
10323 color: '#8CC916'
10324 }
10325 },
10326 name: '������',
10327 value: 19.7
10328 },
10329 alert: {
10330
10331 itemStyle: {
10332 normal: {
10333 color: '#FF5500'
10334 }
10335 },
10336 name: '����ֵ',
10337 value: 1
10338 },
10339 free: {
10340
10341 itemStyle: {
10342 normal: {
10343 color: '#D8D8D8'
10344 }
10345 },
10346 name: 'δʹ��',
10347 value: 50
10348 },
10349 full: {
10350
10351
10352 itemStyle: {
10353 normal: {
10354 color: '#DF4313'
10355 }
10356 },
10357 name: '��������',
10358 value: 30
10359 },
10360 left1: {
10361
10362 itemStyle: {
10363 normal: {
10364 color: '#D8D8D8'
10365 }
10366 },
10367 name: '����ֵ��δʹ��',
10368 value: 50,
10369 },
10370 start: {
10371
10372 itemStyle: {
10373 normal: {
10374 color: '#D8D8D8'
10375 }
10376 },
10377 name: '����ֵ��δʹ��',
10378 value: 50
10379 },
10380 used: {
10381
10382 itemStyle: {
10383 normal: {
10384 color: '#8CC916'
10385 }
10386 },
10387 name: '��ʹ��',
10388 value: 30
10389 }
10390 },
10391 cacheEle: {},
10392 // Ԫ�ػ�ȡ
10393 getEle: function (i_elementId) {
10394 if (this.cacheEle.hasOwnProperty('id')) {
10395 return this.cacheEle[i_elementId];
10396 } else {
10397 this.cacheEle[i_elementId] = $("#" + i_elementId);
10398 return this.cacheEle[i_elementId];
10399 }
10400 },
10401 // ��ȡ�����澯״ֵ̬
10402 fetchTrafficAlertInfo: function(){
10403 sv_sourceData = getTrafficAlertInfo();
10404 return sv_sourceData;
10405 },
10406 // ��ȡ����ֵ�Ͷ�Ӧ��λֵ
10407 getTrafficStatisticalDatalnfo: function (i_valueInfo) {
10408 return {
10409 data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
10410 unit: /[A-Z]{1,2}/.exec(i_valueInfo)[0]
10411 }
10412 },
10413
10414 // ��ȡʱ��ʱ���֡���
10415 getTrafficTimeHours: function (i_time) {
10416 var s_timeArray = i_time.split(':');
10417 return {
10418 h: parseInt(s_timeArray[0], 10),
10419 m: parseInt(s_timeArray[1], 10),
10420 s: parseInt(s_timeArray[2], 10)
10421 }
10422 },
10423 // ��ȡͳ��ʱ���Ͷ�Ӧ��λֵ
10424 getTrafficTimeInfo: function (i_valueInfo) {
10425 return {
10426 data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
10427 unit: /[a-z]{4,6}/.exec(i_valueInfo)[0]
10428 }
10429 },
10430 // ʱ�任����S
10431 getTrafficTimeToSeconds: function (i_time) {
10432 var s_FormattedTime = this.getTrafficTimeHours(i_time);
10433 return s_FormattedTime.h * 3600 + s_FormattedTime.m * 60 + s_FormattedTime.s;
10434 },
10435 // ͨ�����ƻ�ȡ������λ
10436 getTrafficUnitByScale: function (i_scale) {
10437 if (i_scale == '1024') {
10438 return 'GB';
10439 } else if (i_scale == '1048576') {
10440 return 'TB';
10441 } else {
10442 return 'MB';
10443 }
10444 },
10445 // ��λ��Ӧֵ��ȡ
10446 getTrafficValueByStatisticalUnit: function (i_unit) {
10447 i_unit = i_unit.toLowerCase();
10448 if(i_unit == 'minute'){
10449 return '60';
10450 } else if (i_unit == 'gb') {
10451 return '1024';
10452 } else if(i_unit == 'hour'){
10453 return '3600';
10454 } else if (i_unit == 'tb') {
10455 return '1048576';
10456 } else {
10457 return '1';
10458 }
10459 },
10460
10461 // ���������Ƿ��ɱ༭
10462 isFormEditable: function (fwVm) {
10463 var s_dataPageEditState = fwVm.dataLimitTypeChecked() == '1' && (fwVm.viewEditUsedData() || fwVm.viewEditAlertData() || fwVm.viewEditTotalData());
10464 var s_timePageEditState = fwVm.dataLimitTypeChecked() == '0' && (fwVm.viewEditUsedTime() || fwVm.viewEditAlertTime() || fwVm.viewEditTotalTime());
10465 if (s_dataPageEditState || s_timePageEditState) {
10466 $('.border-color-transition:visible').addClass('attention-focus');
10467 addTimeout(function () {
10468 $('.border-color-transition:visible').removeClass('attention-focus');
10469 }, 1500);
10470 return true;
10471 } else {
10472 var s_result = false;
10473 if (fwVm.dataLimitTypeChecked() == 1) {
10474 if (fwVm.alertDataReach() == '0') {
10475 fwVm.editAlertDataHandler();
10476 s_result = true;
10477 }
10478 if (fwVm.limitDataMonth() == '0') {
10479 fwVm.editTotalDataHandler();
10480 s_result = true;
10481 }
10482 } else {
10483 if (fwVm.alertTimeReach() == '0') {
10484 fwVm.editAlertTimeHandler();
10485 s_result = true;
10486 }
10487 if (fwVm.limitTimeMonth() == '0') {
10488 fwVm.editTotalTimeHandler();
10489 s_result = true;
10490 }
10491 }
10492
10493 if (s_result) {
10494 $('.border-color-transition:visible').addClass('attention-focus');
10495 addTimeout(function () {
10496 $('.border-color-transition:visible').removeClass('attention-focus');
10497 }, 1500);
10498 }
10499 return s_result;
10500 }
10501 },
10502
10503 // ˢ������ͼ��Ϣ������������ֵ����ʾ����
10504
10505 refreshFlowDiagramInfo: function (fwVm) {
10506 var s_alarm = 0;
10507 var s_left = 0;
10508 var s_left1 = 0;
10509 var s_reach = 0;
10510 var s_total = 0;
10511 var s_used = 0;
10512
10513
10514 var s_startName = $.i18n.prop("echarts_no");
10515
10516 if (sv_sourceData.dataLimitChecked == '1') { //if (fwVm.dataLimitChecked() == '1') { //����
10517 s_startName = $.i18n.prop("echarts_used");
10518 sv_trafficGraphOptions.series[0].data = [];
10519
10520 if (fwVm.dataLimitTypeChecked() == '1') { // ����
10521 sv_trafficGraphOptions.title.text = "";
10522 sv_trafficGraphOptions.series[0].data = [];
10523
10524 if (fwVm.limitDataMonth() == 0) {
10525 var s_usedData = sv_trafficStaticalInfo.data.used;
10526 s_usedData.value = 1;
10527 s_usedData.name = $.i18n.prop("echarts_used");
10528 s_usedData.selected = false;
10529 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10530 } else {
10531 s_total = fwVm.limitDataMonth() * fwVm.selectedDataUnit() * 1048576;
10532 s_used = parseInt(sv_sourceData.monthlySent, 10) + parseInt(sv_sourceData.monthlyReceived, 10);
10533 s_reach = s_total * fwVm.alertDataReach() / 100;
10534
10535 if (s_used >= s_total) {
10536 var s_fullData = sv_trafficStaticalInfo.data.full;
10537 s_fullData.value = 100;
10538 s_fullData.name = $.i18n.prop("echarts_full");
10539 sv_trafficGraphOptions.series[0].data.push(s_fullData);
10540 s_startName = $.i18n.prop("echarts_full");
10541 } else {
10542 if (s_reach > s_used) {
10543 s_left1 = s_reach - s_used;
10544 s_left = s_total - s_reach;
10545 } else {
10546 s_alarm = s_used - s_reach;
10547 s_left = s_total - s_used;
10548 }
10549
10550 var s_usedData = sv_trafficStaticalInfo.data.used;
10551 if (s_reach - s_used > 0) {
10552 s_usedData.value = s_used;
10553 } else {
10554 s_usedData.value = s_reach;
10555 }
10556 s_usedData.name = $.i18n.prop("echarts_used");
10557 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10558
10559 if (s_left1 > 0) {
10560 var s_left1Data = sv_trafficStaticalInfo.data.left1;
10561 s_left1Data.value = s_left1;
10562 s_left1Data.name = $.i18n.prop("echarts_left1");
10563 sv_trafficGraphOptions.series[0].data.push(s_left1Data);
10564 }
10565
10566 var s_alertData = sv_trafficStaticalInfo.data.alert;
10567 s_alertData.value = s_total / 200;
10568 s_alertData.name = $.i18n.prop("echarts_alert");
10569 sv_trafficGraphOptions.series[0].data.push(s_alertData);
10570
10571 if (s_alarm > 0) {
10572 var s_alarmData = sv_trafficStaticalInfo.data.alarm;
10573 s_alarmData.value = s_alarm;
10574 s_alarmData.name = $.i18n.prop("echarts_alarm");
10575 sv_trafficGraphOptions.series[0].data.push(s_alarmData);
10576 }
10577
10578 var s_freeData = sv_trafficStaticalInfo.data.free;
10579 s_freeData.value = s_left;
10580 s_freeData.name = $.i18n.prop("echarts_free");
10581 sv_trafficGraphOptions.series[0].data.push(s_freeData);
10582 }
10583 }
10584
10585 }else{// ʱ��
10586
10587 sv_trafficGraphOptions.series[0].data = [];
10588
10589 if (fwVm.limitTimeMonth() == 0) {
10590 var s_usedData = sv_trafficStaticalInfo.data.used;
10591 s_usedData.value = 1;
10592 s_usedData.selected = false;
10593 s_usedData.name = $.i18n.prop("echarts_used");
10594 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10595 } else {
10596 s_total = fwVm.limitTimeMonth() * fwVm.selectedTimeUnit();
10597 s_used = sv_sourceData.monthlyConnectedTime;
10598 s_reach = s_total * fwVm.alertTimeReach() / 100;
10599
10600 if (s_used >= s_total) {
10601 var fullTime = sv_trafficStaticalInfo.data.full;
10602 fullTime.value = 100;
10603 fullTime.name = $.i18n.prop("echarts_full");
10604 sv_trafficGraphOptions.series[0].data.push(fullTime);
10605 s_startName = $.i18n.prop("echarts_full");
10606 } else {
10607 if (s_reach - s_used > 0) {
10608 s_left1 = s_reach - s_used;
10609 s_left = s_total - s_reach;
10610 } else {
10611 s_alarm = s_used - s_reach;
10612 s_left = s_total - s_used;
10613 }
10614
10615 var s_usedTime = sv_trafficStaticalInfo.data.used;
10616 if (s_reach - s_used > 0) {
10617 s_usedTime.value = s_used;
10618 } else {
10619 s_usedTime.value = s_reach;
10620 }
10621 s_usedTime.name = $.i18n.prop("echarts_used");
10622 sv_trafficGraphOptions.series[0].data.push(s_usedTime);
10623
10624 if (s_left1 > 0) {
10625 var s_left1Time = sv_trafficStaticalInfo.data.left1;
10626 s_left1Time.value = s_left1;
10627 s_left1Time.name = $.i18n.prop("echarts_left1");
10628 sv_trafficGraphOptions.series[0].data.push(s_left1Time);
10629 }
10630
10631 var s_alertTime = sv_trafficStaticalInfo.data.alert;
10632 s_alertTime.value = s_total / 200;
10633 s_alertTime.name = $.i18n.prop("echarts_alert");
10634 sv_trafficGraphOptions.series[0].data.push(s_alertTime);
10635
10636 if (s_alarm > 0) {
10637 var s_alarmTime = sv_trafficStaticalInfo.data.alarm;
10638 s_alarmTime.value = s_alarm;
10639 s_alarmTime.name = $.i18n.prop("echarts_alarm");
10640 sv_trafficGraphOptions.series[0].data.push(s_alarmTime);
10641 }
10642
10643 var s_freeTime = sv_trafficStaticalInfo.data.free;
10644 s_freeTime.value = s_left;
10645 s_freeTime.name = $.i18n.prop("echarts_free");
10646 sv_trafficGraphOptions.series[0].data.push(s_freeTime);
10647 }
10648 }
10649 }
10650 } else {
10651 var s_usedData = sv_trafficStaticalInfo.data.used;
10652 s_usedData.value = 1;
10653 s_usedData.selected = false;
10654 s_usedData.name = $.i18n.prop("echarts_no");
10655
10656 sv_trafficGraphOptions.series[0].data = [s_usedData];
10657 sv_trafficGraphOptions.title.text = '';
10658 }
10659 sv_trafficStaticalInfo.setFlowDiagramInfo(sv_trafficGraphOptions, s_startName);
10660 },
10661
10662
10663 // �ػ�����ͼ
10664 setFlowDiagramInfo: function (i_options, i_startName) {
10665 var s_startPart = sv_trafficStaticalInfo.data.start;
10666
10667 s_startPart.name = i_startName;
10668 s_startPart.selected = false;
10669 s_startPart.value = 0;
10670
10671 var s_arr = [s_startPart].concat(i_options.series[0].data);
10672 i_options.series[0].data = s_arr;
10673 sv_trafficGraph.setOption(i_options, true);
10674
10675 addTimeout(function () {
10676 sv_trafficGraph.resize();
10677 }, 1000);
10678 }
10679 };
10680
10681
10682 // ����ͼ��������
10683 var sv_trafficGraphOptions = {
10684 animation: false,
10685 color: ['red', 'red', 'red', 'red', 'red'],
10686 series: [
10687 {
10688 name: '��������',
10689 radius: ['0', '75'],
10690 selectedOffset: 3,
10691 type: 'pie',
10692 data: [
10693
10694 ],
10695 itemStyle: {
10696 normal: {
10697 labelLine: {
10698 show: false
10699 },
10700 label: {
10701 show: false
10702 }
10703 }
10704 }
10705 }
10706 ],
10707 title: {
10708 itemGap: 0,
10709 text: '',
10710 subtextStyle: {
10711 color: '#FFF',
10712 fontFamily: '΢���ź�',
10713 fontSize: 16,
10714 fontWeight: 'bolder'
10715 },
10716 textStyle: {
10717 color: '#FFF',
10718 fontFamily: '΢���ź�',
10719 fontSize: 20,
10720 fontWeight: 'bolder'
10721 },
10722 x: 'center',
10723 y: 'center'
10724 },
10725 tooltip: {
10726 formatter: "{b}"
10727 }
10728 };
10729
10730
10731 // ��ȡ������������
10732 function getTrafficAlertInfo() {
10733 return service.getTrafficAlertInfo();
10734 }
10735
10736
10737
10738 // ��������ViewModel
10739
10740 function trafficViewModel() {
10741
10742 var target = this;
10743
10744 var info = sv_trafficStaticalInfo.fetchTrafficAlertInfo();
10745 var dataMonth = info.limitDataMonth.split("_");
10746
10747 sv_usedDataModified = false;
10748 sv_usedTimeModified = false;
10749
10750 target.alertDataReach = ko.observable(info.alertDataReach || 0);
10751 target.alertTimeReach = ko.observable(info.alertTimeReach || 0);
10752 target.dataLimitChecked = ko.observable(info.dataLimitChecked == '0' ? '0' : '1');
10753 target.dataLimitTypeChecked = ko.observable(info.dataLimitTypeChecked == '0' ? '0' : '1');
10754 target.limitTimeMonth = ko.observable(info.limitTimeMonth || 0);
10755
10756
10757 // ע��˳��
10758 target.usedDataText = ko.observable(transUnit(parseInt(info.monthlySent, 10) + parseInt(info.monthlyReceived, 10), false));
10759 var sv_staticalDataInfo = sv_trafficStaticalInfo.getTrafficStatisticalDatalnfo(target.usedDataText());
10760 var sv_staticalInfoData = sv_staticalDataInfo.data;
10761 target.dataUsed = ko.observable(sv_staticalInfoData);
10762 var sv_staticalInfoUnit = sv_staticalDataInfo.unit;
10763 target.selectedDataUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_staticalInfoUnit));
10764 target.usedDataTextDescData = ko.observable("");
10765
10766 target.limitDataMonth = ko.observable(dataMonth[0] || 0);
10767 target.selectedDataUnit = ko.observable(dataMonth[1] || 1);
10768
10769 var limitDataMonthTmp = transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1024 * 1024, false);
10770 var limitDataMonthUnitTmp = limitDataMonthTmp.substring(limitDataMonthTmp.length-2);
10771 target.limitDataMonth(limitDataMonthTmp.substring(0, limitDataMonthTmp.length-2));
10772 target.selectedDataUnit(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(limitDataMonthUnitTmp));
10773
10774 target.usedDataTextDesc = ko.computed(sf_usedDataTextDesc);
10775 target.limitDataMonthDescData = ko.observable("");
10776 target.limitDataMonthDesc = ko.computed(sf_limitDataMonthDesc);
10777 target.alertDataReachDescData = ko.observable("");
10778 target.alertDataReachDesc = ko.computed(sf_alertDataReachDesc);
10779 target.leftDataDescData = ko.observable("");
10780 target.leftDataDesc = ko.computed(sf_leftDataDesc);
10781 target.monthlyConnectedTime = ko.observable(transSecond2Time(info.monthlyConnectedTime));
10782
10783 var sv_timeInfo1 = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(info.monthlyConnectedTime));
10784 target.usedTime = ko.observable(sv_timeInfo1.data);
10785 target.selectedTimeUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfo1.unit));
10786
10787 target.usedTimeTextDescData = ko.observable("");
10788 target.usedTimeTextDesc = ko.computed(sf_usedTimeTextDesc);
10789
10790 var sv_timeInfoNew = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(parseFloat(target.limitTimeMonth()) * 3600));
10791 target.selectedTimeUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfoNew.unit));
10792 target.limitTimeMonth(sv_timeInfoNew.data);
10793
10794
10795 target.limitTimeMonthDescData = ko.observable("");
10796 target.limitTimeMonthDescText = ko.observable("traffic_limit_time_h");
10797 target.limitTimeMonthDesc = ko.computed(sf_limitTimeMonthDesc);
10798 target.alertTimeReachDescData = ko.observable("");
10799 target.alertTimeReachDesc = ko.computed(sf_alertTimeReachDesc);
10800 target.leftTimeDescData = ko.observable("");
10801 target.leftTimeDesc = ko.computed(sf_leftTimeDesc);
10802 target.save = sf_save;
10803 target.viewEditUsedData = ko.observable(false);
10804 target.editUsedDataHandler = sf_editUsedDataHandler;
10805 target.editUsedDataSaveHandler = sf_editUsedDataSaveHandler;
10806 target.saveUsedData = sf_saveUsedData;
10807 target.editUsedDataCancelHandler = sf_editUsedDataCancelHandler;
10808 target.viewEditTotalData = ko.observable(false);
10809 target.editTotalDataHandler = sf_editTotalDataHandler;
10810 target.editTotalDataSaveHandler = sf_editTotalDataSaveHandler;
10811 target.editTotalDataCancelHandler = sf_editTotalDataCancelHandler;
10812 target.viewEditAlertData = ko.observable(false);
10813 target.editAlertDataHandler = sf_editAlertDataHandler;
10814 target.editAlertDataSaveHandler = sf_editAlertDataSaveHandler;
10815 target.editAlertDataCancelHandler = sf_editAlertDataCancelHandler;
10816 target.viewEditUsedTime = ko.observable(false);
10817 target.editUsedTimeHandler = sf_editUsedTimeHandler;
10818 target.saveUsedTime = sf_saveUsedTime;
10819 target.editUsedTimeSaveHandler = sf_editUsedTimeSaveHandler;
10820 target.editUsedTimeCancelHandler = sf_editUsedTimeCancelHandler;
10821 target.viewEditTotalTime = ko.observable(false);
10822 target.editTotalTimeHandler = sf_editTotalTimeHandler ;
10823 target.editTotalTimeSaveHandler = sf_editTotalTimeSaveHandler;
10824 target.editTotalTimeCancelHandler = sf_editTotalTimeCancelHandler;
10825 target.viewEditAlertTime = ko.observable(false);
10826 target.editAlertTimeHandler = sf_editAlertTimeHandler;
10827 target.editAlertTimeSaveHandler = sf_editAlertTimeSaveHandler;
10828 target.editAlertTimeCancelHandler = sf_editAlertTimeCancelHandler;
10829 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
10830
10831
10832 // ��������������
10833 function sf_alertDataReachDesc() {
10834 if(isNaN(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach())) {
10835 target.alertDataReachDescData(target.alertDataReach() + ', ');
10836 return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), ' ');
10837 }
10838
10839 var s_value = transUnit(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach() * 1048576 / 100, false);
10840 target.alertDataReachDescData(target.alertDataReach() + ',' + s_value);
10841 return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), s_value);
10842 }
10843 // ʱ������������
10844 function sf_alertTimeReachDesc() {
10845 if(isNaN(target.limitTimeMonth() * target.alertTimeReach())) {
10846 target.alertTimeReachDescData(target.alertTimeReach() + ', ');
10847 return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), ' ');
10848 }
10849 var s_value = transSecond2Time(target.limitTimeMonth() * target.selectedTimeUnit() * target.alertTimeReach() / 100);
10850 target.alertTimeReachDescData(target.alertTimeReach() + ',' + s_value);
10851 return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), s_value);
10852 }
10853
10854
10855 // ��������ֵȡ���༭��ť�¼�
10856 function sf_editAlertDataCancelHandler() {
10857 target.alertDataReach(sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue'));
10858 target.viewEditAlertData(false);
10859 }
10860
10861 // ��������ֵ�༭��ť�¼�
10862 function sf_editAlertDataHandler() {
10863 sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue', target.alertDataReach());
10864 target.viewEditAlertData(true);
10865 }
10866
10867 // ��������ֵ�����༭��ť�¼�
10868 function sf_editAlertDataSaveHandler() {
10869 if (sv_trafficStaticalInfo.getEle('alertDataReach').valid()) {
10870 target.viewEditAlertData(false);
10871 }
10872 }
10873
10874 // ʱ������ֵȡ���༭��ť�¼�
10875 function sf_editAlertTimeCancelHandler() {
10876 target.alertTimeReach(sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue'));
10877 target.viewEditAlertTime(false);
10878 }
10879 // ʱ������ֵ�༭��ť�¼�
10880 function sf_editAlertTimeHandler() {
10881 sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue', target.alertTimeReach());
10882 target.viewEditAlertTime(true);
10883 }
10884 // ʱ������ֵ�����༭��ť�¼�
10885 function sf_editAlertTimeSaveHandler() {
10886 if (sv_trafficStaticalInfo.getEle('alertTimeReach').valid()) {
10887 target.viewEditAlertTime(false);
10888 }
10889 }
10890
10891 // �ײ������༭��ť�¼�
10892 function sf_editTotalDataHandler() {
10893 sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue', target.limitDataMonth());
10894 sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue', target.selectedDataUnit());
10895 target.viewEditTotalData(true);
10896 }
10897
10898 // �ײ����������༭��ť�¼�
10899 function sf_editTotalDataSaveHandler() {
10900 if (sv_trafficStaticalInfo.getEle('limitDataMonth').valid()) {
10901 target.usedDataText(transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1048576, false));
10902 target.viewEditTotalData(false);
10903 }
10904 }
10905
10906 // �ײ�����ȡ���༭��ť�¼�
10907 function sf_editTotalDataCancelHandler() {
10908 target.limitDataMonth(sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue'));
10909 target.selectedDataUnit(sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue'));
10910 target.viewEditTotalData(false);
10911 }
10912 // �ײ�ʱ��ȡ���༭��ť�¼�
10913 function sf_editTotalTimeCancelHandler() {
10914 target.limitTimeMonth(sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue'));
10915 target.viewEditTotalTime(false);
10916 }
10917 // �ײ�ʱ���༭��ť�¼�
10918 function sf_editTotalTimeHandler() {
10919 sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue', target.limitTimeMonth());
10920 target.viewEditTotalTime(true);
10921 }
10922 // �ײ�ʱ�䱣���༭��ť�¼�
10923 function sf_editTotalTimeSaveHandler() {
10924 if (sv_trafficStaticalInfo.getEle('limitTimeMonth').valid()) {
10925 target.viewEditTotalTime(false);
10926 }
10927 }
10928
10929 // ��������ȡ���༭��ť�¼�
10930 function sf_editUsedDataCancelHandler() {
10931 target.dataUsed(sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue'));
10932 target.selectedDataUsedUnit(sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue'));
10933 sv_trafficStaticalInfo.getEle('editUsedDataCancel').siblings('label.error').hide();
10934 target.viewEditUsedData(false);
10935 }
10936 // ���������༭��ť�¼�
10937 function sf_editUsedDataHandler() {
10938 sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue', target.dataUsed());
10939 sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue', target.selectedDataUsedUnit());
10940 target.dataUsed(target.dataUsed());
10941 target.viewEditUsedData(true);
10942 }
10943 // �����������水ť�¼�
10944 function sf_editUsedDataSaveHandler() {
10945 if (sv_trafficStaticalInfo.getEle('dataUsed').valid()) {
10946 sv_usedDataModified = true;
10947 target.viewEditUsedData(false);
10948 }
10949 }
10950 // ����ʱ��ȡ���༭��ť�¼�
10951 function sf_editUsedTimeCancelHandler() {
10952 target.usedTime(sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue'));
10953 target.viewEditUsedTime(false);
10954 }
10955 // ����ʱ���༭��ť�¼�
10956 function sf_editUsedTimeHandler() {
10957 sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue', target.usedTime());
10958 target.viewEditUsedTime(true);
10959 }
10960
10961 // ����ʱ�䱣���༭��ť�¼�
10962 function sf_editUsedTimeSaveHandler() {
10963 if (sv_trafficStaticalInfo.getEle('usedTime').valid()) {
10964 target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
10965 target.viewEditUsedTime(false);
10966 sv_usedTimeModified = true;
10967 }
10968 }
10969
10970 // ʣ������������
10971 function sf_leftDataDesc() {
10972 var s_left = (target.limitDataMonth() * target.selectedDataUnit() - target.dataUsed() * target.selectedDataUsedUnit()) * 1048576;
10973 if(s_left < 0) {
10974 s_left = 0;
10975 }
10976
10977 if(isNaN(s_left)) {
10978 target.leftDataDescData('');
10979 return $.i18n.prop('traffic_data_left_text', ' ');
10980 }
10981
10982 target.leftDataDescData(transUnit(s_left, false));
10983 return $.i18n.prop('traffic_data_left_text', transUnit(s_left, false));
10984 }
10985 //ʣ��ʱ��������
10986 function sf_leftTimeDesc() {
10987 var s_surplus = target.limitTimeMonth() * target.selectedTimeUnit() - sv_trafficStaticalInfo.getTrafficTimeToSeconds(target.monthlyConnectedTime());
10988 if(s_surplus < 0) {
10989 s_surplus = 0;
10990 }
10991
10992 if(isNaN(s_surplus)) {
10993 target.leftTimeDescData(' ');
10994 return $.i18n.prop('traffic_data_left_text', ' ');
10995 }
10996 target.leftTimeDescData(transSecond2Time(s_surplus));
10997 return $.i18n.prop('traffic_data_left_text', transSecond2Time(s_surplus));
10998 }
10999 // �ײ�����������
11000 function sf_limitDataMonthDesc() {
11001 if(isNaN(target.limitDataMonth())) {
11002 target.limitDataMonthDescData("");
11003 return $.i18n.prop('traffic_limit_data_text', ' ');
11004 }else{
11005 // todo
11006 }
11007
11008 target.limitDataMonthDescData(target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
11009 return $.i18n.prop('traffic_limit_data_text', target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
11010 }
11011 // �ײ�ʱ��������
11012 function sf_limitTimeMonthDesc() {
11013 if(isNaN(target.limitTimeMonth())) {
11014 target.limitTimeMonthDescData(' ');
11015 target.limitTimeMonthDescText('traffic_limit_time_h');
11016 return $.i18n.prop('traffic_limit_time_h', ' ');
11017 }else{
11018 // todo:
11019 }
11020
11021 target.limitTimeMonthDescData(target.limitTimeMonth());
11022
11023 if(target.selectedTimeUnit() == "60"){
11024 target.limitTimeMonthDescText('traffic_limit_time_m');
11025 return $.i18n.prop('traffic_limit_time_m', target.limitTimeMonth());
11026 }else{
11027 target.limitTimeMonthDescText('traffic_limit_time_h');
11028 return $.i18n.prop('traffic_limit_time_h', target.limitTimeMonth());
11029 }
11030 }
11031
11032 // Ӧ�ð�ť�¼�
11033 function sf_save() {
11034 if (sv_trafficStaticalInfo.isFormEditable(target) && target.dataLimitChecked() == '1') {
11035 return false;
11036 }
11037
11038 if (target.selectedDataUnit() == '1' && target.selectedDataUsedUnit() == '1048576' && target.dataLimitTypeChecked() == "1" && target.dataLimitChecked() == '1' && !(parseInt(target.dataUsed(), 10) < parseInt('4096', 10)) ) {
11039 showAlert('traffic_over_note');
11040 return false;
11041 }
11042
11043 showLoading();
11044 service.setTrafficAlertInfo({
11045 alertDataReach: parseInt(target.alertDataReach(), 10),
11046 alertTimeReach: parseInt(target.alertTimeReach(), 10),
11047 dataLimitChecked: target.dataLimitChecked(),
11048 dataLimitTypeChecked: target.dataLimitTypeChecked(),
11049 limitDataMonth: target.limitDataMonth() + "_" + target.selectedDataUnit(),
11050 limitTimeMonth: target.selectedTimeUnit() == "60" ? target.limitTimeMonth()/60 : target.limitTimeMonth()//save by hours
11051 }, function (data) {
11052 if (data.result == 'success') {
11053 if(target.dataLimitTypeChecked() == "1" && sv_usedDataModified) {
11054 target.saveUsedData();
11055 } else if(target.dataLimitTypeChecked() == "0" && sv_usedTimeModified) {
11056 target.saveUsedTime();
11057 } else {
11058 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11059 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11060 status.setTrafficAlertPopuped(false);
11061 successOverlay();
11062 }
11063 } else {
11064 errorOverlay();
11065 }
11066 }, function () {
11067 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11068 errorOverlay();
11069 });
11070 }
11071
11072 // ����������������
11073 function sf_saveUsedData() {
11074 var val = target.dataUsed() * target.selectedDataUsedUnit();
11075 service.trafficCalibration({
11076 way: 'data',
11077 value: val
11078 }, function(){
11079 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11080 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11081 successOverlay();
11082 target.viewEditUsedData(false);
11083 status.setTrafficAlertPopuped(false);
11084 sv_usedDataModified = false;
11085 }, function(){
11086 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11087 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11088 errorOverlay();
11089 });
11090 }
11091
11092
11093
11094 function sf_saveUsedTime() {
11095 service.trafficCalibration({
11096 way: 'time',
11097 value: target.selectedTimeUsedUnit() == "60" ? parseFloat(target.usedTime())/60 : target.usedTime()
11098 }, function(){
11099 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11100 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11101 successOverlay();
11102 target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
11103 target.viewEditUsedTime(false);
11104 status.setTrafficAlertPopuped(false);
11105 sv_usedTimeModified = false;
11106 }, function(){
11107 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11108 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11109 errorOverlay();
11110 });
11111 }
11112
11113
11114 // ��������������
11115 function sf_usedDataTextDesc() {
11116 if(isNaN(target.dataUsed())) {
11117 target.usedDataTextDescData("");
11118 return $.i18n.prop('traffic_used_text', ' ');
11119 }
11120 target.usedDataTextDescData(target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
11121 return $.i18n.prop('traffic_used_text', target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
11122 }
11123 // ����ʱ��������
11124 function sf_usedTimeTextDesc() {
11125 target.usedTimeTextDescData(target.monthlyConnectedTime());
11126 return $.i18n.prop('traffic_used_text', target.monthlyConnectedTime());
11127 }
11128
11129
11130 }
11131
11132 function init() {
11133 sv_trafficGraph = echarts.init($("#traffic_graphic")[0]);
11134 window.onresize = sv_trafficGraph.resize;
11135 var s_container = $('#container');
11136 ko.cleanNode(s_container[0]);
11137 var fwVm = new trafficViewModel();
11138 ko.applyBindings(fwVm, s_container[0]);
11139 $('#trafficAlertForm').validate({
11140 submitHandler: function () {
11141 fwVm.save();
11142 },
11143
11144
11145 errorPlacement: function (error, para) {
11146 if (para.attr("name") == "alertDataReach") {
11147 error.insertAfter("#editAlertDataDiv");
11148 } else if (para.attr("name") == "alertTimeReach") {
11149 error.insertAfter("#editAlertTimeDiv");
11150 } else if (para.attr("name") == "dataUsed") {
11151 error.insertAfter("#editUsedDataDiv");
11152 } else if (para.attr("name") == "limitDataMonth") {
11153 error.insertAfter("#editTotalDataDiv");
11154 } else if (para.attr("name") == "limitTimeMonth") {
11155 error.insertAfter("#editTotalTimeDiv");
11156 } else if (para.attr("name") == "usedTime") {
11157 error.insertAfter("#editUsedTimeDiv");
11158 } else {
11159 error.insertAfter(para);
11160 }
11161 },
11162
11163 rules: {
11164 alertDataReach: {
11165 range: [ 1, 100 ],
11166 digits: true
11167 },
11168 alertTimeReach: {
11169 range: [ 1, 100 ],
11170 digits: true
11171 },
11172 dataUsed: {
11173 range : [ 0, 9999 ],
11174 decimalRange : true
11175 },
11176 limitDataMonth: {
11177 range : [ 1, 9999 ],
11178 decimalRange : true
11179 },
11180 limitTimeMonth: {
11181 range : [ 1, 9999 ],
11182 decimalRange : true
11183 },
11184 usedTime: {
11185 range : [ 0, 9999 ],
11186 decimalRange : true
11187 }
11188 }
11189
11190 });
11191
11192 var sv_originalLan = window.language;
11193 window.setInterval(function(){
11194 if(sv_originalLan != window.language){
11195 sv_originalLan = window.language;
11196 sv_trafficStaticalInfo.refreshFlowDiagramInfo(fwVm);
11197 }
11198 }, 1000);
11199
11200 }
11201
11202 return {
11203 init: init
11204 };
11205});
11206
11207// ״̬����ʾ��ʵ��
11208define("tooltip",[ "jquery" ],
11209
11210 function($) {
11211
11212
11213 // ����Ԫ��λ����Ϣ
11214 // @method calculatePositionInfo
11215 // @param trigger Ԫ��
11216 // @param tooltip ״̬��
11217 // @param {JSON} config �����
11218
11219 function calculatePositionInfo(trigger, tooltip, config) {
11220 var top = trigger.offset().top;
11221 var left = trigger.offset().left;
11222 var position = config.position[0];
11223 var height = tooltip.outerHeight() + trigger.outerHeight();
11224 var width = tooltip.outerWidth() + trigger.outerWidth();
11225
11226 top -= tooltip.outerHeight() - config.offset[0];
11227 left += trigger.outerWidth() + config.offset[1];
11228
11229 if (/iPad/i.test(navigator.userAgent)) {
11230 top -= $(window).scrollTop();
11231 }
11232
11233 if (position == 'center') {
11234 top += height / 2;
11235 }
11236 if (position == 'bottom') {
11237 top += height;
11238 }
11239 position = config.position[1];
11240 if (position == 'center') {
11241 left -= width / 2;
11242 }else if (position == 'left') {
11243 left -= width;
11244 }
11245
11246 return {
11247 top : top,
11248 left : left
11249 };
11250 }
11251
11252 // ״̬����ʼ��
11253 function init() {
11254
11255 $(".statusItem", "#statusBar").each(function(i, n){
11256 var $this = $(this);
11257 $this.attr("tipTitle", $this.attr("title")).removeAttr("title");
11258 }).hover(
11259 function() {
11260 var $this = $(this);
11261 var title = $this.attr("tipTitle");
11262 var tooltip = $("<div>").addClass("tooltip in").appendTo(document.body).hide()
11263 .append($this.attr("i18n") ? $.i18n.prop(title) : title);
11264 if ($this.attr("i18n")) {
11265 tooltip.attr("data-trans", title).attr("id", "tooltip_" + $this.attr("id"));
11266 }
11267 var pos = calculatePositionInfo($this, tooltip, {
11268 position : [ 'bottom', 'center' ],
11269 offset : [ 0, 0 ]
11270 });
11271 tooltip.css({
11272 position : 'absolute',
11273 top : pos.top,
11274 left : pos.left
11275 }).show();
11276 }, function() {
11277 $(".tooltip").hide().remove();
11278 });
11279 }
11280
11281 return {
11282 init : init
11283 };
11284 });
11285
11286define("menu","set service knockout underscore jquery".split(" "),
11287 function (set, fnc, libko, libus, libjq) {
11288 var displayMenuWhenLogout = false;
11289 var vmMenu;
11290 var menu = [];
11291 var menuResource = "";
11292
11293 function menuExistCheck(path) {
11294 for (var i = 0; i < menu.length; i++) {
11295 if (menu[i].path == path) {
11296 return true;
11297 }
11298 }
11299 return false;
11300 }
11301
11302 function getIsLoggedin() {
11303 var loginStatus = fnc.getLoginStatus();
11304 return (loginStatus.status == "loggedIn");
11305 }
11306
11307 function buildNew() {
11308 var loggedIn = getIsLoggedin();
11309 var menuMain = libus.filter(menu, function (param) {
11310 return (param.level == '1' && ((param.requireLogin && loggedIn) || !param.requireLogin) && param.hash != "#entry");
11311 });
11312 vmMenu.menuMain(menuMain);
11313 vmMenu.loggedIn(loggedIn);
11314
11315 getMainWth(vmMenu.menuMain().length);
11316 vmMenu.showMenu(loggedIn || displayMenuWhenLogout);
11317 libjq("#nav").translate();
11318 }
11319
11320 function getMainWth(len) {
11321 var width = 100 / len;
11322 libjq('ul#list-nav li').each(function () {
11323 libjq(this).css('width', width + '%');
11324 });
11325 }
11326
11327 function menuRefresh() {
11328 var currentHash = window.location.hash;
11329 var itmRoot = libus.find(menu, function (param) {
11330 return param.hash == currentHash;
11331 });
11332 while (itmRoot.parent) {
11333 itmRoot = libus.find(menu, function (param) {
11334 return param.hash == itmRoot.parent;
11335 });
11336 }
11337 if (!itmRoot.parent) {
11338 libjq("#list-nav li").removeClass("active");
11339 var mid = itmRoot.hash.substring(1, itmRoot.hash.length);
11340 libjq("#list-nav li[mid=" + mid + "]").addClass("active");
11341 }
11342 vmMenu.changeMenu(itmRoot);
11343 }
11344
11345 function menuSearch(hashVal) {
11346 hashVal = hashVal || window.location.hash;
11347 var loggedIn = getIsLoggedin();
11348 return libus.filter(menu, function (param) {
11349 return (hashVal == param.hash && ((param.requireLogin && loggedIn) || !param.requireLogin));
11350 });
11351 }
11352
11353 function menuRenderSub(level, baseItem) {
11354 var levelItem = libus.find(menu, function (param) {
11355 return param.parent == baseItem.hash && param.path == baseItem.path;
11356 });
11357 libjq(".menu-" + level + "-level").removeClass("active");
11358 if (levelItem) {
11359 if (level == "two") {
11360 menuRenderSub("three", levelItem);
11361 //forward/backward support
11362 clickMenuTrig(levelItem.hash, level);
11363 }
11364 libjq(".menu-" + level + "-level." + levelItem.hash.substring(1)).addClass("active");
11365 }
11366 }
11367
11368 function menuActSub() {
11369 var currentHash = window.location.hash;
11370 var itmRoot = libus.find(menu, function (param) {
11371 return param.hash == currentHash;
11372 });
11373 if (itmRoot.level == 1) {
11374 menuRenderSub("two", itmRoot);
11375 }
11376 if (itmRoot.level == 2) {
11377 menuRenderSub("three", itmRoot);
11378 //forward/backward support
11379 clickMenuTrig(itmRoot.hash, itmRoot.level);
11380 }
11381 if (itmRoot.level == 3) {
11382 //forward/backward support
11383 clickMenuTrig(itmRoot.parent, itmRoot.level);
11384 libjq(".menu-three-level").removeClass("active");
11385 libjq(".menu-three-level." + itmRoot.hash.substring(1)).addClass("active");
11386 }
11387 }
11388
11389 function clickMenuTrig(hash, level) {
11390 libjqobj = libjq(".menu-two-level." + hash.substring(1));
11391 var levelArr = ['3', 'three', '2', 'two'];
11392 if (libus.indexOf(levelArr, level) != -1 && libjqobj.hasClass('active')) {
11393 return;
11394 }
11395
11396 libjqobj.siblings().removeClass('active');
11397 libjqobj.addClass('active');
11398
11399 libjqobj.siblings().not('.menu-two-level').slideUp();
11400 libjqobj.next().has('ul li').slideDown();
11401 }
11402
11403 set.blc_wan_mode = fnc.getOpMode().blc_wan_mode;
11404 if (!set.RJ45_SUPPORT) {
11405 menuResource = "menu";
11406 } else {
11407 switch (set.blc_wan_mode) {
11408 case "PPPOE":
11409 case "AUTO_PPPOE":
11410 menuResource = "menu_pppoe";
11411 break;
11412 default:
11413 menuResource = "menu";
11414 break;
11415 }
11416 }
11417
11418 require([set.DEVICE + '/' + menuResource], function (otherMenu) {
11419 menu = otherMenu;
11420 if (set.SD_CARD_SUPPORT) {
11421 menu = menu.concat([{ hash: '#httpshare_guest', path: 'sd_httpshare', level: '', requireLogin: false, checkSIMStatus: false},
11422 { hash: '#sdcard', path: 'sd', level: '', requireLogin: true, checkSIMStatus: false},
11423 { hash: '#httpshare', path: 'sd_httpshare', level: '', requireLogin: true, checkSIMStatus: false}]);
11424 }
11425 });
11426
11427 function initialize() {
11428 vmMenu = new Menu_vm();
11429 }
11430
11431 function Menu_vm() {
11432 var loginState = getIsLoggedin();
11433 var target = this;
11434 target.loggedIn = libko.observable(loginState);
11435
11436 target.showMenu = libko.observable(loginState || displayMenuWhenLogout);
11437
11438 var menuMain = libus.filter(menu, function (param) {
11439 return (param.level == '1' && ((param.requireLogin && target.loggedIn()) || !param.requireLogin) && param.hash != "#entry");
11440 });
11441
11442 target.menuMain = libko.observableArray(menuMain);
11443 target.secondMenu = libko.observableArray([]);
11444 //target.curThirdMenu; cov_2
11445 target.changeMenu = function (data) {
11446 var secondMenu = getSubMenu(data);
11447 if (secondMenu.length == 0) {
11448 libjq("#container").addClass("fixContainerWidth");
11449 } else {
11450 libjq("#container").removeClass("fixContainerWidth");
11451 }
11452
11453 target.secondMenu(secondMenu);
11454 return true;
11455 };
11456 target.thirdMenu = function () {
11457 return target.curThirdMenu;
11458 };
11459 target.getThirdMenu = function (data) {
11460 target.curThirdMenu = getSubMenu(data);
11461 };
11462 function getSubMenu(data) {
11463 return libus.filter(menu, function (param) {
11464 return ((param.parent && param.parent == data.hash) && ((param.requireLogin && target.loggedIn()) || !param.requireLogin));
11465 });
11466 }
11467 }
11468
11469 return {
11470 activeSubMenu: menuActSub,
11471 checkIsMenuExist: menuExistCheck,
11472 findMenu: menuSearch,
11473 rebuild: buildNew,
11474 refreshMenu: menuRefresh,
11475 init: initialize
11476 };
11477});