blob: e20699f46dca2b77c1f1005324258e8012410d18 [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 //�����ꡢ�¡�ʱ���ֵ�����
6091 sf_produceArray(2000, 2030, sv_sntpYears);
6092 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 });
6494// �������� �
6495
6496define("adm_management","jquery knockout set service underscore CryptoJS".split(" "),
6497
6498 function ($, ko, config, service, _, CryptoJS) {
6499
6500 function manageViewModel() {
6501 var target = this;
6502
6503 target.currentValue = ko.observable();
6504 target.newValue = ko.observable();
6505 target.confirmValue = ko.observable();
6506
6507 function sf_changeValue() {
6508 var sv_manageInfo = {};
6509 if (config.PASSWORD_ENCODE) {
6510 sv_manageInfo.oldValue = target.currentValue();
6511 sv_manageInfo.newValue = target.newValue();
6512 } else {
6513 var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
6514
6515 if (!pwdRegex.test(target.newValue())) {
6516 showConfirm("password_note_too_low", function () {
6517
6518 var kparam = service.getDeviceInfoLow();
6519 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
6520 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
6521 var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
6522 iv: tiv,
6523 mode: CryptoJS.mode.CBC,
6524 padding: CryptoJS.pad.ZeroPadding
6525 }).toString();
6526 var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
6527 iv: tiv,
6528 mode: CryptoJS.mode.CBC,
6529 padding: CryptoJS.pad.ZeroPadding
6530 }).toString();
6531
6532 sv_manageInfo.oldValue = cipherold;
6533 sv_manageInfo.newValue = ciphernew;
6534
6535 showLoading();
6536
6537 service.changeManageInfo(sv_manageInfo, function (resultInfo) {
6538 target.cancel();
6539 if (resultInfo && resultInfo.result == true) {
6540 successOverlay();
6541 } else {
6542 if (resultInfo && resultInfo.errorType == "badPassword") {
6543 hideLoading();
6544 showAlert("current_password_error",function(){
6545 $("#txtCurrent").focus();
6546 });
6547 } else {
6548 errorOverlay();
6549 }
6550 }
6551 });
6552 });
6553 return;
6554 }
6555 var kparam = service.getDeviceInfoLow();
6556 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
6557 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
6558 var cipherold = CryptoJS.AES.encrypt(target.currentValue(), tkey, {
6559 iv: tiv,
6560 mode: CryptoJS.mode.CBC,
6561 padding: CryptoJS.pad.ZeroPadding
6562 }).toString();
6563 var ciphernew = CryptoJS.AES.encrypt(target.newValue(), tkey, {
6564 iv: tiv,
6565 mode: CryptoJS.mode.CBC,
6566 padding: CryptoJS.pad.ZeroPadding
6567 }).toString();
6568
6569 sv_manageInfo.oldValue = cipherold;
6570 sv_manageInfo.newValue = ciphernew;
6571 }
6572
6573 showLoading();
6574
6575 service.changeManageInfo(sv_manageInfo, function (resultInfo) {
6576 target.cancel();
6577 if (resultInfo && resultInfo.result == true) {
6578 successOverlay();
6579 } else {
6580 if (resultInfo && resultInfo.errorType == "badPassword") {
6581 hideLoading();
6582 showAlert("current_password_error",function(){
6583 $("#txtCurrent").focus();
6584 });
6585 } else {
6586 errorOverlay();
6587 }
6588 }
6589 });
6590 }
6591
6592 // ��������������
6593 function sf_cancel() {
6594 target.currentValue("");
6595 target.newValue("");
6596 target.confirmValue("");
6597 }
6598
6599 target.cancel = sf_cancel;
6600
6601 // �޸�����
6602 target.changeValue = sf_changeValue;
6603 }
6604
6605 function init() {
6606 var container = $('#container');
6607 ko.cleanNode(container[0]);
6608 var fwVm = new manageViewModel();
6609 ko.applyBindings(fwVm, container[0]);
6610
6611 $('#frmPassword').validate({
6612 submitHandler:function () {
6613 fwVm.changeValue();
6614 },
6615 rules:{
6616 txtCurrent:"manage_info_check",
6617 txtNew:"manage_info_check",
6618 txtConfirm:{ equalTo:"#txtNew"}
6619 }
6620 });
6621 }
6622
6623 return {
6624 init:init
6625 }
6626 }
6627);
6628// PIN�����
6629
6630define("adm_pin","jquery knockout set service".split(" "),
6631
6632 function ($, ko, config, service) {
6633 var pageState = {common:0, requirePin:1, modifyPin:2, requirePuk:3, destroyed:4};
6634 var pinStatus = {enable:"1", disable:"0"};
6635
6636
6637 function pinViewModel() {
6638 var target = this;
6639 var sv_currentPinData = service.getPinData();
6640
6641 target.isDataCard = config.PRODUCT_TYPE == 'DATACARD';
6642 target.originPinStatus = ko.observable(sv_currentPinData.pin_status);
6643
6644 target.pinStatus = ko.observable(sv_currentPinData.pin_status);
6645 target.pinNumber = ko.observable(sv_currentPinData.pinnumber);
6646 target.pukNumber = ko.observable(sv_currentPinData.puknumber);
6647
6648 target.currentPin = ko.observable();
6649 target.newPin = ko.observable();
6650 target.confirmPin = ko.observable();
6651
6652 target.puk = ko.observable();
6653
6654 target.pageState = ko.observable();
6655 // �����������ɹ���־λ
6656 target.operateSuccessFlag = true;
6657
6658 target.callback = sf_callback;
6659
6660 function sf_callback(info) {
6661 if (info && info.result == true) {
6662 target.operateSuccessFlag = true;
6663 successOverlay();
6664 } else {
6665 target.operateSuccessFlag = false;
6666
6667 // ����һ��ǰҪ������ʾ
6668 if(target.pinNumber() == 2){
6669 showAlert("last_enter_pin");
6670 } else if(target.pukNumber() == 2){
6671 showAlert("last_enter_puk");
6672 }
6673 else{
6674 errorOverlay();
6675 }
6676 }
6677 init(target);
6678 }
6679
6680
6681 // ȷ����ť�¼������������޸�PIN������PUK����PIN������PIN��ʹ��״̬
6682
6683 function sf_changePin() {
6684 if (target.isConnectedNetWork()) {
6685 showAlert("cannot_operate_when_connected");
6686 return;
6687 }
6688
6689 if (target.pageState() == pageState.common) {
6690 return;
6691 }
6692
6693 var sv_pinPara = {
6694 oldPin:target.currentPin(),
6695 newPin:target.newPin()
6696 };
6697 showLoading();
6698
6699 if (target.pageState() == pageState.modifyPin) {
6700 service.changePin(sv_pinPara, target.callback);
6701 } else if (target.pageState() == pageState.requirePuk) {
6702 sv_pinPara = {
6703 PinNumber:target.newPin(),
6704 PUKNumber:target.puk()
6705 };
6706 service.enterPUK(sv_pinPara, target.callback);
6707 } else {
6708 if (target.pinStatus() == pinStatus.enable) {
6709 service.enablePin(sv_pinPara, target.callback);
6710 } else {
6711 service.disablePin(sv_pinPara, target.callback);
6712 }
6713 }
6714 }
6715
6716
6717 // ȡ���¼�����
6718 function sf_cancel() {
6719 target.pageState(pageState.common);
6720 target.pinStatus(target.originPinStatus());
6721 target.clear();
6722 }
6723
6724 // ����ҳ�������ͼ�����Ϣ
6725 function sf_clear() {
6726 target.confirmPin("");
6727 target.currentPin("");
6728 target.newPin("");
6729 target.puk("");
6730 clearValidateMsg();
6731 }
6732
6733 // �������ݣ����õ�ǰ��ҳ��״̬
6734 function sf_computePageState(i_pinData) {
6735 if (i_pinData.pinnumber > 0) {
6736 //�����ɹ�ҳ���ص���ʼ״̬������ʧ�ܲ���pinnumber>0,ҳ�治��ת
6737 if (target.operateSuccessFlag) {
6738 target.cancel();
6739 } else {
6740 target.clear();
6741 }
6742 } else {
6743 target.clear();
6744 if (i_pinData.puknumber > 0) {
6745 target.pageState(pageState.requirePuk);
6746 } else {
6747 target.pageState(pageState.destroyed);
6748 }
6749 }
6750 }
6751
6752 // ����PIN�޸�״̬�¼�����
6753 function sf_displayModifyPinPage() {
6754 if (target.isConnectedNetWork()) {
6755 showAlert("cannot_operate_when_connected");
6756 return;
6757 }
6758 target.pinStatus(target.originPinStatus());
6759 target.pageState(pageState.modifyPin);
6760 target.clear();
6761 }
6762
6763 // ����ҳ��Ԫ�ص�ʹ��״̬
6764 function sf_fixPageEnable() {
6765 if (target.isConnectedNetWork()) {
6766 $('#frmPin :input').each(function () {
6767 disableBtn($(this));
6768 });
6769 clearValidateMsg();
6770 } else {
6771 $('#frmPin :input').each(function () {
6772 if (this.id == "txtPin" || this.id == "btnPinApply") {
6773 if (target.pageState() == pageState.common) {
6774 disableBtn($(this));
6775 return;
6776 }
6777 }
6778 if (this.id == "btnModifyPin") {
6779 if (target.originPinStatus() != pinStatus.enable) {
6780 disableBtn($(this));
6781 return;
6782 }
6783 }
6784 if (this.id == "pinEnable" || this.id == "pinDisable") {
6785 if (target.pageState() == pageState.modifyPin) {
6786 disableBtn($(this));
6787 return;
6788 }
6789 }
6790 enableBtn($(this));
6791 });
6792
6793 }
6794 }
6795
6796 // �Ƿ�������
6797 function sf_isConnectedNetWork() {
6798 var info = service.getConnectionInfo();
6799 return info.connectStatus == "ppp_connected";
6800 }
6801
6802 // PINʹ�ܸı�ʱ�¼�����
6803 function sf_pinStatusChangeEvent() {
6804 if (target.pinStatus() == target.originPinStatus()) {
6805 target.pageState(pageState.common);
6806 } else {
6807 target.pageState(pageState.requirePin);
6808 }
6809 target.clear();
6810 }
6811
6812 target.changePin = sf_changePin;
6813 target.cancel = sf_cancel;
6814 target.clear = sf_clear;
6815 target.computePageState = sf_computePageState;
6816
6817 target.computePageState(sv_currentPinData);
6818
6819 target.displayModifyPinPage = sf_displayModifyPinPage;
6820 target.fixPageEnable = sf_fixPageEnable;
6821 target.isConnectedNetWork = sf_isConnectedNetWork;
6822
6823 target.pinStatusChangeEvent = ko.dependentObservable(sf_pinStatusChangeEvent, this);
6824 }
6825
6826 function init(oldViewModel) {
6827
6828 var fwVm = oldViewModel;
6829
6830 if (fwVm) {
6831 var sv_currentPinData = service.getPinData();
6832 fwVm.originPinStatus(sv_currentPinData.pin_status);
6833 fwVm.pinNumber(sv_currentPinData.pinnumber);
6834 fwVm.pukNumber(sv_currentPinData.puknumber);
6835 fwVm.computePageState(sv_currentPinData);
6836 } else {
6837 fwVm = new pinViewModel();
6838 addInterval(function () {
6839 fwVm.fixPageEnable();
6840 }, 1000);
6841 }
6842
6843 var container = $('#container')[0];
6844 ko.cleanNode(container);
6845 ko.applyBindings(fwVm, container);
6846 fwVm.fixPageEnable();
6847
6848 $('#frmPin').validate({
6849 submitHandler:function () {
6850 fwVm.changePin();
6851 },
6852 rules:{
6853 txtPuk:"puk_check",
6854 txtPin:"pin_check",
6855 txtNewPin:"pin_check",
6856 txtConfirmPin:{equalToPin:"#txtNewPin"}
6857 }
6858 });
6859 }
6860
6861 return {
6862 init:init
6863 }
6864 }
6865);
6866
6867// ��������
6868define("adm_quick_set","jquery knockout set service underscore CryptoJS".split(" "),
6869
6870 function ($, ko, config, service, _, CryptoJS) {
6871
6872 var sv_wifiState = {ok:0, wps_on:1, wifi_off:2};
6873 var sv_apnMode = {auto:"auto", manual:"manual"};
6874 var sv_minStep = 1;
6875 var sv_maxStep = 5;
6876
6877 // ��ȡ��Ȩ��ʽ
6878 function sf_fetchAuthenticationModes() {
6879 return _.map(config.APN_AUTH_MODES, function (item) {
6880 return new Option(item.name, item.value);
6881 });
6882 }
6883
6884 // WIFI��ȫģʽѡ��
6885 var sv_securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
6886 return new Option(item.name, item.value);
6887 });
6888
6889
6890 function quickSettingViewModel() {
6891 var target = this;
6892
6893 var sv_quickSettingInfo = service.getQuickSettingInfo();
6894
6895 target.currentStep = ko.observable(sv_minStep);
6896 target.ipType = ko.observable(sv_quickSettingInfo.pdp_type == "IP" ? "IP" : sv_quickSettingInfo.ipv6_pdp_type);
6897 target.supportIPv6 = config.IPV6_SUPPORT;
6898 target.supportIpv4AndIpv6 = config.IPV4_AND_V6_SUPPORT;
6899
6900 target.wpsFlag = ko.observable(sv_quickSettingInfo.WscModeOption);
6901
6902 function sf_apnDisabled() {
6903 return (sv_quickSettingInfo.apn_index < config.defaultApnSize || sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting");
6904 }
6905
6906 function sf_apnModeDisabled() {
6907 return (sv_quickSettingInfo.ppp_status == "ppp_connected" || sv_quickSettingInfo.ppp_status == "ppp_connecting" || (!target.profileName() && target.apnMode() == sv_apnMode.auto));//ѡ��Ϊ�ջ��������ӻ�������
6908 }
6909
6910 function sf_currAPN() {
6911 var sv_APNText = sv_quickSettingInfo["APN_configtmp" + sv_quickSettingInfo.apn_index];
6912 var strIPv6APN = sv_quickSettingInfo["ipv6_APN_configtmp" + sv_quickSettingInfo.apn_index];
6913
6914 var sv_apn = [];
6915 var sv_ipv6APNItems = [];
6916
6917 if (sv_APNText) {
6918 sv_apn = sv_APNText.split("($)");
6919 }
6920
6921 if (strIPv6APN) {
6922 sv_ipv6APNItems = strIPv6APN.split("($)");
6923 }
6924
6925 return {
6926 m_profile_name:sv_apn[0],
6927 wan_apn:sv_apn[1],
6928 ppp_auth_mode: sv_apn[4] == "" || typeof(sv_apn[4]) == "undefined" ? "" : sv_apn[4].toLowerCase(),
6929 ppp_username:sv_apn[5],
6930 ppp_passtmp:sv_apn[6],
6931 pdp_type: sv_apn[7],
6932 ipv6_wan_apn:sv_ipv6APNItems[1],
6933 ipv6_ppp_auth_mode:typeof(sv_ipv6APNItems[4]) == "undefined" || sv_ipv6APNItems[4] == ""? "" : sv_ipv6APNItems[4].toLowerCase(),
6934 ipv6_ppp_username:sv_ipv6APNItems[5],
6935 ipv6_ppp_passtmp:sv_ipv6APNItems[6],
6936 ipv6_pdp_type:sv_ipv6APNItems[7]
6937 }
6938 }
6939
6940 // ��ǰAPN����
6941 target.currAPN = ko.computed(sf_currAPN);
6942
6943 target.apn = ko.observable(target.currAPN().wan_apn);
6944 target.ipv6_apn = ko.observable(target.currAPN().ipv6_wan_apn);
6945 target.ipv6_selectedAuthMode = ko.observable(target.currAPN().ipv6_ppp_auth_mode);
6946 target.ipv6_username = ko.observable(target.currAPN().ipv6_ppp_username);
6947 target.ipv6_password = ko.observable(target.currAPN().ipv6_ppp_passtmp);
6948 target.profileName = ko.observable(target.currAPN().m_profile_name);
6949 target.selectedAuthMode = ko.observable(target.currAPN().ppp_auth_mode);
6950 target.username = ko.observable(target.currAPN().ppp_username);
6951 target.password = ko.observable(target.currAPN().ppp_passtmp);
6952
6953 target.transAPN = ko.observable("apn_ipv4_apn");
6954 target.transAPNIPv6 = ko.observable("apn_ipv6_apn");
6955 target.transAuthMode = ko.observable("apn_authentication_ipv4");
6956 target.transAuthModeIPv6 = ko.observable("apn_authentication_ipv6");
6957 target.transUserName = ko.observable("apn_user_name_ipv4");
6958 target.transPassword = ko.observable("apn_password_ipv4");
6959 target.transUserNameIPv6 = ko.observable("apn_user_name_ipv6");
6960 target.transPasswordIPv6 = ko.observable("apn_password_ipv6");
6961
6962
6963
6964 target.apnDisabled = ko.computed(sf_apnDisabled);
6965 target.apnMode = ko.observable(sv_quickSettingInfo.apn_mode);
6966 target.apnModeDisabled = ko.computed(sf_apnModeDisabled);
6967 target.authModes = ko.observableArray(sf_fetchAuthenticationModes());
6968
6969 if (target.ipType() == "IPv6") {
6970 target.showIPv4 = false;
6971 target.showIPv6 = true;
6972 target.transAPNIPv6("apn");
6973 target.transAuthModeIPv6("apn_authentication");
6974 target.transUserNameIPv6("apn_user_name");
6975 target.transPasswordIPv6("apn_password");
6976 } else if (config.IPV4_AND_V6_SUPPORT && target.ipType() == "IPv4v6") {
6977 target.showIPv4 = true;
6978 target.showIPv6 = true;
6979 //ʹ��Ĭ��
6980 } else if (target.ipType() == "IP" || target.ipType() == "IPv4") {
6981 target.showIPv4 = true;
6982 target.showIPv6 = false;
6983 target.transAPN("apn");
6984 target.transAuthMode("apn_authentication");
6985 target.transUserName("apn_user_name");
6986 target.transPassword("apn_password");
6987 } else { //pdp_type == "IPv4v6" && config.IPV4V6_SUPPORT
6988 target.showIPv4 = true;
6989 target.showIPv6 = false;
6990 target.transAPN("apn");
6991 target.transAuthMode("apn_authentication");
6992 target.transUserName("apn_user_name");
6993 target.transPassword("apn_password");
6994 }
6995
6996 target.wifiDisabled = (sv_quickSettingInfo.wifi_cur_state != "1");
6997 target.ssid = ko.observable(sv_quickSettingInfo.SSID1);
6998 target.broadcast = ko.observable(sv_quickSettingInfo.HideSSID);
6999 target.hasWifiWep = config.WIFI_WEP_SUPPORT;
7000 target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
7001 target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
7002
7003 target.securityModes = ko.observableArray(sv_securityModes);
7004 target.selectedSecurityMode = ko.observable(sv_quickSettingInfo.AuthMode);
7005 target.WPAKey = ko.observable(sv_quickSettingInfo.WPAPSK1);
7006
7007 target.apnMode_display = ko.observable("");
7008
7009 target.apnMode_trans = ko.computed(sf_apnMode_trans);
7010 target.selectedAuthMode_display = ko.computed(sf_selectedAuthMode_display);
7011 target.ipv6_selectedAuthMode_display = ko.computed(sf_ipv6_selectedAuthMode_display);
7012
7013 target.showWifiPassword = ko.observable(false);
7014 target.showWifiPasswordHandler = sf_showWifiPasswordHandler;
7015
7016 //�ж��Ƿ���802 n only��
7017 var sv_adInfo = service.getWifiAdvance();
7018 target.adBand = ko.observable(sv_adInfo.wifiBand);
7019 target.adMode = ko.observable(sv_adInfo.mode);
7020
7021 target.encryptType = ko.observable(sv_quickSettingInfo.EncrypType);
7022 target.keyID = ko.observable(sv_quickSettingInfo.DefaultKeyID);
7023 target.wepPassword = ko.observable("");
7024
7025 target.getWepPassword = sf_getWepPassword;
7026 target.wepPassword(target.getWepPassword());
7027 target.profileChangeHandler = sf_profileChangeHandler;
7028
7029 target.broadcast_display = ko.observable("");
7030 target.broadcast_trans = ko.computed(sf_broadcast_trans);
7031
7032 target.selectedSecurityMode_display = ko.observable();
7033 target.selectedSecurityMode_trans = ko.computed(sf_selectedSecurityMode_trans);
7034
7035
7036 target.callback = sf_callback;
7037 target.next = sf_button_next;
7038 target.previous = sf_button_previous;
7039 target.save = sf_button_save;
7040
7041 function sf_apnMode_trans() {
7042 if (sv_apnMode.auto == target.apnMode()) {
7043 target.apnMode_display($.i18n.prop("apn_auto_apn"));
7044 return "apn_auto_apn";
7045 } else {
7046 target.apnMode_display($.i18n.prop("apn_manual_apn"));
7047 return "apn_manual_apn";
7048 }
7049 }
7050
7051 function sf_broadcast_trans() {
7052 if ("0" == target.broadcast()) {
7053 target.broadcast_display($.i18n.prop("enable"));
7054 return "enable";
7055 } else {
7056 target.broadcast_display($.i18n.prop("disable"));
7057 return "disable";
7058 }
7059 }
7060
7061 function sf_button_next() {
7062 var currentStep = target.currentStep();
7063 var toStep = target.currentStep() + 1;
7064 sf_changeStep(toStep);
7065
7066 if (currentStep == 1 && target.apnMode() == sv_apnMode.auto) {
7067 toStep = target.currentStep() + 1;
7068 sf_changeStep(toStep);
7069 }
7070 }
7071
7072 function sf_button_previous() {
7073
7074 var currentStep = target.currentStep();
7075 var toStep = target.currentStep() - 1;
7076
7077 sf_changeStep(toStep);
7078
7079 if (currentStep == 3 && target.apnMode() == sv_apnMode.auto) {
7080 toStep = target.currentStep() - 1;
7081 sf_changeStep(toStep);
7082 }
7083 }
7084 function sf_button_save() {
7085 var submit = function () {
7086 sf_quickSetting4IPv6();
7087 };
7088 var result = sf_isDisabled_Wifi();
7089 if(result == sv_wifiState.wifi_off){
7090 showConfirm("quick_setting_wifi_disable_confirm", submit);
7091 } else if (result == sv_wifiState.wps_on) {
7092 showAlert("wps_on_info");
7093 } else{
7094 showConfirm("quick_setting_param_changed_confirm", submit);//submit();
7095 }
7096 }
7097 // ���������ύ���Ļص�����
7098 function sf_callback(data) {
7099 if (data.result == "success") {
7100 successOverlay();
7101 location.hash = "#network_choose";
7102 }
7103 else {
7104 errorOverlay();
7105 }
7106 }
7107
7108 // �任����ʱ����
7109 function sf_changeStep(i_step) {
7110 if (i_step > sv_maxStep) {
7111 i_step = sv_maxStep;
7112 } else if (i_step < sv_minStep) {
7113 i_step = sv_minStep;
7114 }
7115
7116 target.currentStep(i_step);
7117 return true;
7118 }
7119
7120 function sf_ipv6_selectedAuthMode_display() {
7121 var mode = target.ipv6_selectedAuthMode();
7122 return sf_getAuthModeNameByValue(mode);
7123 }
7124 // ���ݼ�Ȩģʽ��ֵ��������
7125 function sf_getAuthModeNameByValue(authMode) {
7126 for (var i = 0; i < config.APN_AUTH_MODES.length; i++) {
7127 if (authMode == config.APN_AUTH_MODES[i].value) {
7128 return config.APN_AUTH_MODES[i].name;
7129 }
7130 }
7131 }
7132
7133 function sf_getWepPassword(){
7134 return target.keyID() == '3' ? sv_quickSettingInfo.Key4Str1 : (target.keyID() == '2' ? sv_quickSettingInfo.Key3Str1 : target.keyID() == '1' ? sv_quickSettingInfo.Key2Str1 : sv_quickSettingInfo.Key1Str1);
7135 }
7136
7137 function sf_isDisabled_Wifi() {
7138 var s_wpsInfo = service.getWpsInfo();
7139 if(s_wpsInfo.radioFlag == "0"){
7140 return sv_wifiState.wifi_off;
7141 }else if (s_wpsInfo.wpsFlag == '1') {
7142 return sv_wifiState.wps_on;
7143 }
7144 return sv_wifiState.ok;
7145 }
7146 function sf_profileChangeHandler(i_data, i_event) {
7147 $("#pwdWepKey").parent().find("label[class='error']").hide();
7148 target.wepPassword(target.getWepPassword());
7149 return true;
7150 }
7151
7152 // ���������ύ(֧��IPv6��
7153 function sf_quickSetting4IPv6() {
7154 showLoading();
7155 var useIPv4ForV6 = config.IPV4V6_SUPPORT && target.currAPN().pdp_type == "IPv4v6";
7156
7157 var ciphertext = "";
7158 if (config.PASSWORD_ENCODE) {
7159 ciphertext = target.WPAKey();
7160 } else {
7161 var kparam = service.getDeviceInfoLow();
7162 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
7163 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
7164 ciphertext = CryptoJS.AES.encrypt(target.WPAKey(), tkey, {
7165 iv: tiv,
7166 mode: CryptoJS.mode.CBC,
7167 padding: CryptoJS.pad.ZeroPadding
7168 }).toString();
7169 }
7170
7171 var s_quickSettingParameters = {
7172 apn_index: sv_quickSettingInfo.apn_index,
7173 apnMode: target.apnMode(),
7174 Encryption_Mode_hid: target.selectedSecurityMode(),
7175 ipv6_ppp_auth_mode: useIPv4ForV6 ? target.selectedAuthMode() : target.ipv6_selectedAuthMode(),
7176 ipv6_ppp_username: useIPv4ForV6 ? target.username() : target.ipv6_username(),
7177 ipv6_ppp_passtmp: useIPv4ForV6 ? target.password() : target.ipv6_password(),
7178 ipv6_wan_apn: useIPv4ForV6 ? target.apn() : target.ipv6_apn(),
7179 pdp_type: target.ipType(),
7180 ppp_auth_mode: target.selectedAuthMode(),
7181 ppp_username: target.username(),
7182 ppp_passtmp: target.password(),
7183 profile_name: target.profileName(),
7184 //Ŀǰ����ģʽֻ��2�֣�����3������Ϊ�̶�ֵ
7185 //������Ҫ����Ϊ5�֣�����ֵ��Ҫ����
7186 security_shared_mode: "NONE",
7187 SSID_Broadcast: target.broadcast(),
7188 SSID_name: target.ssid(),
7189 wan_apn: target.apn(),
7190 wep_default_key: 0,
7191 WPA_ENCRYPTION_hid: target.selectedSecurityMode() == "OPEN" ? "NONE" : target.selectedSecurityMode() == "WPA2PSK" ? 1 : 2,
7192 WPA_PreShared_Key: ciphertext
7193 }
7194
7195 s_quickSettingParameters.wep_default_key = target.keyID();
7196
7197 if(target.encryptType() == "SHARED" || target.selectedSecurityMode() == "WEP") {
7198
7199 s_quickSettingParameters.security_shared_mode = "WEP";
7200
7201 s_quickSettingParameters.wep_key_1 = sv_quickSettingInfo.Key1Str1;
7202 s_quickSettingParameters.wep_key_2 = sv_quickSettingInfo.Key2Str1;
7203 s_quickSettingParameters.wep_key_3 = sv_quickSettingInfo.Key3Str1;
7204 s_quickSettingParameters.wep_key_4 = sv_quickSettingInfo.Key4Str1;
7205
7206 var WEPSelectTmp = '0';
7207
7208 if(target.wepPassword().length =='5' ||target.wepPassword().length =='13'){
7209 WEPSelectTmp = '1';
7210 }else{
7211 WEPSelectTmp = '0';
7212 }
7213
7214 if(target.keyID() =='3'){
7215 s_quickSettingParameters.wep_key_4 = target.wepPassword();
7216 s_quickSettingParameters.WEP4Select = WEPSelectTmp;
7217 }else if(target.keyID() =='2'){
7218 s_quickSettingParameters.wep_key_3 = target.wepPassword();
7219 s_quickSettingParameters.WEP3Select = WEPSelectTmp;
7220 }else if(target.keyID() =='1'){
7221 s_quickSettingParameters.wep_key_2 = target.wepPassword();
7222 s_quickSettingParameters.WEP2Select = WEPSelectTmp;
7223 }else{
7224 s_quickSettingParameters.wep_key_1 = target.wepPassword();
7225 s_quickSettingParameters.WEP1Select = WEPSelectTmp;
7226 }
7227 }else if(target.encryptType() == "WPAPSKWPA2PSK") {
7228 s_quickSettingParameters.security_shared_mode = "NONE";
7229 }else {
7230 s_quickSettingParameters.security_shared_mode = "NONE";
7231 }
7232
7233 service.setQuickSetting4IPv6(s_quickSettingParameters, target.callback);
7234 }
7235
7236 function sf_selectedAuthMode_display() {
7237 var mode = target.selectedAuthMode();
7238 return sf_getAuthModeNameByValue(mode);
7239 }
7240
7241 function sf_selectedSecurityMode_trans() {
7242 var mode = target.selectedSecurityMode();
7243 var modesOption = config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES;
7244 for (var i = 0; i < modesOption.length; i++) {
7245 if (mode == modesOption[i].value) {
7246 target.selectedSecurityMode_display($.i18n.prop("security_mode_" + modesOption[i].value));
7247 return "security_mode_" + modesOption[i].value;
7248 }
7249 }
7250 }
7251
7252 function sf_showWifiPasswordHandler(){
7253 $("#pwdWepKey").parent().find(".error").hide();
7254 $("#codeWPAKey").parent().find(".error").hide();
7255 var checkbox = $("#showWifiPassword:checked");
7256 if(checkbox && checkbox.length == 0){
7257 target.showWifiPassword(true);
7258 }else{
7259 target.showWifiPassword(false);
7260 }
7261 }
7262
7263 }
7264
7265 function init() {
7266 var container = $('#container');
7267 ko.cleanNode(container[0]);
7268 var fwVm = new quickSettingViewModel();
7269 ko.applyBindings(fwVm, container[0]);
7270
7271 $('#quickSettingForm').validate({
7272 submitHandler:function () {
7273 if (fwVm.currentStep() < 5) {
7274 fwVm.next();
7275 } else {
7276 fwVm.save();
7277 }
7278 },
7279 rules:{
7280 txtAPN:"apn_check",
7281 txtIPv6APN:"apn_check",
7282 txtSSID:'ssid',
7283 pwdWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
7284 txtWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
7285 txtWPAKey:'wifi_password_check',
7286 codeWPAKey:'wifi_password_check',
7287 txtUserName:'ppp_username_check',
7288 txtIPv6UserName:'ppp_username_check',
7289 txtSecretCode:"ppp_secretcode_check",
7290 txtIPv6SecretCode:"ppp_secretcode_check"
7291 },
7292 errorPlacement:function (error, element) {
7293 var id = element.attr("id");
7294 if (id == "pwdWepKey" || id == "txtWepKey"){
7295 error.insertAfter("#lblShowWepPassword");
7296 } else if (id == "txtWPAKey" || id == "codeWPAKey") {
7297 error.insertAfter("#lblShowWifiPassword");
7298 } else {
7299 error.insertAfter(element);
7300 }
7301 }
7302 });
7303 }
7304
7305 return {
7306 init:init
7307 };
7308 }
7309);
7310
7311define("main","set service knockout underscore jquery statusBar echarts".split(" "), function (set, fnc, libko, libus, libjq, barStat, echarts) {
7312
7313 var chartOptions = {
7314 color: ['red', 'red', 'red', 'red', 'red'],
7315 series: [{
7316 name: '��������',
7317 type: 'pie',
7318 radius: ['0', '72'],
7319 itemStyle: {
7320 normal: {
7321 label: {
7322 show: false
7323 },
7324 labelLine: {
7325 show: false
7326 }
7327 }
7328 },
7329 data: [],
7330 selectedOffset: 3
7331 }
7332 ],
7333 animation: false,
7334 title: {
7335 text: '',
7336 x: 'center',
7337 y: 'center',
7338 itemGap: 0,
7339 textStyle: {
7340 color: '#FFF',
7341 fontFamily: '΢���ź�',
7342 fontSize: 20,
7343 fontWeight: 'bolder'
7344 },
7345 subtextStyle: {
7346 color: '#FFF',
7347 fontFamily: '΢���ź�',
7348 fontSize: 16,
7349 fontWeight: 'bolder'
7350 }
7351 },
7352 tooltip: {
7353 formatter: "{b}"
7354 },
7355 };
7356 var languageOld = window.language;
7357 var num_refresh = 0;
7358 var traffic_graphic_chart = null;
7359 var connStat = {
7360 CONNECTED: 1,
7361 DISCONNECTED: 2,
7362 CONNECTING: 3,
7363 DISCONNECTING: 4
7364 };
7365 function init() {
7366 num_refresh = 0;
7367 homeUtil.oldUsedData = null;
7368 homeUtil.oldAlarmData = null;
7369 traffic_graphic_chart = echarts.init(libjq("#traffic_graphic")[0]);
7370 var container = libjq('#container')[0];
7371 libko.cleanNode(container);
7372 var tmp = new VmHome();
7373 libko.applyBindings(tmp, container);
7374 var data = fnc.getLoginData();
7375 var psw_flg = data.psw_changed;
7376 if (psw_flg != "1") {
7377 showConfirm("password_note_first_change", function () {
7378 window.location.hash = '#pwd_mode';
7379 });
7380 return;
7381 }
7382 }
7383
7384 var homeUtil = {
7385 initStatus: null,
7386 initShownStatus: function (data) {
7387 this.initStatus = {};
7388 var ipv6Mode = data.ipv6PdpType.toLowerCase().indexOf("v6") > 0;
7389 if (set.RJ45_SUPPORT) {
7390 var mode = checkCableMode(data.blc_wan_mode);
7391 if (mode) {
7392 this.initStatus.showIpv6WanIpAddr = false;
7393 this.initStatus.showIpv4WanIpAddr = true;
7394 } else if (set.IPV6_SUPPORT) {
7395 if (data.pdpType == "IP") {
7396 this.initStatus.showIpv6WanIpAddr = false;
7397 this.initStatus.showIpv4WanIpAddr = true;
7398 } else if (ipv6Mode) {
7399 if (data.ipv6PdpType == "IPv6") {
7400 this.initStatus.showIpv6WanIpAddr = true;
7401 this.initStatus.showIpv4WanIpAddr = false;
7402 } else {
7403 this.initStatus.showIpv6WanIpAddr = true;
7404 this.initStatus.showIpv4WanIpAddr = true;
7405 }
7406 }
7407 } else {
7408 this.initStatus.showIpv6WanIpAddr = false;
7409 this.initStatus.showIpv4WanIpAddr = true;
7410 }
7411 } else {
7412 if (set.IPV6_SUPPORT) {
7413 if (data.pdpType == "IP") {
7414 this.initStatus.showIpv6WanIpAddr = false;
7415 this.initStatus.showIpv4WanIpAddr = true;
7416 } else if (ipv6Mode) {
7417 if (data.ipv6PdpType == "IPv6") {
7418 this.initStatus.showIpv6WanIpAddr = true;
7419 this.initStatus.showIpv4WanIpAddr = false;
7420 } else {
7421 this.initStatus.showIpv6WanIpAddr = true;
7422 this.initStatus.showIpv4WanIpAddr = true;
7423 }
7424 }
7425 } else {
7426 this.initStatus.showIpv6WanIpAddr = false;
7427 this.initStatus.showIpv4WanIpAddr = true;
7428 }
7429 }
7430 },
7431 wanIpGet: function (data) {
7432 var addrInfo = {
7433 wanIpAddress: '',
7434 ipv6WanIpAddress: ''
7435 };
7436 addrInfo.wanIpAddress = verifyDeviceInfo(data.wanIpAddress);
7437 addrInfo.ipv6WanIpAddress = verifyDeviceInfo(data.ipv6WanIpAddress);
7438 return addrInfo;
7439 },
7440 cachedAPStationBasic: null,
7441 cachedConnectionMode: null,
7442 getCanConnectNetWork: function (param) {
7443 var status = fnc.getStatusInfo();
7444 if (status.simStatus != "modem_init_complete") {
7445 return false;
7446 }
7447 var typeNetworkTmp = status.networkType.toLowerCase();
7448 if (typeNetworkTmp == 'searching') {
7449 return false;
7450 }
7451 if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
7452 typeNetworkTmp = 'limited_service';
7453 }
7454 if (typeNetworkTmp == 'no service') {
7455 typeNetworkTmp = 'no_service';
7456 }
7457 if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
7458 if (param.cStatus() != connStat.CONNECTED) {
7459 return false;
7460 }
7461 }
7462 if (set.AP_STATION_SUPPORT) {
7463 if (status.connectWifiStatus == "connect") {
7464 if (status.ap_station_mode == "wifi_pref") {
7465 return false;
7466 }
7467 }
7468 }
7469 return true;
7470 },
7471 doConnect: function () {
7472 showLoading('connecting');
7473 fnc.connect({}, function (data) {
7474 if (data.result) {
7475 successOverlay();
7476 } else {
7477 errorOverlay();
7478 }
7479 });
7480 },
7481 refreshHomeData: function (param) {
7482 var info = fnc.getConnectionInfo();
7483 param.connectStatus(info.connectStatus);
7484 param.canConnect(this.getCanConnectNetWork(param));
7485 param.networkType(homeUtil.getNetworkType(info.networkType));
7486 if (info.connectStatus == "ppp_connected") {
7487 param.current_Flux(transUnit(parseInt(info.data_counter.currentReceived, 10) + parseInt(info.data_counter.currentSent, 10), false));
7488 param.connected_Time(transSecond2Time(info.data_counter.currentConnectedTime));
7489 param.up_Speed(transUnit(info.data_counter.uploadRate, true));
7490 param.down_Speed(transUnit(info.data_counter.downloadRate, true));
7491 } else {
7492 param.current_Flux(transUnit(0, false));
7493 param.connected_Time(transSecond2Time(0));
7494 param.up_Speed(transUnit(0, true));
7495 param.down_Speed(transUnit(0, true));
7496 }
7497 param.trafficAlertEnable(info.limitVolumeEnable);
7498 if (info.limitVolumeEnable) {
7499 if (info.limitVolumeType == '1') {
7500 param.trafficUsed(transUnit(parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10), false));
7501 param.trafficLimited(transUnit(info.limitDataMonth, false));
7502 } else {
7503 param.trafficUsed(transSecond2Time(info.data_counter.monthlyConnectedTime));
7504 param.trafficLimited(transSecond2Time(info.limitTimeMonth));
7505 }
7506 }
7507 if (languageOld != window.language) {
7508 languageOld = window.language;
7509 num_refresh = 1;
7510 }
7511 if (param.showTraffic()) {
7512 homeUtil.updateEcharts(info);
7513 } else {
7514 homeUtil.allFreeEcharts();
7515 }
7516 homeUtil.refreshStationInfo(param);
7517 },
7518 allFreeEcharts: function () {
7519 var usedData = homeUtil.data.free;
7520 usedData.value = 1;
7521 usedData.selected = false;
7522 usedData.name = libjq.i18n.prop("echarts_no");
7523 chartOptions.series[0].data = [usedData];
7524 chartOptions.title.text = '';
7525 homeUtil.setEcharts(chartOptions, libjq.i18n.prop("echarts_no"));
7526 },
7527 getNetworkType: function (networkType) {
7528 var typeNetworkTmp = networkType.toLowerCase();
7529 if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
7530 typeNetworkTmp = 'limited_service';
7531 }
7532 if (typeNetworkTmp == 'no service') {
7533 typeNetworkTmp = 'no_service';
7534 }
7535 if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
7536 return libjq.i18n.prop("network_type_" + typeNetworkTmp);
7537 } else {
7538 return networkType;
7539 }
7540 },
7541 data: {
7542 full: {
7543 value: 30,
7544 name: '��������',
7545 itemStyle: {
7546 normal: {
7547 color: '#DF4313'
7548 }
7549 }
7550 },
7551 used: {
7552 value: 30,
7553 name: '��ʹ��',
7554 itemStyle: {
7555 normal: {
7556 color: '#8CC916'
7557 }
7558 }
7559 },
7560 left1: {
7561 value: 50,
7562 name: '����ֵ��δʹ��',
7563 itemStyle: {
7564 normal: {
7565 color: '#D8D8D8'
7566 }
7567 }
7568 },
7569 free: {
7570 value: 50,
7571 name: 'δʹ��',
7572 itemStyle: {
7573 normal: {
7574 color: '#D8D8D8'
7575 }
7576 }
7577 },
7578 alert: {
7579 value: 1,
7580 name: '����ֵ',
7581 itemStyle: {
7582 normal: {
7583 color: '#FF5500'
7584 }
7585 }
7586 },
7587 alarm: {
7588 value: 19.7,
7589 name: '������',
7590 itemStyle: {
7591 normal: {
7592 color: '#8CC916'
7593 }
7594 }
7595 },
7596 start: {
7597 value: 50,
7598 name: '����ֵ��δʹ��',
7599 itemStyle: {
7600 normal: {
7601 color: '#D8D8D8'
7602 }
7603 }
7604 },
7605 },
7606 getDataInfo: function (value) {
7607 return {
7608 data: /\d+(.\d+)?/.exec(value)[0],
7609 unit: /[A-Z]{1,2}/.exec(value)[0]
7610 }
7611 },
7612 oldAlarmData: null,
7613 oldUsedData: null,
7614 updateEcharts: function (info) {
7615 var startName = libjq.i18n.prop("echarts_no");
7616 num_refresh++;
7617 if (num_refresh % 10 != 2) {
7618 return false;
7619 }
7620 var total = 0,
7621 used = 0,
7622 reach = 0,
7623 left = 0,
7624 alarm = 0,
7625 left1 = 0;
7626 if (info.limitVolumeEnable) {
7627 startName = libjq.i18n.prop("echarts_used");
7628 chartOptions.series[0].data = [];
7629 if (info.limitVolumeType == '1') {
7630 var limitedDataFormatted = transUnit(info.limitDataMonth, false);
7631 chartOptions.series[0].data = [];
7632 if (info.limitDataMonth == 0) {
7633 var usedData = homeUtil.data.used;
7634 usedData.value = 1;
7635 usedData.selected = false;
7636 usedData.name = libjq.i18n.prop("echarts_used");
7637 chartOptions.series[0].data.push(usedData);
7638 } else {
7639 var dataInfo = homeUtil.getDataInfo(limitedDataFormatted);
7640 total = dataInfo.data * homeUtil.getUnitValue(dataInfo.unit) * 1048576;
7641 used = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
7642 reach = total * info.limitVolumePercent / 100;
7643 if (used >= total) {
7644 var fullData = homeUtil.data.full;
7645 fullData.value = 100;
7646 fullData.name = libjq.i18n.prop("echarts_full");
7647 chartOptions.series[0].data.push(fullData);
7648 startName = libjq.i18n.prop("echarts_full");
7649 } else {
7650 if (reach - used > 0) {
7651 left1 = reach - used;
7652 left = total - reach;
7653 } else {
7654 alarm = used - reach;
7655 left = total - used;
7656 }
7657 var usedData = homeUtil.data.used;
7658 if (reach - used > 0) {
7659 usedData.value = used;
7660 } else {
7661 usedData.value = reach;
7662 }
7663 usedData.name = libjq.i18n.prop("echarts_used");
7664 chartOptions.series[0].data.push(usedData);
7665 if (left1 > 0) {
7666 var left1Data = homeUtil.data.left1;
7667 left1Data.value = left1;
7668 left1Data.name = libjq.i18n.prop("echarts_left1");
7669 chartOptions.series[0].data.push(left1Data);
7670 }
7671 var alertData = homeUtil.data.alert;
7672 alertData.value = total / 200;
7673 alertData.name = libjq.i18n.prop("echarts_alert");
7674 chartOptions.series[0].data.push(alertData);
7675 if (alarm > 0) {
7676 var alarmData = homeUtil.data.alarm;
7677 alarmData.value = alarm;
7678 alarmData.name = libjq.i18n.prop("echarts_alarm");
7679 chartOptions.series[0].data.push(alarmData);
7680 }
7681 var freeData = homeUtil.data.free;
7682 freeData.value = left;
7683 freeData.name = libjq.i18n.prop("echarts_free");
7684 chartOptions.series[0].data.push(freeData);
7685 }
7686 }
7687 } else {
7688 chartOptions.series[0].data = [];
7689 if (info.limitTimeMonth == 0) {
7690 var usedData = homeUtil.data.used;
7691 usedData.value = 1;
7692 usedData.selected = false;
7693 usedData.name = libjq.i18n.prop("echarts_used");
7694 chartOptions.series[0].data.push(usedData);
7695 } else {
7696 total = info.limitTimeMonth;
7697 used = info.data_counter.monthlyConnectedTime;
7698 reach = total * info.limitVolumePercent / 100;
7699 if (used >= total) {
7700 var fullTime = homeUtil.data.full;
7701 fullTime.value = 100;
7702 fullTime.name = libjq.i18n.prop("echarts_full");
7703 chartOptions.series[0].data.push(fullTime);
7704 startName = libjq.i18n.prop("echarts_full");
7705 } else {
7706 if (reach - used > 0) {
7707 left1 = reach - used;
7708 left = total - reach;
7709 } else {
7710 alarm = used - reach;
7711 left = total - used;
7712 }
7713 var usedTime = homeUtil.data.used;
7714 if (reach - used > 0) {
7715 usedTime.value = used;
7716 } else {
7717 usedTime.value = reach;
7718 }
7719 usedTime.name = libjq.i18n.prop("echarts_used");
7720 chartOptions.series[0].data.push(usedTime);
7721 if (left1 > 0) {
7722 var left1Time = homeUtil.data.left1;
7723 left1Time.value = left1;
7724 left1Time.name = libjq.i18n.prop("echarts_left1");
7725 chartOptions.series[0].data.push(left1Time);
7726 }
7727 var alertTime = homeUtil.data.alert;
7728 alertTime.value = total / 200;
7729 alertTime.name = libjq.i18n.prop("echarts_alert");
7730 chartOptions.series[0].data.push(alertTime);
7731 if (alarm > 0) {
7732 var alarmTime = homeUtil.data.alarm;
7733 alarmTime.value = alarm;
7734 alarmTime.name = libjq.i18n.prop("echarts_alarm");
7735 chartOptions.series[0].data.push(alarmTime);
7736 }
7737 var freeTime = homeUtil.data.free;
7738 freeTime.value = left;
7739 freeTime.name = libjq.i18n.prop("echarts_free");
7740 chartOptions.series[0].data.push(freeTime);
7741 }
7742 }
7743 }
7744 } else {
7745 var usedData = homeUtil.data.used;
7746 usedData.value = 1;
7747 usedData.selected = false;
7748 usedData.name = libjq.i18n.prop("echarts_no");
7749 chartOptions.series[0].data = [usedData];
7750 chartOptions.title.text = '';
7751 }
7752 var firstEle = libus.find(chartOptions.series[0].data, function (n) {
7753 return n.name == libjq.i18n.prop("echarts_used");
7754 });
7755 var alarmEle = libus.find(chartOptions.series[0].data, function (n) {
7756 return n.name == libjq.i18n.prop("echarts_alarm");
7757 });
7758 if (!alarmEle) {
7759 alarmEle = {
7760 value: 0
7761 };
7762 }
7763 if (typeof firstEle == "undefined") {
7764 homeUtil.setEcharts(chartOptions, startName);
7765 } else if (homeUtil.oldUsedData != firstEle.value || homeUtil.oldAlarmData != alarmEle.value) {
7766 homeUtil.oldUsedData = firstEle.value;
7767 homeUtil.oldAlarmData = alarmEle.value;
7768 homeUtil.setEcharts(chartOptions, startName);
7769 }
7770 },
7771 getUnitValue: function (unit) {
7772 unit = unit.toUpperCase();
7773 if (unit == 'GB') {
7774 return '1024';
7775 } else if (unit == 'TB') {
7776 return '1048576';
7777 } else {
7778 return '1';
7779 }
7780 },
7781 setEcharts: function (options, startName) {
7782 var startPart = homeUtil.data.start;
7783 startPart.value = 0;
7784 startPart.name = startName;
7785 startPart.selected = false;
7786 var arr = [startPart].concat(options.series[0].data);
7787 options.series[0].data = arr;
7788 traffic_graphic_chart.setOption(options, true);
7789 addTimeout(function () {
7790 traffic_graphic_chart.resize();
7791 }, 1000);
7792 },
7793 refreshStationInfo: function (param) {
7794 param.wirelessDeviceNum(fnc.getStatusInfo().wirelessDeviceNum);
7795 if (num_refresh % 10 == 2) {
7796 fnc.getAttachedCableDevices({}, function (data) {
7797 param.wireDeviceNum(data.attachedDevices.length);
7798 });
7799 }
7800 },
7801 getUnit: function (val) {
7802 if (val == '1024') {
7803 return 'GB';
7804 } else if (val == '1048576') {
7805 return 'TB';
7806 } else {
7807 return 'MB';
7808 }
7809 },
7810 refreshOpmodeInfo: function (param) {
7811 var obj = fnc.getOpMode();
7812 param.isLoggedIn(obj.loginfo == "ok");
7813 var currentMode = checkCableMode(obj.blc_wan_mode);
7814 if (param.opCurMode() && !currentMode) {
7815 var data = fnc.getLoginData();
7816 var state = data.modem_main_state;
7817 if (state == "modem_sim_undetected" || state == "modem_undetected" || state == "modem_sim_destroy" || state == "modem_waitpin" || state == "modem_waitpuk" || state == "modem_imsi_waitnck") {
7818 window.location.reload();
7819 return;
7820 }
7821 }
7822 param.opCurMode(currentMode);
7823 if (currentMode && obj.ethwan_mode == "DHCP") {
7824 param.enableFlag(false);
7825 } else if ((!currentMode && obj.ppp_status != "ppp_disconnected") || (currentMode && obj.rj45_state != "idle" && obj.rj45_state != "dead")) {
7826 param.enableFlag(true);
7827 } else {
7828 param.enableFlag(false);
7829 }
7830 var mode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;
7831 var currentOpMode = "";
7832 switch (mode) {
7833 case "AUTO":
7834 currentOpMode = "opmode_auto";
7835 break;
7836 case "PPPOE":
7837 currentOpMode = "opmode_cable";
7838 break;
7839 case "PPP":
7840 currentOpMode = "opmode_gateway";
7841 break;
7842 default:
7843 break;
7844 }
7845 libjq("#opmode").attr("data-trans", currentOpMode).text(libjq.i18n.prop(currentOpMode));
7846 param.isShowHomeConnect(!currentMode);
7847 param.showTraffic(set.TRAFFIC_SUPPORT && !currentMode);
7848 param.isSupportQuicksetting(set.HAS_QUICK_SETTING && !currentMode);
7849 }
7850 };
7851 function VmHome() {
7852 var target = this;
7853 target.hasSms = set.HAS_SMS;
7854 target.hasPhonebook = set.HAS_PHONEBOOK;
7855 target.isSupportSD = set.SD_CARD_SUPPORT;
7856 target.isCPE = set.PRODUCT_TYPE == 'CPE';
7857 target.hasRj45 = set.RJ45_SUPPORT;
7858 target.notDataCard = set.PRODUCT_TYPE != 'DATACARD';
7859 target.hasParentalControl = set.HAS_PARENTAL_CONTROL;
mj.qu28df13a2025-01-07 19:14:21 -08007860 target.hasUssd = set.HAS_USSD;
w.dengd463b342024-12-20 10:21:38 +08007861 var wifiInfo = fnc.getWifiBasic();
7862 if (set.WIFI_SUPPORT_QR_SWITCH) {
7863 target.showQRCode = set.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;
7864 } else {
7865 target.showQRCode = set.WIFI_SUPPORT_QR_CODE;
7866 }
7867 if(set.WIFI_SUPPORT_QR_CODE){
7868 target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + libjq.now();
7869 } else {
7870 target.qrcodeSrc = './pic/res_blacktrans.png';
7871 }
7872 if (target.hasRj45) {
7873 var opModeObj = checkCableMode(fnc.getOpMode().blc_wan_mode);
7874 target.opCurMode = libko.observable(opModeObj);
7875 target.isShowHomeConnect = libko.observable(!opModeObj);
7876 target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT && !opModeObj);
7877 target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING && !opModeObj);
7878 } else {
7879 target.isShowHomeConnect = libko.observable(true);
7880 target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT);
7881 target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING);
7882 }
7883 if (set.PRODUCT_TYPE == 'DATACARD') {
7884 libjq('#home_image').addClass('data-card');
7885 }
7886 var info = fnc.getConnectionInfo();
7887 target.networkType = libko.observable(homeUtil.getNetworkType(info.networkType));
7888 target.connectStatus = libko.observable(info.connectStatus);
7889 target.canConnect = libko.observable(false);
7890 target.cStatus = libko.computed(function () {
7891 if (target.connectStatus().indexOf('_connected') != -1) {
7892 return connStat.CONNECTED;
7893 } else if (target.connectStatus().indexOf('_disconnecting') != -1) {
7894 return connStat.DISCONNECTING;
7895 } else if (target.connectStatus().indexOf('_connecting') != -1) {
7896 return connStat.CONNECTING;
7897 } else {
7898 return connStat.DISCONNECTED;
7899 }
7900 });
7901 target.current_Flux = libko.observable(transUnit(0, false));
7902 target.connected_Time = libko.observable(transSecond2Time(0));
7903 target.up_Speed = libko.observable(transUnit(0, true));
7904 target.down_Speed = libko.observable(transUnit(0, true));
7905 target.isLoggedIn = libko.observable(false);
7906 target.enableFlag = libko.observable(true);
7907 target.simSerialNumber = libko.observable('');
7908 target.imei = libko.observable('');
7909 target.imsi = libko.observable('');
mj.qu28df13a2025-01-07 19:14:21 -08007910 target.iccid = libko.observable('');
7911 target.cellid = libko.observable('');
w.dengd463b342024-12-20 10:21:38 +08007912 target.ssid = libko.observable('');
7913 target.hasWifi = set.HAS_WIFI;
7914 target.showMultiSsid = libko.observable(set.HAS_MULTI_SSID && wifiInfo.multi_ssid_enable == "1");
7915 target.trafficAlertEnable = libko.observable(false);
7916 target.trafficUsed = libko.observable('');
7917 target.trafficLimited = libko.observable('');
7918 target.wireDeviceNum = libko.observable(fnc.getAttachedCableDevices().attachedDevices.length);
7919 target.wirelessDeviceNum = libko.observable(fnc.getStatusInfo().wirelessDeviceNum);
7920 target.showOpModeWindow = function () {
7921 if (target.enableFlag()) {
7922 return;
7923 }
7924 showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});
7925 };
7926 target.currentOpMode = libko.observable("0");
7927 var popoverShown = false;
7928 libjq('#showDetailInfo').popover({
7929 html: true,
7930 placement: 'top',
7931 trigger: 'focus',
7932 title: function () {
7933 return libjq.i18n.prop('device_info')
7934 },
7935 content: function () {
7936 return getDetailInfoContent();
7937 }
7938 }).on('shown.bs.popover', function () {
7939 popoverShown = true;
7940 }).on('hidden.bs.popover', function () {
7941 popoverShown = false;
7942 });
7943 function fetchDeviceInfo() {
7944 var data = fnc.getDeviceInfo();
7945 target.simSerialNumber(verifyDeviceInfo(data.simSerialNumber));
7946 target.imei(verifyDeviceInfo(data.imei));
7947 target.imsi(verifyDeviceInfo(data.imsi));
mj.qu28df13a2025-01-07 19:14:21 -08007948 target.iccid(verifyDeviceInfo(data.iccid));
7949 target.cellid(verifyDeviceInfo(data.cellid));
w.dengd463b342024-12-20 10:21:38 +08007950 target.ssid(verifyDeviceInfo(data.ssid));
7951 target.showMultiSsid(set.HAS_MULTI_SSID && data.multi_ssid_enable == "1");
7952 return data;
7953 }
7954 fetchDeviceInfo();
7955 function getDetailInfoContent() {
7956 var data = fetchDeviceInfo();
7957 homeUtil.initShownStatus(data);
7958 var addrInfo = homeUtil.wanIpGet(data);
7959 var compiled = libus.template(libjq("#detailInfoTmpl").html());
7960 var tmpl = compiled({
7961 simSerialNumber: verifyDeviceInfo(data.simSerialNumber),
7962 imei: verifyDeviceInfo(data.imei),
7963 imsi: verifyDeviceInfo(data.imsi),
mj.qu28df13a2025-01-07 19:14:21 -08007964 iccid : verifyDeviceInfo(data.iccid),
7965 cellid: verifyDeviceInfo(data.cellid),
w.dengd463b342024-12-20 10:21:38 +08007966 signal: signalFormat(data.signal),
7967 hasWifi: set.HAS_WIFI,
7968 isCPE: set.PRODUCT_TYPE == 'CPE',
7969 hasRj45: set.RJ45_SUPPORT,
7970 showMultiSsid: set.HAS_MULTI_SSID && data.multi_ssid_enable == "1",
7971 ssid: verifyDeviceInfo(data.ssid),
7972 max_access_num: verifyDeviceInfo(data.max_access_num),
7973 m_ssid: verifyDeviceInfo(data.m_ssid),
7974 m_max_access_num: verifyDeviceInfo(data.m_max_access_num),
7975 wifi_long_mode: "wifi_des_" + data.wifiRange,
7976 lanDomain: verifyDeviceInfo(data.lanDomain),
7977 ipAddress: verifyDeviceInfo(data.ipAddress),
7978 showMacAddress: set.SHOW_MAC_ADDRESS,
7979 macAddress: verifyDeviceInfo(data.macAddress),
7980 showIpv4WanIpAddr: homeUtil.initStatus.showIpv4WanIpAddr,
7981 wanIpAddress: addrInfo.wanIpAddress,
7982 showIpv6WanIpAddr: homeUtil.initStatus.showIpv6WanIpAddr,
7983 ipv6WanIpAddress: addrInfo.ipv6WanIpAddress,
7984 sw_version: verifyDeviceInfo(data.sw_version),
7985 hw_version: verifyDeviceInfo(data.hw_version)
7986 });
7987 return libjq(tmpl).translate();
7988 }
7989 target.connectHandler = function () {
7990 if (target.connectStatus() == "ppp_connected") {
7991 showLoading('disconnecting');
7992 fnc.disconnect({}, function (data) {
7993 if (data.result) {
7994 successOverlay();
7995 } else {
7996 errorOverlay();
7997 }
7998 });
7999 } else {
8000 if (fnc.getStatusInfo().roamingStatus) {
8001 showConfirm('dial_roaming_connect', function () {
8002 target.connect();
8003 });
8004 } else {
8005 target.connect();
8006 }
8007 }
8008 };
8009 target.connect = function () {
8010 var statusInfo = fnc.getStatusInfo();
8011 var trafficResult = barStat.getTrafficResult(statusInfo);
8012 if (statusInfo.limitVolumeEnable && trafficResult.showConfirm) {
8013 var confirmMsg = null;
8014 if (trafficResult.usedPercent > 100) {
8015 confirmMsg = {
8016 msg: 'traffic_beyond_connect_msg'
8017 };
8018 barStat.setTrafficAlertPopuped(true);
8019 } else {
8020 confirmMsg = {
8021 msg: 'traffic_limit_connect_msg',
8022 params: [trafficResult.limitPercent]
8023 };
8024 barStat.setTrafficAlert100Popuped(false);
8025 }
8026 showConfirm(confirmMsg, function () {
8027 homeUtil.doConnect();
8028 });
8029 } else {
8030 homeUtil.doConnect();
8031 }
8032 };
8033 fnc.getSignalStrength({}, function (data) {
8034 var signalTxt = signalFormat(convertSignal(data));
8035 libjq("#fresh_signal_strength").text(signalTxt);
8036 if (popoverShown) {
8037 libjq("#popoverSignalTxt").text(signalTxt);
8038 }
8039 });
8040 homeUtil.refreshHomeData(target);
8041 addInterval(function () {
8042 fnc.getSignalStrength({}, function (data) {
8043 var signalTxt = signalFormat(convertSignal(data));
8044 libjq("#fresh_signal_strength").text(signalTxt);
8045 if (popoverShown) {
8046 libjq("#popoverSignalTxt").text(signalTxt);
8047 }
8048 });
8049 homeUtil.refreshHomeData(target);
8050 }, 1000);
8051 if (target.hasRj45) {
8052 homeUtil.refreshOpmodeInfo(target);
8053 addInterval(function () {
8054 homeUtil.refreshOpmodeInfo(target);
8055 }, 1000);
8056 }
8057 target.showNetworkSettingsWindow = function () {
8058 if (target.hasRj45) {
8059 fnc.getOpMode({}, function (data) {
8060 var mode = checkCableMode(data.blc_wan_mode);
8061 if (mode) {
8062 window.location.hash = '#network_set';
8063 } else {
8064 window.location.hash = '#conn_set';
8065 }
8066 });
8067 } else {
8068 window.location.hash = '#conn_set';
8069 }
8070 }
8071 };
8072 return {
8073 init: init
8074 };
8075});
8076
8077
8078define("language","knockout service jquery set underscore".split(" "),
8079 function(ko, service, $, config, _) {
8080
8081 // ��ȡ��ǰ������
8082 function getCurrentLanguage() {
8083 return service.getLanguage();
8084 }
8085
8086 // ��������������������Դ������ҳ���ϵ�body����
8087 // @param {String} current ������:zh-cn
8088 function loadLanguageAndRefresh(current){
8089 window.CURRENT_LANGUAGE = current;
8090 $("body").attr('lang', current);
8091 $.i18n.properties({
8092 name:'Messages',
8093 path:'i18n/',
8094 mode:'map',
8095 cache: true,
8096 language:current,
8097 callback: function() {
8098 jQuery.validator.messages = $.i18n.map;
8099 $('body').translate();
8100 }
8101 });
8102 }
8103
8104 window.language = null;
8105
8106
8107 function LanguageViewModel() {
8108 var target = this;
8109 var currentLan = getCurrentLanguage();
8110 var languages = _.map(config.LANGUAGES, function(item) {
8111 return new Option(item.name, item.value);
8112 });
8113
8114 document.title = config.WEBUI_TITLE;
8115 if($('#webui_title')[0]) {
8116 $('#webui_title').html(config.WEBUI_TITLE);
8117 }
8118
8119 target.languages = ko.observableArray(languages);
8120 target.currentLan = ko.observable(currentLan.Language);
8121 window.language = target.currentLan();
8122
8123 // �л������¼�����
8124 // @event langChangeHandler
8125 target.langChangeHandler = function(info, event) {
8126 clearValidateMsg();
8127
8128 service.setLanguage({Language: target.currentLan()}, function() {
8129 loadLanguageAndRefresh(target.currentLan());
8130 window.language = target.currentLan();
8131 });
8132 };
8133
8134 // ���������б���ˢ�½���
8135 loadLanguageAndRefresh(target.currentLan());
8136 }
8137
8138 // ��ʼ������VM������
8139 function init() {
8140 ko.applyBindings(new LanguageViewModel(), $('#language')[0]);
8141 }
8142
8143 return {
8144 init: init
8145 };
8146});
8147
8148
8149// ��½ ģ��
8150define("entry","jquery knockout set service underscore menu logout CryptoJS".split(" "),
8151 function($, ko,config, service, _, menu, logout, CryptoJS) {
8152
8153
8154 var pageState = {LOGIN:0, WAIT_PIN:1, WAIT_PUK:2, PUK_LOCKED:3, LOGGEDIN:4, LOADING:5};
8155 var timer = loginStatusCheckingTimer();
8156 var loginLockTimer = 0;
8157 var lastLoginStatus = "0";
8158
8159 function loginViewModel() {
8160 var target = this;
8161 var data = service.getLoginData();
8162 var loginStatus = service.getLoginStatus();
8163
8164 target.confirmPIN = ko.observable();
8165 target.leftSeconds = ko.observable(0);
8166 target.loginCount = ko.observable(0);
8167 target.loginSecuritySupport = ko.observable(config.LOGIN_SECURITY_SUPPORT);
8168 target.newPIN = ko.observable();
8169 target.password = ko.observable();
8170 target.PIN = ko.observable();
8171 target.pinNumber = ko.observable(data.pinnumber);
8172 target.PUK = ko.observable();
8173 target.pukNumber = ko.observable(data.puknumber);
8174 target.showEntrance = ko.observable(false);
8175 target.sharePathInvalid = ko.observable(false);
8176 target.uiLoginTimer = ko.observable(300);
8177
8178 // ע��˳�򣬵���ǰ�����޷�ˢ�³�����
8179 target.accountLocked = ko.computed(function () {
8180 return target.loginCount() == config.MAX_LOGIN_COUNT && target.leftSeconds() != '-1';
8181 });
8182
8183 target.leftUnlockTime = ko.computed(function () {
8184 target.leftSeconds();
8185 var formatted = transSecond2Time(target.uiLoginTimer());
8186 return formatted.substring(formatted.indexOf(':') + 1, formatted.length);
8187 });
8188
8189
8190 if(config.SD_CARD_SUPPORT){
8191 service.getSDConfiguration({}, function (data) {
8192 target.showEntrance(data.sd_status == "1" && data.share_status == "1" && data.sd_mode == "0");
8193 if(target.showEntrance()){
8194 service.checkFileExists({
8195 path: data.share_file
8196 }, function (data1) {
8197 if (data1.status == 'exist' || data1.status == 'processing') {
8198 target.sharePathInvalid(false);
8199 } else {
8200 target.sharePathInvalid(true);
8201 }
8202 });
8203 }
8204 });
8205 }
8206
8207 var state = computePageState(loginStatus, data);
8208 target.pageState = ko.observable(state);
8209 if (state == pageState.LOADING) {
8210 addTimeout(refreshPage, 500);
8211 }
8212 setFocus();
8213
8214
8215 // login �¼�����
8216
8217 target.login = function () {
8218 if(config.LOGIN_SECURITY_SUPPORT && target.accountLocked()){
8219 showAlert("password_error_account_lock_time", function () {
8220 setFocus();
8221 });
8222 return false;
8223 }
8224 target.pageState(pageState.LOADING);
8225 window.clearInterval(timer);
8226 var ciphertext = "";
8227 if (config.PASSWORD_ENCODE) {
8228 ciphertext = target.password();
8229 } else {
8230 var kparam = service.getDeviceInfoLow();
8231 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
8232 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
8233 ciphertext = CryptoJS.AES.encrypt(target.password(), tkey, {
8234 iv: tiv,
8235 mode: CryptoJS.mode.CBC,
8236 padding: CryptoJS.pad.ZeroPadding
8237 }).toString();
8238 }
8239 service.login({
8240 password:ciphertext
8241 }, function (info) {
8242 setTimeout(function () {
8243 timer = loginStatusCheckingTimer();
8244 }, 1300);
8245 if (info.result) {
8246 target.pageState(pageState.LOGGEDIN);
8247 if(config.LOGIN_SECURITY_SUPPORT){
8248 target.loginCount(0);
8249 target.uiLoginTimer(300);
8250 clearInterval(loginLockTimer);
8251 }
8252 $("#container").empty();
8253 window.location.hash = "#main";
8254 logout.init();
8255 } else {
8256 target.password("");
8257 if(config.LOGIN_SECURITY_SUPPORT){
8258 target.checkLoginData(function(){
8259 if (target.loginCount() == config.MAX_LOGIN_COUNT) {
8260 showAlert("password_error_five_times", function () {
8261 setFocus();
8262 });
8263 target.startLoginLockInterval();
8264 } else {
8265 showAlert({msg: 'password_error_left', params: [config.MAX_LOGIN_COUNT - target.loginCount()]}, function () {
8266 setFocus();
8267 });
8268 }
8269 });
8270 }else {
8271 showAlert("password_error", function () {
8272 setFocus();
8273 });
8274 }
8275 target.pageState(pageState.LOGIN);
8276 }
8277 });
8278 };
8279
8280
8281
8282
8283 // ��ȡ��¼������Ϣ
8284 target.checkLoginData = function(cb){
8285 service.getLoginData({}, function(r){
8286 var failTimes = parseInt(r.psw_fail_num_str, 10);
8287 target.loginCount(config.MAX_LOGIN_COUNT - failTimes);
8288 target.leftSeconds(r.login_lock_time);
8289 target.uiLoginTimer(r.login_lock_time);
8290 if($.isFunction(cb)){
8291 cb();
8292 } else if (target.loginCount() == config.MAX_LOGIN_COUNT) {
8293 target.startLoginLockInterval();
8294 }
8295 });
8296 };
8297
8298 // ��������ʱ��ʱ����
8299 target.startLoginLockInterval = function () {
8300 loginLockTimer = setInterval(function () {
8301 service.getLoginData({}, function (data) {
8302 if (data.login_lock_time <= 0 || data.psw_fail_num_str == 5) {
8303 target.loginCount(0);
8304 clearInterval(loginLockTimer);
8305 }
8306 if(target.leftSeconds() != data.login_lock_time){
8307 target.leftSeconds(data.login_lock_time);
8308 target.uiLoginTimer(data.login_lock_time);
8309 } else {
8310 target.uiLoginTimer(target.uiLoginTimer() > 0 ? target.uiLoginTimer() - 1 : 0);
8311 }
8312 });
8313 }, 1000);
8314 };
8315
8316 target.checkLoginData();
8317
8318
8319
8320 // ��֤����PIN�¼�����
8321 target.enterPIN = function () {
8322 target.pageState(pageState.LOADING);
8323 var pin = target.PIN();
8324 service.enterPIN({
8325 PinNumber:pin
8326 }, function (data) {
8327 if (!data.result) {
8328 showAlert("pin_error", function () {
8329 refreshPage();
8330 });
8331 target.PIN('');
8332 } else {
8333 refreshPage();
8334 }
8335 });
8336 };
8337
8338 function setFocus(){
8339 setTimeout(function () {
8340 var txtAdmin = $('#txtAdmin:visible');
8341 var txtPIN = $('#txtPIN:visible');
8342 var txtPUK = $('#txtPUK:visible');
8343 if (txtAdmin.length > 0) {
8344 txtAdmin.focus();
8345 } else if (txtPIN.length > 0) {
8346 txtPIN.focus();
8347 } else if (txtPUK.length > 0) {
8348 txtPUK.focus();
8349 }
8350 }, 100);
8351 }
8352
8353
8354 // ˢ��ҳ��״̬
8355 function refreshPage() {
8356 var data = service.getLoginData();
8357 var loginStatus = service.getLoginStatus();
8358 var state = computePageState(loginStatus, data);
8359 if (state == pageState.LOADING) {
8360 addTimeout(refreshPage, 500);
8361 } else {
8362 target.pageState(state);
8363 target.pinNumber(data.pinnumber);
8364 target.pukNumber(data.puknumber);
8365 }
8366 setFocus();
8367 }
8368
8369 // ����PUK������PIN�¼�����
8370 target.enterPUK = function () {
8371 target.pageState(pageState.LOADING);
8372 var newPIN = target.newPIN();
8373 var confirmPIN = target.confirmPIN();
8374 var params = {};
8375 params.PinNumber = newPIN;
8376 params.PUKNumber = target.PUK();
8377 service.enterPUK(params, function (data) {
8378 if (!data.result) {
8379 showAlert("puk_error", function () {
8380 refreshPage();
8381 });
8382 target.PUK('');
8383 target.newPIN('');
8384 target.confirmPIN('');
8385 } else {
8386 refreshPage();
8387 }
8388 });
8389 };
8390
8391
8392
8393 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8394 function checkPinAfterLogin(loginStatus, data) {
8395 if (loginStatus.status == "loggedIn") {
8396 var currentState = data.modem_main_state; // cov_2
8397 if (currentState == "modem_waitpin") {
8398 return pageState.WAIT_PIN;
8399 } else if ((currentState == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {
8400 return pageState.WAIT_PUK;
8401 } else if ((data.puknumber == 0 || currentState == "modem_sim_destroy")
8402 && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
8403 return pageState.PUK_LOCKED;
8404 } else {
8405 return pageState.LOGGEDIN;
8406 }
8407 } else {
8408 var currentState = data.modem_main_state;
8409 if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8410 return pageState.LOADING;
8411 } else {
8412 return pageState.LOGIN;
8413 }
8414 }
8415 }
8416
8417 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8418 function computePageState(loginStatus, data) {
8419 //PX-880 �ȵ�¼�ٽ���PIN��֤������router����ԭ�򣬵�¼����PIN��֤���ڵ�¼ҳ�����У������ݿ�����֤����һ�¡�
8420 if (config.LOGIN_THEN_CHECK_PIN) {
8421 return checkPinAfterLogin(loginStatus, data);
8422 } else {
8423 return loginAfterCheckPin(loginStatus, data);
8424 }
8425 }
8426
8427 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8428 function loginAfterCheckPin(loginStatus, data) {
8429 if (loginStatus.status == "loggedIn") {
8430 return pageState.LOGGEDIN;
8431 } else {
8432 var currentState = data.modem_main_state;
8433 if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8434 return pageState.LOADING;
8435 } else if (currentState == "modem_waitpin") {
8436 return pageState.WAIT_PIN;
8437 } else if ((currentState == "modem_waitpuk" || parseInt(data.pinnumber) === 0) && (parseInt(data.puknumber) != 0)) {
8438 return pageState.WAIT_PUK;
8439 } else if ((parseInt(data.puknumber) === 0 || currentState == "modem_sim_destroy") && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
8440 return pageState.PUK_LOCKED;
8441 } else {
8442 return pageState.LOGIN;
8443 }
8444 }
8445 }
8446 }
8447
8448
8449 // ���鵱ǰwindow.location.hash���쳣����ת��index.html
8450 function gotoLogin() {
8451 if (window.location.hash != config.defaultRoute && _.indexOf(config.GUEST_HASH, window.location.hash) == -1) {
8452 if (!manualLogout && lastLoginStatus == "1") {
8453 manualLogout = false;
8454 lastLoginStatus = 'UNREAL';
8455 showAlert('need_login_again', function () {
8456 window.location = "index.html";
8457 });
8458 } else if (lastLoginStatus == 'UNREAL') {
8459 //do nothing, only popup need_login_again alert one time
8460 return;
8461 } else {
8462 window.location = "index.html";
8463 }
8464 }
8465 }
8466
8467 // ��ʱ������¼״̬
8468 function loginStatusCheckingTimer() {
8469 return setInterval(function () {
8470 var info = service.getStatusInfo();
8471 if (!info.isLoggedIn) {
8472 gotoLogin();
8473 return;
8474 }
8475 lastLoginStatus = service.getStatusInfo().isLoggedIn ? "1" : "0";
8476 }, 1000);
8477 }
8478
8479 function init() {
8480 var info = service.getStatusInfo();
8481 if (info.isLoggedIn) {
8482 window.location.hash = '#main';
8483 return;
8484 }
8485
8486 var container = $('#container')[0];
8487 ko.cleanNode(container);
8488 var fwVm = new loginViewModel();
8489 ko.applyBindings(fwVm, container);
8490
8491 $('#frmLogin').validate({
8492 submitHandler:function () {
8493 fwVm.login();
8494 },
8495 rules: {
8496 txtAdmin: 'login_password_length_check'
8497 }
8498 });
8499 $('#frmPIN').validate({
8500 submitHandler:function () {
8501 fwVm.enterPIN();
8502 },
8503 rules:{
8504 txtPIN:"pin_check"
8505 }
8506 });
8507 $('#frmPUK').validate({
8508 submitHandler:function () {
8509 fwVm.enterPUK();
8510 },
8511 rules:{
8512 txtNewPIN:"pin_check",
8513 txtConfirmPIN:{equalToPin:"#txtNewPIN"},
8514 txtPUK:"puk_check"
8515 }
8516 });
8517 }
8518
8519
8520 return {
8521 init:init,
8522 gotoLogin:gotoLogin
8523 };
8524 });
8525
8526
8527// Logout �
8528define("logout","set service knockout underscore jquery".split(" "),
8529 function (config, service, ko, _, $) {
8530
8531 function logoutViewModel() {
8532 var target = this;
8533 // ��ȡ�Ƿ���¼
8534 var loginFlag = function () {
8535 var loginInfo = service.getLoginStatus();
8536 return (loginInfo.status == "loggedIn");
8537 }
8538 ();
8539 target.loggedIn = ko.observable(loginFlag);
8540
8541 // �˳�ϵͳ
8542 target.logout = function () {
8543 showConfirm("confirm_logout", function () {
8544 manualLogout = true;
8545 service.logout({}, setLocation());
8546 });
8547 };
8548
8549 // �Ƿ���ʾ�˳���ť
8550 target.showLogout = function () {
8551 if (config.HAS_LOGIN) {
8552 return target.loggedIn();
8553 } else {
8554 return false;
8555 }
8556 };
8557 }
8558 function setLocation() {
8559 window.location = 'index.html';
8560 }
8561 function initialize() {
8562 var fwVm = new logoutViewModel();
8563 bindContainer(fwVm);
8564 }
8565 function bindContainer(fwVm) {
8566 var con = $('#logout')[0];
8567 ko.cleanNode(con);
8568 ko.applyBindings(fwVm, con);
8569 }
8570 return {
8571 init: initialize
8572 };
8573});
8574
8575// operation mode �
8576define("opmode","knockout service jquery set underscore".split(" "),
8577
8578 function (ko, service, $, config, _) {
8579
8580 function currentOperationModeViewMode(){
8581 var target = this;
8582 target.isLoggedIn = ko.observable(false);
8583 target.enableFlag = ko.observable(false);
8584
8585 target.showOpModeWindow = function () {
8586 showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {
8587 });
8588 };
8589 target.currentOpMode = ko.observable("0");
8590
8591 service.getOpMode({}, function(info){
8592 target.isLoggedIn(info.loginfo == "ok");
8593 if (info.opms_wan_mode != "PPP" && info.rj45_state != "idle" && info.rj45_state != "dead") {
8594 target.enableFlag(false);
8595 } else if (info.opms_wan_mode == "PPP" && info.ppp_status != "ppp_disconnected") {
8596 target.enableFlag(false);
8597 } else if(info.opms_wan_mode == "DHCP"){
8598 target.enableFlag(true);
8599 } else {
8600 target.enableFlag(true);
8601 }
8602
8603 var opmsWanMode = (info.opms_wan_mode == "DHCP" || info.opms_wan_mode == "STATIC") ? "PPPOE" : info.opms_wan_mode;
8604
8605 var currentOperationMode = "";
8606 switch(opmsWanMode){
8607 case "BRIDGE":
8608 currentOperationMode = "opmode_bridge";
8609 break;
8610 case "PPP":
8611 currentOperationMode = "opmode_gateway";
8612 break;
8613 case "PPPOE":
8614 currentOperationMode = "opmode_cable";
8615 break;
8616 default:
8617 break;
8618 }
8619 $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
8620 });
8621 // ��ʱ��ѯ����ģʽ����״̬�����ý���״̬
8622 setInterval(function(){
8623 var object = service.getConnectionInfo();
8624 if(object.opms_wan_mode == "DHCP") {
8625 target.enableFlag(true);
8626 } 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")) {
8627 target.enableFlag(false);
8628 } else {
8629 target.enableFlag(true);
8630 }
8631 }, 1000);
8632 }
8633
8634 function init() {
8635 var container = $('#currentOpMode')[0];
8636 ko.cleanNode(container);
8637 var fwVm = new currentOperationModeViewMode();
8638 ko.applyBindings(fwVm, container);
8639 }
8640
8641 return {
8642 init:init
8643 };
8644});
8645
8646// operation mode popup�
8647
8648define("opmode_popup","knockout service jquery set underscore".split(" "),
8649
8650 function (ko, service, $, config, _) {
8651
8652 function operationModeViewMode() {
8653 var target = this;
8654 var currentSelectedOperationMode = "";
8655 target.selectedMode = ko.observable("0");
8656
8657 // ��ʼ������ģʽ��ʾ
8658 service.getOpMode({}, function(info){
8659 if(info.blc_wan_mode == "AUTO_PPP"){
8660 currentSelectedOperationMode = "AUTO";
8661 }else if(info.blc_wan_mode == "AUTO_PPPOE"){
8662 currentSelectedOperationMode = "AUTO";
8663 }else if(info.blc_wan_mode == "PPPOE"){
8664 currentSelectedOperationMode = "PPPOE";
8665 }else{
8666 currentSelectedOperationMode = info.blc_wan_mode;
8667 }
8668 target.selectedMode(currentSelectedOperationMode);
8669 });
8670
8671 // ģʽ����/�л�
8672 target.changeOpMode = function(){
8673 var userSelectedOperationMode = $('input:radio[name="opMode"]:checked').val();
8674 var messageText = "";
8675 if(userSelectedOperationMode == currentSelectedOperationMode) {
8676 hidePopupSettingWindow();
8677 return;
8678 }
8679 if(userSelectedOperationMode == "LTE_BRIDGE"){
8680 messageText = "opmode_msg3";
8681 }else{
8682 messageText = "opmode_msg2";
8683 }
8684 showConfirm(messageText, function(){
8685 showLoading();
8686 service.SetOperationMode({
8687 opMode: userSelectedOperationMode
8688 },function(info){
8689 if (info && info.result == "success") {
8690 var currentOperationMode = "";
8691 switch(userSelectedOperationMode){
8692 case "AUTO":
8693 currentOperationMode = "opmode_auto"
8694 break;
8695 case "PPP":
8696 currentOperationMode = "opmode_gateway";
8697 break;
8698 case "PPPOE":
8699 currentOperationMode = "opmode_cable";
8700 break;
8701 default:
8702 break;
8703 }
8704 $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
8705 successOverlay();
8706 } else {
8707 errorOverlay();
8708 }
8709 });
8710 });
8711
8712 }
8713
8714 }
8715
8716 function init() {
8717 var fwVm = new operationModeViewMode();
8718 ko.applyBindings(fwVm, $('#popupSettingWindow')[0]);
8719
8720 $("#opmode_form").validate({
8721 submitHandler: function(){
8722 fwVm.changeOpMode();
8723 }
8724 });
8725 }
8726
8727 return {
8728 init:init
8729 };
8730});
8731
8732define("router","underscore jquery menu set service".split(" "),
8733 function (_, $, menu, config, service) {
8734 var currentHash = '';
8735 var container = $('#container');
8736
8737 //�뿪����ʱ�����Ƿ��������޸ģ�����������ʾ
8738 checkFormContentModify = function (href) {
8739 if (config.CONTENT_MODIFIED.modified && window.location.hash != href) {
8740 if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {
8741 config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
8742 config.resetContentModifyValue();
8743 window.location.hash = href;
8744 } else {
8745 showConfirm(config.CONTENT_MODIFIED.message, {
8746 ok: function () {
8747 config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
8748 config.resetContentModifyValue();
8749 window.location.hash = href;
8750 },
8751 no: function () {
8752 var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);
8753 if (!result) {
8754 window.location.hash = href;
8755 config.resetContentModifyValue();
8756 }
8757 }
8758 });
8759 }
8760 return false;
8761 } else {
8762 return true;
8763 }
8764 };
8765
8766 //��ʱ�鿴SIM����״̬������ǰSIM��״̬��Ϊ����״̬��δ��ʾnosimcardҳ�棬����ʾnosimcardҳ��,�Ա��ⲻ�ر�webui�����²����豸�󣬲����ж�SIM��״̬������
8767 function checkSimCardStatus() {
8768 setInterval(function () {
8769 var data = service.getStatusInfo();
8770 var match = menu.findMenu();
8771 if (match.length == 0) {
8772 return false;
8773 }
8774 var requirePinHash = ["phonebook", "sms_list"];
8775 var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
8776 if (match[0].checkSIMStatus === true) {
8777 var simstatus = data.simStatus == "modem_sim_undetected"
8778 || data.simStatus == "modem_sim_destroy" || data.simStatus == "modem_waitpin"
8779 || data.simStatus == "modem_waitpuk";
8780 var netlockstatus = data.simStatus == "modem_imsi_waitnck";
8781 if (data.isLoggedIn && (
8782 ($('#div-nosimcard')[0] == undefined && simstatus)
8783 || ($('#div-network-lock')[0] == undefined && netlockstatus)
8784 || (($('#div-nosimcard')[0] != undefined || $('#div-network-lock')[0] != undefined) && data.simStatus == "modem_init_complete"))) {
8785 fixedLoadResources(match[0], data.simStatus, isRequirePin);
8786 }
8787 }
8788 }, 1000);
8789 }
8790
8791 //������¼ҳ�汳��
8792 function checkLoginPageBg() {
8793 var h = window.location.hash;
8794 if (h == '#entry' || _.indexOf(config.GUEST_HASH, h) != -1) {
8795 $("#manageContainer").attr("style", "margin-top:-36px;");
8796 } else {
8797 $("#manageContainer").attr("style", "margin-top:0px;");
8798 }
8799
8800 if (window.location.hash == '#entry') {
8801 $("#mainContainer").addClass('loginBackgroundBlue');
8802 } else {
8803 var mainContainer = $("#mainContainer");
8804 if (mainContainer.hasClass('loginBackgroundBlue')) {
8805 $("#container").css({
8806 margin: 0
8807 });
8808 mainContainer.removeClass('loginBackgroundBlue').height('auto');
8809 }
8810 }
8811 }
8812
8813 function fixedLoadResources(menuItem, simStatus, isRequirePin) {
8814 var item = {};
8815 $.extend(item, menuItem);
8816 //û��SIM��ʱ������homeҳ�治��������
8817 //���类��ʱ��homeҳ����ʾ����ҳ��
8818 if (simStatus == "modem_sim_undetected" || simStatus == "modem_sim_destroy") {
8819 if (!isRequirePin) {
8820 item.path = "sim_abnormal";
8821 }
8822 } else if (simStatus == "modem_waitpin" || simStatus == "modem_waitpuk") {
8823 item.path = "sim_abnormal";
8824 } else if (simStatus == "modem_imsi_waitnck") {
8825 item.path = "locknet";
8826 }
8827 //load tmpl and controller js
8828 loadResources(item);
8829 }
8830
8831 //���ݲ˵�����item���ض�Ӧ����Դ
8832 function loadResources(item) {
8833 var pId = item.path.replace(/\//g, '_');
8834 var $body = $('body').removeClass();
8835 if (pId != 'entry' && pId != 'main') {
8836 $body.addClass('beautiful_bg page_' + pId);
8837 } else {
8838 $body.addClass('page_' + pId);
8839 }
8840 clearTimer();
8841 hideLoading();
8842 var tmplPath = 'text!tmpl/' + item.path + '.html';
8843 //TODO: prevent first menu click cover the second menu content, need test with device
8844 require([tmplPath, item.path], function (tmpl, viewModel) {
8845 container.stop(true, true);
8846 container.hide();
8847 container.html(tmpl);
8848 viewModel.init();
8849 //support backward/forward
8850 menu.refreshMenu();
8851 $('#container').translate();
8852 menu.activeSubMenu();
8853
8854 $("form").attr("autocomplete", "off");
8855 container.fadeIn();
8856 });
8857 }
8858 //�ȶ�hash״̬, �����仯�������µ�hashƥ���˵�����,ƥ�䲻��ʱ��ת��homeҳ��, ƥ����ʱ��¼hashֵ����̬���ض�Ӧ����Դ�ļ�
8859 function hashCheck() {
8860 if (window.location.hash != currentHash) {
8861 //������½����������, ��½�û����ʷǵ�¼�û�ʱҳ�治��ת
8862 var info = service.getStatusInfo();
8863 if (window.location.hash == config.defaultRoute || _.indexOf(config.GUEST_HASH, window.location.hash) != -1) {
8864 if (info.isLoggedIn) {
8865 window.location.hash = currentHash == "" ? "#main" : currentHash;
8866 return;
8867 }
8868 }
8869
8870 var match = menu.findMenu();
8871
8872 if (match.length == 0) {
8873 window.location.hash = config.defaultRoute;
8874 } else {
8875 //��¼ʱ���鹤��ģʽ������ģʽ������������Ҫ����SIM��״̬�����¼���,����ģʽ�������治��Ҫ����SIM��״̬�����¼���
8876 if (config.RJ45_SUPPORT && window.location.hash == "#main") {
8877 if ((match[0].checkSIMStatus && checkCableMode(info.blc_wan_mode)) || (!match[0].checkSIMStatus && !checkCableMode(info.blc_wan_mode))) {
8878 window.location.reload();
8879 return;
8880 }
8881 }
8882 //TODO: �����˵�����Ӧ�����˵���һ����л�ʱ�����¼�������, ��TODO: click the same menu ʵ�ַ�ʽ����
8883 var oldMenu = menu.findMenu(currentHash);
8884 currentHash = match[0].hash;
8885 if (currentHash == "#entry") {
8886 $('#indexContainer').addClass('login-page-bg');
8887 menu.rebuild();
8888 } else {
8889 $('#indexContainer').removeClass('login-page-bg');
8890 }
8891
8892 if (oldMenu.length != 0 && match[0].path == oldMenu[0].path && match[0].level != oldMenu[0].level && match[0].level != '1' && oldMenu[0].level != '1') {
8893 return;
8894 }
8895
8896 checkLoginPageBg();
8897 var requirePinHash = ["phonebook", "sms_list"];
8898 var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
8899 if (match[0].checkSIMStatus === true || isRequirePin) {
8900 //simStatus is undefined when refreshing page
8901 if (info.simStatus == undefined) {
8902 showLoading('waiting');
8903 function checkSIM() {
8904 var data = service.getStatusInfo();
8905 if (data.simStatus == undefined || $.inArray(data.simStatus, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8906 addTimeout(checkSIM, 500);
8907 } else {
8908 fixedLoadResources(match[0], data.simStatus, isRequirePin);
8909 hideLoading();
8910 }
8911 }
8912 checkSIM();
8913 } else {
8914 fixedLoadResources(match[0], info.simStatus, isRequirePin);
8915 }
8916 } else {
8917 loadResources(match[0]);
8918 }
8919 }
8920 }
8921 }
8922
8923 //Ĭ������ҳ��Ϊ#main, ��ʱ����hash״̬
8924 function init() {
8925 checkSimCardStatus();
8926 window.location.hash = window.location.hash || "#main";
8927 //if support onhashchange then use. If ie8 in ie7 mode, it doesn't trigger onhashchange.
8928 if (('onhashchange' in window) && ((typeof document.documentMode === 'undefined') || document.documentMode == 8)) {
8929 window.onhashchange = hashCheck;
8930 hashCheck();
8931 } else {
8932 setInterval(hashCheck, 200);
8933 }
8934
8935 //�����޸���ҳ������, �뿪ʱ������ʾ
8936 $("a[href^='#']").die('click').live('click', function () {
8937 var $this = $(this);
8938 config.CONTENT_MODIFIED.checkChangMethod();
8939 return checkFormContentModify($this.attr('href'));
8940 });
8941 }
8942
8943 return {
8944 init: init
8945 };
8946});
8947
8948// statusBar �
8949
8950define("statusBar", "knockout jquery underscore service set menu tooltip".split(" "),
8951
8952 function (ko, $, _, service, config, menu, tooltip) {
8953
8954 var sv__hasCheckedSMSCapacity = false;
8955 var sv__initSMSCompleted = false;
8956 var sv_newSMSMessageInDealing = false;
8957 var sv_fotaUpdateCancel = null;
8958 var sv_batteryCheckTimer = 0;
8959 var sv_dbMessageIds = [];
8960 var sv_fotaResultAlertPopuped = false;
8961 var sv_isFirstLoadNewMessage = true;
8962 var isLoggedIn = true;
8963 var sv_messagePopStack = {};
8964 var sv_newMessagePopTemplate = null;
8965 var sv_resetTrafficAlertPopuped = false;
8966 var sv_simMessageListTemplate = null;
8967 var sv_smsListTemplate = null;
8968 var sv_trafficAlertPopuped_100 = false;
8969 var sv_trafficAlertPopuped = false;
8970 var sv_timer = 0;
8971
8972 // ��ȡ״̬��Ϣ�������硢SIM��WIFI��
8973 var getCurrentStatusInfo = function () {
8974 return service.getStatusInfo();
8975 };
8976
8977 function statusViewModel() {
8978 var target = this;
8979 var info = getCurrentStatusInfo();
8980 var roamStatus = info.roamingStatus ? true : false;
8981 var $langLogoBar = $("#langLogoBar");
8982
8983
8984 // �������������¼�����
8985 function sf_connect() {
8986 showLoading("connecting");
8987 service.connect({}, function (data) {
8988 if (data.result) {
8989 refreshWifiConnectStatus(target, data.status);
8990 }
8991 successOverlay();
8992 }, function (data) {
8993 errorOverlay();
8994 });
8995 }
8996 // �Ͽ������¼�����
8997 function sf_disconnect() {
8998 showLoading("disconnecting");
8999 service.disconnect({}, function (data) {
9000 if (data.result) {
9001 refreshWifiConnectStatus(target, data.status);
9002 }
9003 successOverlay();
9004 }, function (data) {
9005 errorOverlay();
9006 });
9007 }
9008
9009 if(info.isLoggedIn){
9010 if(!$langLogoBar.hasClass("langborderBg")){
9011 $langLogoBar.addClass("langborderBg");
9012 }
9013 $("#statusBar:hidden").show();
9014 } else {
9015 if($langLogoBar.hasClass("langborderBg")){
9016 $langLogoBar.removeClass("langborderBg");
9017 }
9018 $("#statusBar:visible").hide();
9019 }
9020
9021
9022 //target.attachedDevices = ko.observable(info.attachedDevices);
9023 target.batteryLevel = ko.observable(info.batteryLevel + '%');
9024 target.batteryPers = ko.observable(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
9025 target.batteryStatus = ko.observable(info.batteryStatus);
9026 target.connectionCssClass = ko.observable("");
9027 target.connectStatus = ko.observable(info.connectStatus);
9028 target.connectStatusText = ko.observable();
9029 target.connectStatusTrans = ko.observable();
9030 target.hasWifi = ko.observable(config.HAS_WIFI);
9031 target.hasBattery = ko.observable(config.HAS_BATTERY);
9032 target.isLoggedIn = ko.observable(info.isLoggedIn);
9033 target.isShowConnectionIcon = ko.observable(false);
9034 target.isShowFotaNewversionIcon = ko.observable(info.new_version_state && info.fota_package_already_download != "yes" && !config.isShowFotaIcon);
9035 target.isShowRj45ConnectionIcon = ko.observable(false);
9036 target.networkOperator = ko.observable(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,roamStatus));
9037 target.networkType = ko.observable(getNetworkType(info.networkType));
9038 target.pinStatus = ko.observable(info.pinStatus);
9039 target.pinStatusText = ko.observable();
9040 target.rj45ConnectionCssClass = ko.observable("");
9041 target.roamingStatus = ko.observable(info.roamingStatus ? "R" : "");
9042 target.showAttachedDevices = ko.observable(info.wifiStatus);
9043 target.showSmsDeleteConfirm = ko.observable(false);
9044 target.smsUnreadCount = ko.observable(0);
9045 target.simStatus = ko.observable(sf_convertSimStatusToImage(info.simStatus));
9046 target.signalCssClass = ko.observable(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
9047 target.updateType = ko.observable(service.getUpdateType().update_type);
9048 target.wifiStatusCssClass = ko.observable(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
9049 target.wifiStatusImg = ko.observable(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
9050
9051 sf_getConnectionCssClass(target, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
9052
9053 target.connect = sf_connect;
9054 target.disconnect = sf_disconnect;
9055 }
9056
9057 function sf_gotoSmsList(){
9058 var s_href = '#msg_main';
9059 if(window.location.hash == '#msg_main'){
9060 s_href = '#msg_list';
9061 }
9062 config.CONTENT_MODIFIED.checkChangMethod();
9063 if(checkFormContentModify(s_href)){
9064 window.location.hash = s_href;
9065 }
9066 }
9067
9068 gotoSmsList = sf_gotoSmsList;
9069
9070 function sf_getNetWorkProvider(i_spnB1Flag, i_spnNameData, i_spnB2Flag, i_networkProvider, i_roamStatus) {
9071 if (i_spnNameData == "") {
9072 return i_networkProvider;
9073 } else {
9074 i_spnNameData = decodeMessage(i_spnNameData);
9075 if (i_spnB1Flag == "0" && i_spnB2Flag == "0") {
9076 if (i_roamStatus) {//����
9077 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9078 } else {//������
9079 return i_spnNameData;
9080 }
9081 }else if (i_spnB1Flag == "1" && i_spnB2Flag == "1") {
9082 if (i_roamStatus) {//����
9083 return i_networkProvider;
9084 } else {//������
9085 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9086 }
9087 } else if (i_spnB1Flag == "1") {
9088 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9089 } else if (i_spnB2Flag == "1") {
9090 if (i_roamStatus) {//����
9091 return i_networkProvider;
9092 } else {//������
9093 return i_spnNameData;
9094 }
9095 }
9096 return "";
9097 }
9098 }
9099
9100 // �����¶���Ϣ��ʾ����������������
9101 function sf_addNewMessage(i_message, i_isUpdate, i_type){
9102 config.smsMaxId = i_message.id;
9103 var now = $.now();
9104 sv_messagePopStack["m" + now] = now;
9105 var name = i_message.number;
9106 if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
9107 sv_isFirstLoadNewMessage = false;
9108 if(config.HAS_PHONEBOOK){
9109 sf_getPhoneBooks();
9110 }else{
9111 config.phonebook = [];
9112 }
9113 }
9114 for(i in config.phonebook){
9115 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9116 name = config.phonebook[i].pbm_name;
9117 break;
9118 }
9119 }
9120 var s_newMsg = {
9121 mark : "m" + now,
9122 name: name,
9123 title: $.i18n.prop("sms"),
9124 titleTrans: "sms",
9125 tag: i_message.tag,
9126 content : i_message.content,
9127 datetime : i_message.time
9128 };
9129 if(sv_newMessagePopTemplate == null){
9130 sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
9131 }
9132 $(".bubbleItem:not(.report)", "#buttom-bubble").remove();
9133 $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
9134 if((window.location.hash == "#msg_main" || window.location.hash == "#msg_list") && i_type == "1"){
9135 //sf_dealChosenNumber(s_newMsg.name, i_message.number);
9136 var s_inChating = config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
9137 var s_itemId = getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
9138 var item = $("#smslist-item-" + s_itemId);
9139 if(item && item.length > 0){
9140 // �Ѵ������ݣ��������ݵ���˳��
9141 for(var i = 0; config.listMsgs && i < config.listMsgs.length; i++){
9142 if(getLastNumber(config.listMsgs[i].number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9143 config.listMsgs[i].id = i_message.id;
9144 config.listMsgs[i].latestId = i_message.id;
9145 config.listMsgs[i].latestSms = i_message.content;
9146 config.listMsgs[i].latestTime = i_message.time;
9147 if(!i_isUpdate){
9148 config.listMsgs[i].newCount++;
9149 config.listMsgs[i].totalCount++;
9150 }
9151 break;
9152 }
9153 }
9154 item.find(".smslist-item-checkbox p.checkbox").attr("id", i_message.id);
9155 item.find(".smslist-item-checkbox input:checkbox").val(i_message.id).attr("id", "checkbox" + i_message.id);
9156 if(!i_isUpdate){
9157 var s_itemCount = item.find(".smslist-item-total-count").text();
9158 s_itemCount = Number(s_itemCount.substring(1, s_itemCount.length - 1));
9159 item.find(".smslist-item-total-count").text("(" + (s_itemCount + 1) + ")");
9160 if(!config.currentChatObject || config.currentChatObject != getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9161 var s_newNum = item.find(".smslist-item-new-count").removeClass("hide");
9162 if(s_newNum && s_newNum.text().length > 0){
9163 s_newNum.text(Number(s_newNum.text()) + 1);
9164 }else{
9165 s_newNum.text(1);
9166 }
9167 }
9168 }
9169 if(item.find(".smslist-item-draft-flag").length > 0){
9170 if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
9171 item.find(" td:nth-child(2)").removeClass("font-weight-bold");
9172 } else {
9173 item.find(" td:nth-child(2)").addClass("font-weight-bold");
9174 }
9175 }else{
9176 var msgContent = item.find(".smslist-item-msg").text(i_message.content);
9177 msgContent.closest('td').prop('title', i_message.content);
9178 item.find("span.clock-time").text(i_message.time);
9179 if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
9180 msgContent.closest('tr').removeClass("font-weight-bold");
9181 } else {
9182 msgContent.closest('tr').addClass("font-weight-bold");
9183 }
9184 }
9185 item.find(".smslist-item-repeat span").die().click(function() {
9186 forwardClickHandler(i_message.id);
9187 });
9188
9189 var s_tmpItem = item;
9190 item.hide().remove();
9191 $("#smslist-table").prepend(s_tmpItem.show());
9192 } else {
9193 // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
9194 var s_theName = "";
9195 if(config.phonebook && config.phonebook.length > 0) {
9196 for(i in config.phonebook){
9197 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9198 s_theName = config.phonebook[i].pbm_name;
9199 break;
9200 }
9201 }
9202 }
9203 var s_theNewMessage = {
9204 id : i_message.id,
9205 name : s_theName,
9206 number : i_message.number,
9207 latestId :i_message.id,
9208 totalCount : 1,
9209 newCount : s_inChating ? 0 : 1,
9210 latestSms : i_message.content,
9211 latestTime : i_message.time,
9212 checked : false,
9213 hasDraft : false,
9214 itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
9215 };
9216 if(sv_smsListTemplate == null){
9217 sv_smsListTemplate = $.template("smsTableTmpl", $("#smsTableTmpl"));
9218 }
9219 $.tmpl("smsTableTmpl", {data: [s_theNewMessage]}).prependTo("#smslist-table");
9220 }
9221 if(config.HAS_PHONEBOOK){
9222 $(".sms-add-contact-icon").removeClass("hide");
9223 }else{
9224 $(".sms-add-contact-icon").addClass("hide");
9225 }
9226 if(s_inChating){
9227 var talkItem = $("#talk-item-" + i_message.id, "#chatlist");
9228 if (talkItem && talkItem.length > 0) {// ���¼�����������
9229 $(".J_content pre", talkItem).html(dealContent(i_message.content));
9230 $(".time .smslist-item-time", talkItem).text(i_message.time);
9231 $(".smslist-item-repeat", talkItem).die().click(
9232 function() {
9233 forwardClickHandler(i_message.id);
9234 });
9235 $(".smslist-item-delete", talkItem).die().click(
9236 function() {
9237 deleteSingleItemClickHandler(i_message.id);
9238 });
9239 } else {// �����µĻظ�����
9240 $("#smsOtherTmpl").tmpl(i_message).appendTo("#chatlist");
9241 $(".clear-container", "#chatpanel").animate({
9242 scrollTop : $("#chatlist").height()
9243 });
9244 }
9245 if (!config.SMS_SET_READ_WHEN_COMPLETE) {
9246 service.setSmsRead({ids: [i_message.id]}, $.noop);
9247 } else if (config.SMS_SET_READ_WHEN_COMPLETE && i_message.receivedAll) {
9248 service.setSmsRead({ids: [i_message.id]}, $.noop);
9249 }
9250 }
9251 enableCheckbox($("#smslist-checkAll"));
9252 }
9253 if(window.location.hash == "#msg_sim" && i_type == "0"){
9254 // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
9255 var s_theName = "";
9256 if(config.phonebook && config.phonebook.length > 0) {
9257 for(i in config.phonebook){
9258 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9259 s_theName = config.phonebook[i].pbm_name;
9260 break;
9261 }
9262 }
9263 }
9264 var s_theNewMessage = {
9265 id : i_message.id,
9266 name : s_theName,
9267 number : i_message.number,
9268 content : i_message.content,
9269 time : i_message.time,
9270 tag: i_message.tag,
9271 checked : false,
9272 itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
9273 };
9274 if(i_isUpdate){
9275 var s_item = $(".simMsgList-item-class-" + s_theNewMessage.id);
9276 s_item.hide().remove();
9277 }
9278 if(sv_simMessageListTemplate == null){
9279 sv_simMessageListTemplate = $.template("ssimMessageListTemplate", $("#simMessageListTemplate"));
9280 }
9281 $.tmpl("simMessageListTemplate", {data: [s_theNewMessage]}).prependTo("#simMsgList_container");
9282 }
9283 }
9284
9285 function sf_checkBatteryStatusForFota(){
9286 var s_state = service.getCurrentUpgradeState();
9287 if(s_state.current_upgrade_state == 'low_battery'){
9288 showInfo('ota_low_battery');
9289 clearInterval(sv_batteryCheckTimer);
9290 }
9291 }
9292
9293 // ��SIM��״̬ת��Ϊ��Ӧ����������
9294 function sf_convertSimStatusToImage(i_status) {
9295 var s_image;
9296 switch (i_status) {
9297 case "modem_destroy":
9298 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
9299 break;
9300 case "modem_imsi_waitnck":
9301 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitnck");
9302 break;
9303 case "modem_init_complete":
9304 s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
9305 break;
9306 case "modem_sim_destroy":
9307 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
9308 break;
9309 case "modem_sim_undetected":
9310 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_undetected");
9311 break;
9312 case "modem_undetected":
9313 s_image = "./pic/simcard_undetected.png";
9314 break;
9315 case "modem_waitpin":
9316 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpin");
9317 break;
9318 case "modem_waitpuk":
9319 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpuk");
9320 break;
9321
9322 default:
9323 s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
9324 break;
9325 }
9326 return s_image;
9327 }
9328
9329 function sf_dealChosenNumber(i_choosenName, i_choosenNum) {
9330 setTimeout(function () {
9331 var s_choosen = $("#chosenUserSelect");
9332 var s_options = $("option", s_choosen);
9333 for (var index = 0; index < s_options.length; index++) {
9334 if (getLastNumber(i_choosenNum, config.SMS_MATCH_LENGTH) == s_options[index].value) {
9335
9336 s_options[index].text = i_choosenName + '/' + i_choosenNum;
9337 s_options[index].value = i_choosenNum;
9338
9339 break;
9340 }
9341 }
9342 s_choosen.trigger("liszt:updated");
9343 }, 0);
9344 }
9345
9346 // ˫�첽��ȡ�豸����sim�����ö���Ϣ���������ϲ�
9347 function sf_dealPhoneBooksResult(i_books){
9348 if($.isArray(i_books.pbm_data) && i_books.pbm_data.length > 0){
9349 config.phonebook = i_books.pbm_data;
9350 }
9351 }
9352
9353 // �������µ�5������Ϣ����δ���ӵ������б��еĵ�����ʾ
9354 function sf_filterNewMessage(i_messages, i_type){
9355 if(!config.dbMsgs){
9356 config.dbMsgs = [];
9357 }
9358 if(sv_dbMessageIds.length == 0){
9359 $.each(config.dbMsgs, function(index_1, i_element){
9360 sv_dbMessageIds.push(i_element.id);
9361 });
9362 }
9363 $.each(i_messages, function(index_2, i_element){
9364 if($.inArray(i_element.id, sv_dbMessageIds) == -1){//�����¶���
9365 sv_dbMessageIds.push(i_element.id);
9366 config.dbMsgs.push(i_element);
9367 if(i_element.tag == '1'){
9368 sf_addNewMessage(i_element, false, i_type);
9369 }
9370 }else{
9371 for(var index = 0; index < config.dbMsgs.length; index++){//���¼�������
9372 if(config.dbMsgs[index].id == i_element.id && config.dbMsgs[index].content != i_element.content && i_element.tag == '1'){
9373 config.dbMsgs[index].content = i_element.content;
9374 sf_addNewMessage(i_element, true, i_type);
9375 break;
9376 }
9377 }
9378 }
9379 });
9380 }
9381
9382 // ������ת��Ϊ��ӦͼƬ
9383 function sf_getBatteryLevelImage(pers, i_status) {
9384 var s_Image = null;
9385 if ("0" == i_status) {
9386 if ("1" == pers) {
9387 s_Image = "pic/power_one.png";
9388 } else if ("2" == pers) {
9389 s_Image = "pic/power_two.png";
9390 } else if ("3" == pers) {
9391 s_Image = "pic/power_three.png";
9392 } else if ("4" == pers) {
9393 s_Image = "pic/power_full.png";
9394 } else { //"5" == pers || "0" == pers
9395 s_Image = "pic/power_out.png";
9396 }
9397 } else {
9398 s_Image = "pic/power_charging.gif";
9399 }
9400 return s_Image;
9401 }
9402
9403 // ��ȡ����״̬��CSS��ʽ
9404 function sf_getConnectionCssClass(i_fwVm, i_status, i_data_counter, i_wifiSSID, i_wifiStatus, i_rj45Status) {
9405
9406 var s_rj45ConnectionStatus = "icon_connection ";
9407 var s_connectionStatus = "icon_connection ";
9408
9409 if(i_rj45Status == "connect"){
9410 s_rj45ConnectionStatus += "connecting";
9411 }else if(i_rj45Status == "working"){
9412 s_rj45ConnectionStatus += "rj45_connected";
9413 }else{
9414 s_rj45ConnectionStatus += "disconnect";
9415 }
9416
9417 if (i_status == "ppp_connecting" || i_status == "wifi_connecting") {
9418 s_connectionStatus += "connecting";
9419 } else if(i_status == "ppp_connected") {//CPE ppp_statusΪnone ready��ֵ
9420 if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate != '0') {
9421 s_connectionStatus += "connectionBoth";
9422 } else if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate == '0') {
9423 s_connectionStatus += "connectionUp";
9424 } else if (i_data_counter.uploadRate == '0' && i_data_counter.downloadRate != '0') {
9425 s_connectionStatus += "connectionDown";
9426 } else {
9427 s_connectionStatus += "connectionNone";
9428 }
9429 } else if (i_status == "ppp_disconnected") {
9430 if (i_wifiSSID && i_wifiStatus == "connect") {
9431 service.getHotspotList({}, function (data) {
9432 var s_cssName = "icon_connection ";
9433 var s_css = "connecting ";
9434 for (var i = 0, len = data.hotspotList.length; i < len; i++) {
9435 if (data.hotspotList[i].connectStatus == "1") {
9436 s_css = "wifi_connected";
9437 break;
9438 }
9439 }
9440 s_cssName += s_css;
9441 i_fwVm.connectionCssClass(s_cssName);
9442 });
9443 i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
9444 return;
9445 } else if (i_wifiSSID && (i_wifiStatus == "connecting" || i_wifiStatus =="dhcping")) {
9446 s_connectionStatus += "connecting";
9447 } else {
9448 s_connectionStatus += "disconnect";
9449 }
9450 } else {
9451 s_connectionStatus += "disconnect";
9452 }
9453
9454 i_fwVm.connectionCssClass(s_connectionStatus);
9455 i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
9456 }
9457
9458 // ��ȡ�绰����Ϣ
9459 function sf_getPhoneBooks() {
9460 var s_books = service.getPhoneBooks({
9461 page : 0,
9462 data_per_page : 2000,
9463 orderBy : "id",
9464 isAsc : false
9465 });
9466 sf_dealPhoneBooksResult(s_books);
9467 }
9468
9469 // ��ȡ�ź�����CSS��ʽ
9470 function sf_getSignalCssClass(siganl, networkType, simStatus) {
9471 networkType = networkType.toLowerCase();
9472 simStatus = simStatus ? simStatus.toLowerCase() : '';
9473 if(networkType == '' || networkType == 'limited_service' || networkType == 'no_service' || networkType == 'limited service' || networkType == 'no service'
9474 || simStatus != 'modem_init_complete'){
9475 siganl = '_none';
9476 }
9477 return "signal signal" + siganl;
9478 }
9479
9480 function sf_getWifiStatusCssClass(i_status, i_deviceSize) {
9481 if (i_status) {
9482 if (i_deviceSize == 0) {
9483 return "wifi_status0";
9484 } else {
9485 return "wifi_status" + i_deviceSize;
9486 }
9487 } else {
9488 return "wifi_status_off";
9489 }
9490 }
9491
9492 // ����wifi״̬��ȡwifi��ͼƬ��Դ
9493 function sf_getWifiStatusImage(i_status, i_deviceSize) {
9494 if (i_status) {
9495 if (i_deviceSize == 0) {
9496 return "./pic/wlan0.png";
9497 } else {
9498 return "./pic/wlan" + i_deviceSize + ".png";
9499 }
9500 } else {
9501 return "./pic/wlan_off.png";
9502 }
9503 }
9504
9505 // ��ȡ��������������С���������ؽ���
9506 function sf_refreshFotaDownloadProgress(){
9507 service.getPackSizeInfo({}, function (data) {
9508 var percents;
9509 if (parseInt(data.fota_pkg_total_size) == 0) {
9510 percents = 0;
9511 } else {
9512 percents = parseInt(parseInt(data.fota_dl_pkg_size) * 100 / parseInt(data.fota_pkg_total_size));
9513 }
9514 if (percents > 100) {
9515 percents = 100;
9516 }
9517 if (percents >= 0) {
9518 if (percents > 95) {
9519 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
9520 }
9521 setProgressBar(percents);
9522 }
9523 });
9524 }
9525
9526 // �������ŷ��ͱ���
9527 function sf_responseSmsReport(){
9528 if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
9529
9530 sv_isFirstLoadNewMessage = false;
9531
9532 if(config.HAS_PHONEBOOK){
9533 sf_getPhoneBooks();
9534 }else{
9535 config.phonebook = [];
9536 }
9537 }
9538 service.getSMSDeliveryReport({
9539 page: 0,
9540 smsCount: 10
9541 }, function(data){
9542 var s_messages = data.messages;
9543 var s_nums = [];
9544 $.each(s_messages, function(i, i_message){
9545 if($.inArray(i_message.number, s_nums) == -1){
9546 s_nums.push(i_message.number);
9547 window.setTimeout(function(){
9548 var s_now = $.now();
9549 sv_messagePopStack["m" + s_now] = s_now;
9550 i_message.name = i_message.number;
9551 for(i in config.phonebook){
9552 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9553 i_message.name = config.phonebook[i].pbm_name;
9554 break;
9555 }
9556 }
9557 var s_msgContent = $.i18n.prop("sms_delivery_report_" + i_message.content);
9558
9559 var s_newMsg = {
9560 mark : "m" + s_now,
9561 name: i_message.name,
9562 title: $.i18n.prop("sms_report"),
9563 titleTrans: "sms_report",
9564 content : s_msgContent,
9565 datetime : i_message.time,
9566 report : 'report'
9567 };
9568
9569 if(sv_newMessagePopTemplate == null){
9570 sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
9571 }
9572
9573 $(".report", "#buttom-bubble").remove();
9574 $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
9575 }, 100);
9576 }
9577 });
9578 }, function(){
9579 //No Deal
9580 });
9581 }
9582
9583 function sf_simStatusInvalid(simStatus){
9584 return simStatus == 'modem_sim_undetected' || simStatus == 'modem_undetected' || simStatus == 'modem_sim_destroy'
9585 || simStatus == 'modem_waitpin' || simStatus == 'modem_waitpuk' || simStatus == 'modem_imsi_waitnck';
9586 }
9587
9588 // ��ʾFOTA������ǰ״̬
9589 function sf_showFotaCurrentStatus() {
9590 sv_fotaUpdateCancel = true;
9591 var r = service.getNewVersionState();
9592
9593 function showProgress() {
9594 var upgradingState = ["downloading"];
9595 var info = service.getCurrentUpgradeState();
9596 if(info.current_upgrade_state.toLowerCase() == "idle") {
9597 addTimeout(showProgress, 1000);
9598 } else if(($.inArray(info.current_upgrade_state, upgradingState) != -1)&&(r.fota_new_version_state != "already_has_pkg")) {
9599 hideLoading();
9600 sf_showFotaUpgradeStatus();
9601 }
9602 }
9603 if (!($("#progress").is(":visible"))) {
9604 showProgress();
9605 }
9606 var times = 0;
9607 var getOTAUpgradeState = function () {
9608 var data = null;
9609 if (times <= 3) {
9610 times = times + 1;
9611 data = service.getCurrentUpgradeState();
9612 } else {
9613 data = getCurrentStatusInfo();
9614 }
9615 var state = data.current_upgrade_state;
9616 if(sv_fotaUpdateCancel && isLoggedIn == true){
9617
9618 if(r.fota_new_version_state == "already_has_pkg"){
9619 if(state == 'low_battery'){
9620 hideProgressBar();
9621 sv_fotaUpdateCancel = false;
9622 service.removeTimerThings('fota_current_upgrade_state',function(){});
9623 showInfo('ota_pkg_low_battery');
9624 window.clearTimeout(sv_timer);
9625 return;
9626 }else if(state == 'prepare_install'){
9627 hideProgressBar();
9628 sv_fotaUpdateCancel = false;
9629 service.removeTimerThings('fota_current_upgrade_state',function(){});
9630 showInfo('ota_pkg_download_success');
9631 window.clearTimeout(sv_timer);
9632 sv_batteryCheckTimer = setInterval(function () {
9633 sf_checkBatteryStatusForFota();
9634 }, 1000);
9635 return;
9636 }
9637 }else if(state == 'downloading') {
9638 sf_refreshFotaDownloadProgress();
9639 }else if(state == 'download_failed') {
9640 hideProgressBar();
9641 sv_fotaUpdateCancel = false;
9642 showAlert('ota_download_failed');
9643 window.clearTimeout(sv_timer);
9644 return;
9645 }else if(state == 'low_battery'){
9646 hideProgressBar();
9647 sv_fotaUpdateCancel = false;
9648 service.removeTimerThings('fota_current_upgrade_state',function(){});
9649 showInfo('ota_low_battery');
9650 window.clearTimeout(sv_timer);
9651 return;
9652 }else if(state == 'prepare_install'){
9653 hideProgressBar();
9654 sv_fotaUpdateCancel = false;
9655 service.removeTimerThings('fota_current_upgrade_state',function(){});
9656 showInfo('ota_download_success');
9657 window.clearTimeout(sv_timer);
9658 sv_batteryCheckTimer = setInterval(function () {
9659 sf_checkBatteryStatusForFota();
9660 }, 1000);
9661 return;
9662 }else{
9663 sv_fotaUpdateCancel = false;
9664 hideProgressBar();
9665 window.clearTimeout(sv_timer);
9666 return;
9667 }
9668 sv_timer = window.setTimeout(getOTAUpgradeState , 1000);
9669 }
9670 };
9671
9672 if(sv_fotaUpdateCancel && isLoggedIn == true){
9673 sv_timer = window.setTimeout(getOTAUpgradeState , 100);
9674 }else{
9675 window.clearTimeout(sv_timer);
9676 }
9677 }
9678
9679 // ��ʾFota��������
9680 function sf_showFotaUpdateResult(i_otaResult) {
9681 if ((!($("#loading").is(":visible"))) && (!($("#confirm").is(":visible")))) {
9682 var s_message = i_otaResult ? "ota_update_success" : "ota_update_failed";
9683 sv_fotaResultAlertPopuped = true;
9684 showAlert(s_message, function () {
9685 sv_fotaResultAlertPopuped = false;
9686 if (config.UPGRADE_TYPE == "OTA") {
9687 service.clearUpdateResult({}, $.noop());
9688 }
9689 });
9690 } else {
9691 window.setTimeout(function () {
9692 sf_showFotaUpdateResult(i_otaResult)
9693 }, 1000);
9694 }
9695 }
9696
9697 // ��ʾ��ǰ����״̬
9698 function sf_showFotaUpgradeStatus() {
9699 var s_data = service.getMandatory();
9700 var s_isMandatory = s_data.is_mandatory;
9701 var s_sizeInfo =service.getPackSizeInfo();
9702 var s_percents;
9703
9704 if (parseInt(s_sizeInfo.fota_pkg_total_size) == 0) {
9705 s_percents = 0;
9706 } else {
9707 s_percents = parseInt(parseInt(s_sizeInfo.fota_dl_pkg_size) * 100 / parseInt(s_sizeInfo.fota_pkg_total_size));
9708 }
9709 if (s_percents > 100) {
9710 s_percents = 100;
9711 }
9712
9713 if (s_isMandatory) {
9714 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
9715 } else {
9716 var cancelHtml = "";
9717 if (config.UPGRADE_TYPE == "OTA") {
9718 cancelHtml = "<br/><br/><button id='btnStopUpgrade' onclick='stopOTAUpgrade();' class='btn-1 btn-primary'>" + $.i18n.prop("cancel") + "</button>";
9719 }
9720 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning") + cancelHtml);
9721 }
9722
9723 //setProgressBar(0);
9724 if (s_percents >= 0) {
9725 setProgressBar(s_percents);
9726 }
9727 }
9728
9729
9730
9731
9732
9733 function sf_startFotaUpgrade(){
9734 service.setUpgradeSelectOp({selectOp:'1'},function(result){
9735 if (result.result == "success"){
9736 sf_showFotaCurrentStatus();
9737 }});
9738 }
9739
9740 function cancelFotaUpgrade(){
9741 service.setUpgradeSelectOp({selectOp:'0'},function(result){ });
9742 }
9743
9744
9745 function refreshFotaStatusForUserSelector(choice){
9746 var info = getCurrentStatusInfo();
9747 if(choice){
9748 var modeData = service.getOpMode();
9749 if (!checkConnectedStatus(info.connectStatus, modeData.rj45_state, info.connectWifiStatus)) {
9750 showAlert("ota_network_disconnected");
9751 return;
9752 }
9753
9754 if(info.fota_user_selector == 'none'){
9755 sf_startFotaUpgrade();
9756 }else if(info.fota_user_selector == 'accept'){
9757 sf_showFotaCurrentStatus();
9758 }else if(info.fota_user_selector == 'cancel'){
9759 showAlert("ota_have_cancel");
9760 }else if(info.fota_user_selector == 'downloading_cancel'){
9761 showAlert("ota_have_cancel");
9762 }
9763 }else{
9764 if(info.fota_user_selector == 'none'){
9765 cancelFotaUpgrade();
9766 }else if(info.fota_user_selector == 'accept'){
9767 sf_showFotaCurrentStatus();
9768 }else if(info.fota_user_selector == 'cancel'){
9769 // todo:
9770 }else if(info.fota_user_selector == 'downloading_cancel'){
9771 // todo:
9772 }
9773 }
9774 }
9775
9776
9777 // ��ʾ���°汾�������ж��Ƿ�������ʾ
9778 function showFotaStatusForUserToConfirm(upgradeState) {
9779 var upgState = upgradeState.current_upgrade_state;
9780 if (upgState == 'upgrade_pack_redownload') {
9781 showConfirm("ota_interrupted", {ok: function () {
9782 refreshFotaStatusForUserSelector(1);
9783 }, no: function () {
9784 refreshFotaStatusForUserSelector(0);
9785 }});
9786 } else {
9787 var upgradingState = ["prepare_install", "low_battery",
9788 "connecting_server", "connect_server_success", "downloading", "accept"];
9789 if ($.inArray(upgState, upgradingState) != -1) {
9790 sf_showFotaCurrentStatus();
9791 } else {
9792
9793 showConfirm($.i18n.prop('ota_new_version'), {ok: function () {
9794 refreshFotaStatusForUserSelector(1);
9795 config.ISNOW_NOTICE = false;
9796 }, no: function () {
9797 refreshFotaStatusForUserSelector(0);
9798 config.ISNOW_NOTICE = false;
9799 }});
9800 }
9801 }
9802 }
9803
9804 showOTAAlert = function () {
9805 config.ISNOW_NOTICE = true;
9806 var is_mandatory = service.getMandatory().is_mandatory;
9807 if (is_mandatory) {
9808 sf_showFotaCurrentStatus();
9809 } else {
9810 var upgradeState = {};
9811 upgradeState = service.getCurrentUpgradeState();
9812 showFotaStatusForUserToConfirm(upgradeState);
9813 }
9814 };
9815
9816 // ��ֹFota����
9817 stopOTAUpgrade = function () {
9818 service.setUpgradeSelectOp({selectOp:'2'},function(result){ });
9819 sv_fotaUpdateCancel = false;
9820 window.clearTimeout(sv_timer);
9821 hideLoading();
9822 showAlert('ota_cancel');
9823 };
9824
9825 // �������������Ƿ����ѹ�
9826 function setTrafficAlertPopuped(val){
9827 sv_trafficAlertPopuped = !!val;
9828 sv_trafficAlertPopuped_100 = !!val;
9829 if(!val){
9830 sv_resetTrafficAlertPopuped = true;
9831 }
9832 }
9833
9834 function setTrafficAlert100Popuped(val){
9835 sv_trafficAlertPopuped_100 = !!val;
9836 if(!val){
9837 sv_resetTrafficAlertPopuped = true;
9838 }
9839 }
9840
9841 // ���������ṹ
9842 function getTrafficResult(info){
9843 var s_trafficResult = {
9844 showConfirm : false,
9845 limitPercent : info.limitVolumePercent
9846 };
9847 if(info.limitVolumeType == '1'){
9848 var monthlyTraffic = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
9849 s_trafficResult.usedPercent = monthlyTraffic / info.limitVolumeSize * 100;
9850 if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
9851 s_trafficResult.showConfirm = true;
9852 s_trafficResult.type = 'data';
9853 }
9854 }else{
9855 s_trafficResult.usedPercent = info.data_counter.monthlyConnectedTime / info.limitVolumeSize * 100;
9856 if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
9857 s_trafficResult.showConfirm = true;
9858 s_trafficResult.type = 'time';
9859 }
9860 }
9861 return s_trafficResult;
9862 }
9863
9864 // ��ʼ�� ViewModel����������ͼ����
9865 function init() {
9866 if(config.PRODUCT_TYPE == 'DATACARD') {
9867 $('#statusBar').addClass('padding-right-90');
9868 $('#language').addClass('data-card-language');
9869 }
9870 //preload img
9871 var imgAlert = $('<img />').attr('src', 'pic/res_alert.png');
9872 var imgConfirm = $('<img />').attr('src', 'pic/res_confirm.png');
9873 var imgInfo = $('<img />').attr('src', 'pic/res_info.png');
9874
9875 window.setTimeout(function () {
9876
9877 var fwVm = new statusViewModel();
9878
9879 ko.applyBindings(fwVm, $('#statusBar')[0]);
9880
9881 window.setInterval(function () {
9882 var info = getCurrentStatusInfo();
9883 var s_roamStatus = info.roamingStatus ? true : false;
9884 var $langLogoBar = $("#langLogoBar");
9885 isLoggedIn = info.isLoggedIn;
9886
9887
9888 //fwVm.attachedDevices(info.attachedDevices);
9889 fwVm.batteryLevel(info.batteryLevel + '%');
9890 fwVm.batteryPers(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
9891 fwVm.batteryStatus(info.batteryStatus);
9892 fwVm.isShowFotaNewversionIcon(info.new_version_state && info.fota_user_selector && info.fota_package_already_download != "yes" && config.ISNOW_NOTICE && fwVm.updateType() == 'mifi_fota');
9893 fwVm.isShowRj45ConnectionIcon(config.RJ45_SUPPORT);
9894 fwVm.networkOperator(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,s_roamStatus));
9895 fwVm.networkType(getNetworkType(info.networkType));
9896 fwVm.pinStatus(info.pinStatus);
9897 fwVm.roamingStatus(info.roamingStatus ? "R" : "");
9898 fwVm.showAttachedDevices(info.wifiStatus);
9899 fwVm.simStatus(sf_convertSimStatusToImage(info.simStatus));
9900 fwVm.signalCssClass(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
9901 fwVm.isLoggedIn(info.isLoggedIn);
9902 fwVm.wifiStatusCssClass(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
9903 fwVm.wifiStatusImg(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
9904
9905 if(config.HAS_SMS ){
9906 if(!sv__hasCheckedSMSCapacity && info.isLoggedIn){
9907 checkSMSCapacity(info.smsUnreadCount);
9908 } else {
9909 fwVm.smsUnreadCount(info.smsUnreadCount);
9910 }
9911 }
9912
9913 sf_getConnectionCssClass(fwVm, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
9914 refreshWifiConnectStatus(fwVm, info.connectStatus,info.connectWifiSSID,info.connectWifiStatus);
9915 checkTrafficLimitAlert(fwVm, info);
9916 updateStatusBarTrans({simStatus: info.simStatus, wifiStatus: info.wifiStatus, deviceSize: info.wirelessDeviceNum, networkType: info.networkType});
9917
9918 if(info.isLoggedIn){
9919 $("#statusBar:hidden").show();
9920 } else {
9921 $("#statusBar:visible").hide();
9922 }
9923 }, 500);
9924
9925 if(config.HAS_SMS){
9926 window.setInterval(function(){
9927 if(fwVm.isLoggedIn()){
9928 checkSMSCapacity();
9929 }
9930 }, 10000);
9931 checkSmsModelReady();
9932 }
9933
9934 window.setInterval(function() {
9935 var data = getCurrentStatusInfo();
9936 var upgradingState = ["prepare_install", "low_battery", "download_success","downloading"];
9937
9938 if (fwVm.isLoggedIn() == true && !($("#progress").is(":visible")) && data.defaultWanName != ""){
9939 if ($.inArray(data.current_upgrade_state, upgradingState) != -1){
9940 if(null == sv_fotaUpdateCancel){
9941 if(!data.is_mandatory){
9942 $.modal.close();
9943 }
9944 sf_showFotaCurrentStatus();
9945 }else if(false == sv_fotaUpdateCancel){
9946 sv_fotaUpdateCancel = null;
9947 }
9948 }
9949 }
9950 }, 1000);
9951
9952 var checkFotaUpgradeResult = function () {
9953 var info = service.getStatusInfo();
9954 if (info.isLoggedIn) {
9955 service.getUpgradeResult({}, function (data) {
9956 if (data.upgrade_result == "success") {
9957 sf_showFotaUpdateResult(true);
9958 } else if (data.upgrade_result == "fail") {
9959 sf_showFotaUpdateResult(false);
9960 } else {
9961 window.setTimeout(checkFotaUpgradeResult, 1000);
9962 }
9963 }, function () {
9964 window.setTimeout(checkFotaUpgradeResult, 1000);
9965 });
9966 } else {
9967 window.setTimeout(checkFotaUpgradeResult, 1000);
9968 }
9969 };
9970 if(fwVm.updateType() == "mifi_fota"){
9971 checkFotaUpgradeResult();
9972 window.setInterval(function () {
9973 var info = getCurrentStatusInfo();
9974 if (info.isLoggedIn && info.defaultWanName != "") {
9975 if(info.new_version_state && info.fota_package_already_download != "yes" && !config.ALREADY_NOTICE){
9976 service.getUpgradeResult({}, function (data) {
9977 if (data.upgrade_result == "success") {
9978 sf_showFotaUpdateResult(true);
9979 } else if (data.upgrade_result == "fail") {
9980 sf_showFotaUpdateResult(false);
9981 } else {
9982 if(sv_fotaResultAlertPopuped == false){
9983 config.ALREADY_NOTICE = true;
9984 showOTAAlert();
9985 }
9986 }
9987 });
9988 }
9989 }
9990 }, 1000);
9991 }
9992 function checkSMSCapacity(unreadCount){
9993 service.getSmsCapability({}, function(info){
9994 var showSmsConfirm = false;
9995 if(info.nvTotal != 0 && info.nvUsed >= info.nvTotal){
9996 $("#sms_unread_count").attr("tipTitle", "sms_capacity_is_full");
9997 showSmsConfirm = true;
9998 } else if(info.nvTotal != 0 && info.nvUsed + 5 >= info.nvTotal) {
9999 $("#sms_unread_count").attr("tipTitle", "sms_capacity_will_full");
10000 showSmsConfirm = true;
10001 } else {
10002 $("#sms_unread_count").attr("tipTitle", "sms_unread_count");
10003 }
10004 fwVm.showSmsDeleteConfirm(showSmsConfirm);
10005 if(typeof unreadCount != "undefined"){
10006 fwVm.smsUnreadCount(unreadCount);
10007 }
10008 sv__hasCheckedSMSCapacity = true;
10009 });
10010 }
10011 }, 1200);
10012
10013 tooltip.init();
10014
10015 // ������Ϣģ����ʼ��״̬
10016 function checkSmsModelReady(){
10017 var info = getCurrentStatusInfo();
10018 if(info.isLoggedIn){
10019 service.getSMSReady({}, function (data) {
10020 if (data.sms_cmd_status_result == "1") {
10021 window.setTimeout(function(){checkSmsModelReady();}, 1000);
10022 } else {
10023 sv__initSMSCompleted = true;
10024 }
10025 });
10026 } else {
10027 window.setTimeout(function(){checkSmsModelReady();}, 1000);
10028 }
10029 }
10030
10031 // ������������״̬
10032 checkTrafficLimitAlert = function(fwVm, info){
10033 if(window.location.hash == '#entry'){
10034 return false;
10035 }
10036 var APStationEnabled = config.AP_STATION_SUPPORT ? service.getStatusInfo().ap_station_enable : 'undefined';
10037 var trafficResult = getTrafficResult(info);
10038 var inShow = $("#confirm-container:visible").length > 0;
10039 var notPPP = (config.PRODUCT_TYPE == 'CPE' && checkCableMode(info.blc_wan_mode)) ? true : false;
10040
10041 // ��ȡAp Stationʹ��״̬���������ѷ�ʽ
10042 if (config.AP_STATION_SUPPORT && (typeof APStationEnabled == "undefined" || APStationEnabled === '')) {
10043 service.refreshAPStationStatus({}, $.noop());
10044 return false;
10045 }
10046 APStationEnabled = APStationEnabled == 1;
10047
10048 if (!info.isLoggedIn || inShow || (sv_trafficAlertPopuped && sv_trafficAlertPopuped_100) || !info.limitVolumeEnable || (!APStationEnabled && !(info.connectStatus == "ppp_connected")) || notPPP) {
10049 return false;
10050 }
10051
10052 if(sv_resetTrafficAlertPopuped){
10053 window.setTimeout(function () {
10054 sv_resetTrafficAlertPopuped = false;
10055 }, 2000);
10056 return false;
10057 }
10058
10059 if(trafficResult.showConfirm){
10060
10061 var confirmMessage = null;
10062
10063 if(trafficResult.usedPercent > 100 && !sv_trafficAlertPopuped_100){
10064
10065 sv_trafficAlertPopuped = true;
10066 sv_trafficAlertPopuped_100 = true;
10067
10068 confirmMessage = {msg: APStationEnabled ? 'traffic_beyond_msg' : 'traffic_beyond_disconnect_msg'};
10069
10070 } else if (!sv_trafficAlertPopuped) {
10071
10072 sv_trafficAlertPopuped = true;
10073 sv_trafficAlertPopuped_100 = false;
10074 confirmMessage = {msg: APStationEnabled ? 'traffic_limit_msg' : 'traffic_limit_disconnect_msg',
10075 params: [trafficResult.limitPercent]};
10076 }
10077
10078 if (confirmMessage != null) {
10079 if (APStationEnabled) {
10080 showAlert(confirmMessage);
10081 } else {
10082 showConfirm(confirmMessage, function () {
10083 showLoading("disconnecting");
10084 service.disconnect({}, function (data) {
10085 if (data.result) {
10086 successOverlay();
10087 } else {
10088 errorOverlay();
10089 }
10090 });
10091 });
10092 }
10093 }
10094 }
10095 return true;
10096 };
10097
10098 // ����״̬�е�tooltip
10099 function updateStatusBarTrans(status){
10100 $("#statusItemSimStatus").attr("tipTitle", "sim_status_" + status.simStatus);
10101 if (status.wifiStatus) {
10102 if (status.deviceSize == 0) {
10103 $("#wifi_status").attr("tipTitle","wifi_status_on");
10104 } else {
10105 $("#wifi_status").attr("tipTitle","wifi_status" + status.deviceSize);
10106 }
10107 } else {
10108 $("#wifi_status").attr("tipTitle","wifi_status_off");
10109 }
10110 }
10111
10112
10113 // ˢ��wifi��������״̬
10114 function refreshWifiConnectStatus(fwVm, status, wifiSSID, wifiStatus) {
10115 fwVm.connectStatus(status);
10116 if (status == "ppp_disconnecting") {
10117 fwVm.connectStatusTrans("disconnecting");
10118 fwVm.connectStatusText($.i18n.prop("disconnecting"));
10119 } else if (status == "ppp_connecting") {
10120 fwVm.connectStatusTrans("connecting");
10121 fwVm.connectStatusText($.i18n.prop("connecting"));
10122 } else if (status == "ppp_connected") {
10123 fwVm.connectStatusTrans("connected");
10124 fwVm.connectStatusText($.i18n.prop("connected"));
10125 } else if(wifiSSID){
10126 if(wifiStatus =="dhcping" || wifiStatus =="connecting"){
10127 fwVm.connectStatus("wifi_connecting");
10128 fwVm.connectStatusTrans("connecting");
10129 fwVm.connectStatusText($.i18n.prop("connecting"));
10130 }else if(wifiStatus =="connect"){
10131 fwVm.connectStatus("wifi_connect");
10132 fwVm.connectStatusTrans("connected");
10133 fwVm.connectStatusText($.i18n.prop("connected"));
10134 }else{
10135 fwVm.connectStatus("ppp_disconnected");
10136 fwVm.connectStatusTrans("disconnected");
10137 fwVm.connectStatusText($.i18n.prop("disconnected"));
10138 }
10139 }else{
10140 fwVm.connectStatusTrans("disconnected");
10141 fwVm.connectStatusText($.i18n.prop("disconnected"));
10142 }
10143 }
10144
10145 // ��ȡ��ǰ����״̬
10146 getNetworkType = function(networkType) {
10147 var networkTypeTmp = networkType.toLowerCase();
10148 if (networkTypeTmp == '' || networkTypeTmp == 'limited service') {
10149 networkTypeTmp = 'limited_service';
10150 }
10151 if(networkTypeTmp == 'no service') {
10152 networkTypeTmp = 'no_service';
10153 }
10154 if (networkTypeTmp == 'limited_service' || networkTypeTmp == 'no_service') {
10155 $("#networkType", "#statusBar").attr("data-trans", "network_type_" + networkTypeTmp);
10156 return $.i18n.prop("network_type_" + networkTypeTmp);
10157 } else {
10158 $("#networkType", "#statusBar").removeAttr("data-trans");
10159 return networkType;
10160 }
10161 };
10162
10163 if(config.HAS_SMS && menu.checkIsMenuExist("sms_list")){
10164 window.setInterval(function () {
10165 var info = getCurrentStatusInfo();
10166 if(window.location.hash == "#entry" || sf_simStatusInvalid(info.simStatus)){
10167 return;
10168 }
10169 for(key in sv_messagePopStack){
10170 var val = sv_messagePopStack[key];
10171 if($.now() - val > 5000){
10172 delete(sv_messagePopStack["m" + val]);
10173 var node = $(".bubbleItem#m" + val, "#buttom-bubble");
10174 node.fadeOut(1000, function(){
10175 $(this).remove();
10176 });
10177 }
10178 }
10179 if(info.isLoggedIn){
10180 if(info.newSmsReceived && !sv_newSMSMessageInDealing){
10181 sv_newSMSMessageInDealing = true;
10182 service.resetNewSmsReceivedVar();
10183 sf_checkNewMessages();
10184 }
10185 if(info.smsReportReceived){
10186 service.resetSmsReportReceivedVar();
10187 sf_responseSmsReport();
10188 }
10189 }
10190 }, 1000);
10191
10192 if(config.SMS_DATABASE_SORT_SUPPORT){
10193 window.setInterval(function(){
10194 if(menu.checkIsMenuExist("sms_list")){
10195 var info = getCurrentStatusInfo();
10196 if(info.isLoggedIn && sv__initSMSCompleted && !sv_newSMSMessageInDealing && !sf_simStatusInvalid(info.simStatus)){
10197 sv_newSMSMessageInDealing = true;
10198 sf_checkNewMessages();
10199 }
10200 }
10201 }, 20001);
10202 }
10203 }
10204
10205 function sf_checkNewMessages(){
10206
10207 var s_tags = 1;
10208 var s_smsCount = 5;
10209
10210 if(!config.dbMsgs || config.dbMsgs.length == 0){
10211 s_smsCount = 500;
10212 s_tags = 10;
10213 }
10214 service.getSMSMessages({
10215 page : 0,
10216 smsCount : s_smsCount,
10217 nMessageStoreType : 0,
10218 tags : s_tags,
10219 orderBy : "order by id desc"
10220 }, function(data){
10221 if(data && data.messages){
10222 sf_filterNewMessage(data.messages, 0);
10223 }
10224 sv_newSMSMessageInDealing = false;
10225 });
10226 service.getSMSMessages({
10227 page : 0,
10228 smsCount : s_smsCount,
10229 nMessageStoreType : 1,
10230 tags : s_tags,
10231 orderBy : "order by id desc"
10232 }, function(data){
10233 if(data && data.messages){
10234 sf_filterNewMessage(data.messages, 1);
10235 }
10236 sv_newSMSMessageInDealing = false;
10237 });
10238 }
10239
10240 if(config.HAS_SMS){
10241 $(".bubbleItem", "#buttom-bubble").live("mouseover", function(){
10242 var $this = $(this);
10243 delete(sv_messagePopStack[$this.attr("id")]);
10244 }).live("mouseout", function(){
10245 var $this = $(this);
10246 var now = $.now();
10247 sv_messagePopStack["m" + now] = now;
10248 $this.attr("id", "m" + now);
10249 $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").data("targetid", "m" + now);
10250 });
10251
10252 $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").die().live("click", function(){
10253 var id = $(this).data("targetid");
10254 delete(sv_messagePopStack[id]);
10255 var node = $(".bubbleItem#" + id, "#buttom-bubble");
10256 node.fadeOut(1000, function(){
10257 $(this).remove();
10258 });
10259 });
10260 }
10261 }
10262
10263
10264 return {
10265 init:init,
10266 setTrafficAlertPopuped: setTrafficAlertPopuped,
10267 setTrafficAlert100Popuped: setTrafficAlert100Popuped,
10268 getTrafficResult: getTrafficResult,
10269 showOTAAlert:showOTAAlert
10270 };
10271});
10272
10273// ����ͳ������ģ��
10274define("status_traffic_alert","jquery knockout service statusBar echarts".split(" "),
10275
10276 function ($, ko, service, status, echarts) {
10277
10278 var sv_trafficGraph = null;
10279 var sv_sourceData = null;
10280 var sv_usedDataModified = false;
10281 var sv_usedTimeModified = false;
10282
10283 var sv_trafficStaticalInfo = {
10284 // ����ͼ��ʼֵ
10285 data: {
10286 alarm: {
10287
10288 itemStyle: {
10289 normal: {
10290 color: '#8CC916'
10291 }
10292 },
10293 name: '������',
10294 value: 19.7
10295 },
10296 alert: {
10297
10298 itemStyle: {
10299 normal: {
10300 color: '#FF5500'
10301 }
10302 },
10303 name: '����ֵ',
10304 value: 1
10305 },
10306 free: {
10307
10308 itemStyle: {
10309 normal: {
10310 color: '#D8D8D8'
10311 }
10312 },
10313 name: 'δʹ��',
10314 value: 50
10315 },
10316 full: {
10317
10318
10319 itemStyle: {
10320 normal: {
10321 color: '#DF4313'
10322 }
10323 },
10324 name: '��������',
10325 value: 30
10326 },
10327 left1: {
10328
10329 itemStyle: {
10330 normal: {
10331 color: '#D8D8D8'
10332 }
10333 },
10334 name: '����ֵ��δʹ��',
10335 value: 50,
10336 },
10337 start: {
10338
10339 itemStyle: {
10340 normal: {
10341 color: '#D8D8D8'
10342 }
10343 },
10344 name: '����ֵ��δʹ��',
10345 value: 50
10346 },
10347 used: {
10348
10349 itemStyle: {
10350 normal: {
10351 color: '#8CC916'
10352 }
10353 },
10354 name: '��ʹ��',
10355 value: 30
10356 }
10357 },
10358 cacheEle: {},
10359 // Ԫ�ػ�ȡ
10360 getEle: function (i_elementId) {
10361 if (this.cacheEle.hasOwnProperty('id')) {
10362 return this.cacheEle[i_elementId];
10363 } else {
10364 this.cacheEle[i_elementId] = $("#" + i_elementId);
10365 return this.cacheEle[i_elementId];
10366 }
10367 },
10368 // ��ȡ�����澯״ֵ̬
10369 fetchTrafficAlertInfo: function(){
10370 sv_sourceData = getTrafficAlertInfo();
10371 return sv_sourceData;
10372 },
10373 // ��ȡ����ֵ�Ͷ�Ӧ��λֵ
10374 getTrafficStatisticalDatalnfo: function (i_valueInfo) {
10375 return {
10376 data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
10377 unit: /[A-Z]{1,2}/.exec(i_valueInfo)[0]
10378 }
10379 },
10380
10381 // ��ȡʱ��ʱ���֡���
10382 getTrafficTimeHours: function (i_time) {
10383 var s_timeArray = i_time.split(':');
10384 return {
10385 h: parseInt(s_timeArray[0], 10),
10386 m: parseInt(s_timeArray[1], 10),
10387 s: parseInt(s_timeArray[2], 10)
10388 }
10389 },
10390 // ��ȡͳ��ʱ���Ͷ�Ӧ��λֵ
10391 getTrafficTimeInfo: function (i_valueInfo) {
10392 return {
10393 data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
10394 unit: /[a-z]{4,6}/.exec(i_valueInfo)[0]
10395 }
10396 },
10397 // ʱ�任����S
10398 getTrafficTimeToSeconds: function (i_time) {
10399 var s_FormattedTime = this.getTrafficTimeHours(i_time);
10400 return s_FormattedTime.h * 3600 + s_FormattedTime.m * 60 + s_FormattedTime.s;
10401 },
10402 // ͨ�����ƻ�ȡ������λ
10403 getTrafficUnitByScale: function (i_scale) {
10404 if (i_scale == '1024') {
10405 return 'GB';
10406 } else if (i_scale == '1048576') {
10407 return 'TB';
10408 } else {
10409 return 'MB';
10410 }
10411 },
10412 // ��λ��Ӧֵ��ȡ
10413 getTrafficValueByStatisticalUnit: function (i_unit) {
10414 i_unit = i_unit.toLowerCase();
10415 if(i_unit == 'minute'){
10416 return '60';
10417 } else if (i_unit == 'gb') {
10418 return '1024';
10419 } else if(i_unit == 'hour'){
10420 return '3600';
10421 } else if (i_unit == 'tb') {
10422 return '1048576';
10423 } else {
10424 return '1';
10425 }
10426 },
10427
10428 // ���������Ƿ��ɱ༭
10429 isFormEditable: function (fwVm) {
10430 var s_dataPageEditState = fwVm.dataLimitTypeChecked() == '1' && (fwVm.viewEditUsedData() || fwVm.viewEditAlertData() || fwVm.viewEditTotalData());
10431 var s_timePageEditState = fwVm.dataLimitTypeChecked() == '0' && (fwVm.viewEditUsedTime() || fwVm.viewEditAlertTime() || fwVm.viewEditTotalTime());
10432 if (s_dataPageEditState || s_timePageEditState) {
10433 $('.border-color-transition:visible').addClass('attention-focus');
10434 addTimeout(function () {
10435 $('.border-color-transition:visible').removeClass('attention-focus');
10436 }, 1500);
10437 return true;
10438 } else {
10439 var s_result = false;
10440 if (fwVm.dataLimitTypeChecked() == 1) {
10441 if (fwVm.alertDataReach() == '0') {
10442 fwVm.editAlertDataHandler();
10443 s_result = true;
10444 }
10445 if (fwVm.limitDataMonth() == '0') {
10446 fwVm.editTotalDataHandler();
10447 s_result = true;
10448 }
10449 } else {
10450 if (fwVm.alertTimeReach() == '0') {
10451 fwVm.editAlertTimeHandler();
10452 s_result = true;
10453 }
10454 if (fwVm.limitTimeMonth() == '0') {
10455 fwVm.editTotalTimeHandler();
10456 s_result = true;
10457 }
10458 }
10459
10460 if (s_result) {
10461 $('.border-color-transition:visible').addClass('attention-focus');
10462 addTimeout(function () {
10463 $('.border-color-transition:visible').removeClass('attention-focus');
10464 }, 1500);
10465 }
10466 return s_result;
10467 }
10468 },
10469
10470 // ˢ������ͼ��Ϣ������������ֵ����ʾ����
10471
10472 refreshFlowDiagramInfo: function (fwVm) {
10473 var s_alarm = 0;
10474 var s_left = 0;
10475 var s_left1 = 0;
10476 var s_reach = 0;
10477 var s_total = 0;
10478 var s_used = 0;
10479
10480
10481 var s_startName = $.i18n.prop("echarts_no");
10482
10483 if (sv_sourceData.dataLimitChecked == '1') { //if (fwVm.dataLimitChecked() == '1') { //����
10484 s_startName = $.i18n.prop("echarts_used");
10485 sv_trafficGraphOptions.series[0].data = [];
10486
10487 if (fwVm.dataLimitTypeChecked() == '1') { // ����
10488 sv_trafficGraphOptions.title.text = "";
10489 sv_trafficGraphOptions.series[0].data = [];
10490
10491 if (fwVm.limitDataMonth() == 0) {
10492 var s_usedData = sv_trafficStaticalInfo.data.used;
10493 s_usedData.value = 1;
10494 s_usedData.name = $.i18n.prop("echarts_used");
10495 s_usedData.selected = false;
10496 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10497 } else {
10498 s_total = fwVm.limitDataMonth() * fwVm.selectedDataUnit() * 1048576;
10499 s_used = parseInt(sv_sourceData.monthlySent, 10) + parseInt(sv_sourceData.monthlyReceived, 10);
10500 s_reach = s_total * fwVm.alertDataReach() / 100;
10501
10502 if (s_used >= s_total) {
10503 var s_fullData = sv_trafficStaticalInfo.data.full;
10504 s_fullData.value = 100;
10505 s_fullData.name = $.i18n.prop("echarts_full");
10506 sv_trafficGraphOptions.series[0].data.push(s_fullData);
10507 s_startName = $.i18n.prop("echarts_full");
10508 } else {
10509 if (s_reach > s_used) {
10510 s_left1 = s_reach - s_used;
10511 s_left = s_total - s_reach;
10512 } else {
10513 s_alarm = s_used - s_reach;
10514 s_left = s_total - s_used;
10515 }
10516
10517 var s_usedData = sv_trafficStaticalInfo.data.used;
10518 if (s_reach - s_used > 0) {
10519 s_usedData.value = s_used;
10520 } else {
10521 s_usedData.value = s_reach;
10522 }
10523 s_usedData.name = $.i18n.prop("echarts_used");
10524 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10525
10526 if (s_left1 > 0) {
10527 var s_left1Data = sv_trafficStaticalInfo.data.left1;
10528 s_left1Data.value = s_left1;
10529 s_left1Data.name = $.i18n.prop("echarts_left1");
10530 sv_trafficGraphOptions.series[0].data.push(s_left1Data);
10531 }
10532
10533 var s_alertData = sv_trafficStaticalInfo.data.alert;
10534 s_alertData.value = s_total / 200;
10535 s_alertData.name = $.i18n.prop("echarts_alert");
10536 sv_trafficGraphOptions.series[0].data.push(s_alertData);
10537
10538 if (s_alarm > 0) {
10539 var s_alarmData = sv_trafficStaticalInfo.data.alarm;
10540 s_alarmData.value = s_alarm;
10541 s_alarmData.name = $.i18n.prop("echarts_alarm");
10542 sv_trafficGraphOptions.series[0].data.push(s_alarmData);
10543 }
10544
10545 var s_freeData = sv_trafficStaticalInfo.data.free;
10546 s_freeData.value = s_left;
10547 s_freeData.name = $.i18n.prop("echarts_free");
10548 sv_trafficGraphOptions.series[0].data.push(s_freeData);
10549 }
10550 }
10551
10552 }else{// ʱ��
10553
10554 sv_trafficGraphOptions.series[0].data = [];
10555
10556 if (fwVm.limitTimeMonth() == 0) {
10557 var s_usedData = sv_trafficStaticalInfo.data.used;
10558 s_usedData.value = 1;
10559 s_usedData.selected = false;
10560 s_usedData.name = $.i18n.prop("echarts_used");
10561 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10562 } else {
10563 s_total = fwVm.limitTimeMonth() * fwVm.selectedTimeUnit();
10564 s_used = sv_sourceData.monthlyConnectedTime;
10565 s_reach = s_total * fwVm.alertTimeReach() / 100;
10566
10567 if (s_used >= s_total) {
10568 var fullTime = sv_trafficStaticalInfo.data.full;
10569 fullTime.value = 100;
10570 fullTime.name = $.i18n.prop("echarts_full");
10571 sv_trafficGraphOptions.series[0].data.push(fullTime);
10572 s_startName = $.i18n.prop("echarts_full");
10573 } else {
10574 if (s_reach - s_used > 0) {
10575 s_left1 = s_reach - s_used;
10576 s_left = s_total - s_reach;
10577 } else {
10578 s_alarm = s_used - s_reach;
10579 s_left = s_total - s_used;
10580 }
10581
10582 var s_usedTime = sv_trafficStaticalInfo.data.used;
10583 if (s_reach - s_used > 0) {
10584 s_usedTime.value = s_used;
10585 } else {
10586 s_usedTime.value = s_reach;
10587 }
10588 s_usedTime.name = $.i18n.prop("echarts_used");
10589 sv_trafficGraphOptions.series[0].data.push(s_usedTime);
10590
10591 if (s_left1 > 0) {
10592 var s_left1Time = sv_trafficStaticalInfo.data.left1;
10593 s_left1Time.value = s_left1;
10594 s_left1Time.name = $.i18n.prop("echarts_left1");
10595 sv_trafficGraphOptions.series[0].data.push(s_left1Time);
10596 }
10597
10598 var s_alertTime = sv_trafficStaticalInfo.data.alert;
10599 s_alertTime.value = s_total / 200;
10600 s_alertTime.name = $.i18n.prop("echarts_alert");
10601 sv_trafficGraphOptions.series[0].data.push(s_alertTime);
10602
10603 if (s_alarm > 0) {
10604 var s_alarmTime = sv_trafficStaticalInfo.data.alarm;
10605 s_alarmTime.value = s_alarm;
10606 s_alarmTime.name = $.i18n.prop("echarts_alarm");
10607 sv_trafficGraphOptions.series[0].data.push(s_alarmTime);
10608 }
10609
10610 var s_freeTime = sv_trafficStaticalInfo.data.free;
10611 s_freeTime.value = s_left;
10612 s_freeTime.name = $.i18n.prop("echarts_free");
10613 sv_trafficGraphOptions.series[0].data.push(s_freeTime);
10614 }
10615 }
10616 }
10617 } else {
10618 var s_usedData = sv_trafficStaticalInfo.data.used;
10619 s_usedData.value = 1;
10620 s_usedData.selected = false;
10621 s_usedData.name = $.i18n.prop("echarts_no");
10622
10623 sv_trafficGraphOptions.series[0].data = [s_usedData];
10624 sv_trafficGraphOptions.title.text = '';
10625 }
10626 sv_trafficStaticalInfo.setFlowDiagramInfo(sv_trafficGraphOptions, s_startName);
10627 },
10628
10629
10630 // �ػ�����ͼ
10631 setFlowDiagramInfo: function (i_options, i_startName) {
10632 var s_startPart = sv_trafficStaticalInfo.data.start;
10633
10634 s_startPart.name = i_startName;
10635 s_startPart.selected = false;
10636 s_startPart.value = 0;
10637
10638 var s_arr = [s_startPart].concat(i_options.series[0].data);
10639 i_options.series[0].data = s_arr;
10640 sv_trafficGraph.setOption(i_options, true);
10641
10642 addTimeout(function () {
10643 sv_trafficGraph.resize();
10644 }, 1000);
10645 }
10646 };
10647
10648
10649 // ����ͼ��������
10650 var sv_trafficGraphOptions = {
10651 animation: false,
10652 color: ['red', 'red', 'red', 'red', 'red'],
10653 series: [
10654 {
10655 name: '��������',
10656 radius: ['0', '75'],
10657 selectedOffset: 3,
10658 type: 'pie',
10659 data: [
10660
10661 ],
10662 itemStyle: {
10663 normal: {
10664 labelLine: {
10665 show: false
10666 },
10667 label: {
10668 show: false
10669 }
10670 }
10671 }
10672 }
10673 ],
10674 title: {
10675 itemGap: 0,
10676 text: '',
10677 subtextStyle: {
10678 color: '#FFF',
10679 fontFamily: '΢���ź�',
10680 fontSize: 16,
10681 fontWeight: 'bolder'
10682 },
10683 textStyle: {
10684 color: '#FFF',
10685 fontFamily: '΢���ź�',
10686 fontSize: 20,
10687 fontWeight: 'bolder'
10688 },
10689 x: 'center',
10690 y: 'center'
10691 },
10692 tooltip: {
10693 formatter: "{b}"
10694 }
10695 };
10696
10697
10698 // ��ȡ������������
10699 function getTrafficAlertInfo() {
10700 return service.getTrafficAlertInfo();
10701 }
10702
10703
10704
10705 // ��������ViewModel
10706
10707 function trafficViewModel() {
10708
10709 var target = this;
10710
10711 var info = sv_trafficStaticalInfo.fetchTrafficAlertInfo();
10712 var dataMonth = info.limitDataMonth.split("_");
10713
10714 sv_usedDataModified = false;
10715 sv_usedTimeModified = false;
10716
10717 target.alertDataReach = ko.observable(info.alertDataReach || 0);
10718 target.alertTimeReach = ko.observable(info.alertTimeReach || 0);
10719 target.dataLimitChecked = ko.observable(info.dataLimitChecked == '0' ? '0' : '1');
10720 target.dataLimitTypeChecked = ko.observable(info.dataLimitTypeChecked == '0' ? '0' : '1');
10721 target.limitTimeMonth = ko.observable(info.limitTimeMonth || 0);
10722
10723
10724 // ע��˳��
10725 target.usedDataText = ko.observable(transUnit(parseInt(info.monthlySent, 10) + parseInt(info.monthlyReceived, 10), false));
10726 var sv_staticalDataInfo = sv_trafficStaticalInfo.getTrafficStatisticalDatalnfo(target.usedDataText());
10727 var sv_staticalInfoData = sv_staticalDataInfo.data;
10728 target.dataUsed = ko.observable(sv_staticalInfoData);
10729 var sv_staticalInfoUnit = sv_staticalDataInfo.unit;
10730 target.selectedDataUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_staticalInfoUnit));
10731 target.usedDataTextDescData = ko.observable("");
10732
10733 target.limitDataMonth = ko.observable(dataMonth[0] || 0);
10734 target.selectedDataUnit = ko.observable(dataMonth[1] || 1);
10735
10736 var limitDataMonthTmp = transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1024 * 1024, false);
10737 var limitDataMonthUnitTmp = limitDataMonthTmp.substring(limitDataMonthTmp.length-2);
10738 target.limitDataMonth(limitDataMonthTmp.substring(0, limitDataMonthTmp.length-2));
10739 target.selectedDataUnit(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(limitDataMonthUnitTmp));
10740
10741 target.usedDataTextDesc = ko.computed(sf_usedDataTextDesc);
10742 target.limitDataMonthDescData = ko.observable("");
10743 target.limitDataMonthDesc = ko.computed(sf_limitDataMonthDesc);
10744 target.alertDataReachDescData = ko.observable("");
10745 target.alertDataReachDesc = ko.computed(sf_alertDataReachDesc);
10746 target.leftDataDescData = ko.observable("");
10747 target.leftDataDesc = ko.computed(sf_leftDataDesc);
10748 target.monthlyConnectedTime = ko.observable(transSecond2Time(info.monthlyConnectedTime));
10749
10750 var sv_timeInfo1 = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(info.monthlyConnectedTime));
10751 target.usedTime = ko.observable(sv_timeInfo1.data);
10752 target.selectedTimeUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfo1.unit));
10753
10754 target.usedTimeTextDescData = ko.observable("");
10755 target.usedTimeTextDesc = ko.computed(sf_usedTimeTextDesc);
10756
10757 var sv_timeInfoNew = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(parseFloat(target.limitTimeMonth()) * 3600));
10758 target.selectedTimeUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfoNew.unit));
10759 target.limitTimeMonth(sv_timeInfoNew.data);
10760
10761
10762 target.limitTimeMonthDescData = ko.observable("");
10763 target.limitTimeMonthDescText = ko.observable("traffic_limit_time_h");
10764 target.limitTimeMonthDesc = ko.computed(sf_limitTimeMonthDesc);
10765 target.alertTimeReachDescData = ko.observable("");
10766 target.alertTimeReachDesc = ko.computed(sf_alertTimeReachDesc);
10767 target.leftTimeDescData = ko.observable("");
10768 target.leftTimeDesc = ko.computed(sf_leftTimeDesc);
10769 target.save = sf_save;
10770 target.viewEditUsedData = ko.observable(false);
10771 target.editUsedDataHandler = sf_editUsedDataHandler;
10772 target.editUsedDataSaveHandler = sf_editUsedDataSaveHandler;
10773 target.saveUsedData = sf_saveUsedData;
10774 target.editUsedDataCancelHandler = sf_editUsedDataCancelHandler;
10775 target.viewEditTotalData = ko.observable(false);
10776 target.editTotalDataHandler = sf_editTotalDataHandler;
10777 target.editTotalDataSaveHandler = sf_editTotalDataSaveHandler;
10778 target.editTotalDataCancelHandler = sf_editTotalDataCancelHandler;
10779 target.viewEditAlertData = ko.observable(false);
10780 target.editAlertDataHandler = sf_editAlertDataHandler;
10781 target.editAlertDataSaveHandler = sf_editAlertDataSaveHandler;
10782 target.editAlertDataCancelHandler = sf_editAlertDataCancelHandler;
10783 target.viewEditUsedTime = ko.observable(false);
10784 target.editUsedTimeHandler = sf_editUsedTimeHandler;
10785 target.saveUsedTime = sf_saveUsedTime;
10786 target.editUsedTimeSaveHandler = sf_editUsedTimeSaveHandler;
10787 target.editUsedTimeCancelHandler = sf_editUsedTimeCancelHandler;
10788 target.viewEditTotalTime = ko.observable(false);
10789 target.editTotalTimeHandler = sf_editTotalTimeHandler ;
10790 target.editTotalTimeSaveHandler = sf_editTotalTimeSaveHandler;
10791 target.editTotalTimeCancelHandler = sf_editTotalTimeCancelHandler;
10792 target.viewEditAlertTime = ko.observable(false);
10793 target.editAlertTimeHandler = sf_editAlertTimeHandler;
10794 target.editAlertTimeSaveHandler = sf_editAlertTimeSaveHandler;
10795 target.editAlertTimeCancelHandler = sf_editAlertTimeCancelHandler;
10796 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
10797
10798
10799 // ��������������
10800 function sf_alertDataReachDesc() {
10801 if(isNaN(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach())) {
10802 target.alertDataReachDescData(target.alertDataReach() + ', ');
10803 return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), ' ');
10804 }
10805
10806 var s_value = transUnit(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach() * 1048576 / 100, false);
10807 target.alertDataReachDescData(target.alertDataReach() + ',' + s_value);
10808 return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), s_value);
10809 }
10810 // ʱ������������
10811 function sf_alertTimeReachDesc() {
10812 if(isNaN(target.limitTimeMonth() * target.alertTimeReach())) {
10813 target.alertTimeReachDescData(target.alertTimeReach() + ', ');
10814 return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), ' ');
10815 }
10816 var s_value = transSecond2Time(target.limitTimeMonth() * target.selectedTimeUnit() * target.alertTimeReach() / 100);
10817 target.alertTimeReachDescData(target.alertTimeReach() + ',' + s_value);
10818 return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), s_value);
10819 }
10820
10821
10822 // ��������ֵȡ���༭��ť�¼�
10823 function sf_editAlertDataCancelHandler() {
10824 target.alertDataReach(sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue'));
10825 target.viewEditAlertData(false);
10826 }
10827
10828 // ��������ֵ�༭��ť�¼�
10829 function sf_editAlertDataHandler() {
10830 sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue', target.alertDataReach());
10831 target.viewEditAlertData(true);
10832 }
10833
10834 // ��������ֵ�����༭��ť�¼�
10835 function sf_editAlertDataSaveHandler() {
10836 if (sv_trafficStaticalInfo.getEle('alertDataReach').valid()) {
10837 target.viewEditAlertData(false);
10838 }
10839 }
10840
10841 // ʱ������ֵȡ���༭��ť�¼�
10842 function sf_editAlertTimeCancelHandler() {
10843 target.alertTimeReach(sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue'));
10844 target.viewEditAlertTime(false);
10845 }
10846 // ʱ������ֵ�༭��ť�¼�
10847 function sf_editAlertTimeHandler() {
10848 sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue', target.alertTimeReach());
10849 target.viewEditAlertTime(true);
10850 }
10851 // ʱ������ֵ�����༭��ť�¼�
10852 function sf_editAlertTimeSaveHandler() {
10853 if (sv_trafficStaticalInfo.getEle('alertTimeReach').valid()) {
10854 target.viewEditAlertTime(false);
10855 }
10856 }
10857
10858 // �ײ������༭��ť�¼�
10859 function sf_editTotalDataHandler() {
10860 sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue', target.limitDataMonth());
10861 sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue', target.selectedDataUnit());
10862 target.viewEditTotalData(true);
10863 }
10864
10865 // �ײ����������༭��ť�¼�
10866 function sf_editTotalDataSaveHandler() {
10867 if (sv_trafficStaticalInfo.getEle('limitDataMonth').valid()) {
10868 target.usedDataText(transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1048576, false));
10869 target.viewEditTotalData(false);
10870 }
10871 }
10872
10873 // �ײ�����ȡ���༭��ť�¼�
10874 function sf_editTotalDataCancelHandler() {
10875 target.limitDataMonth(sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue'));
10876 target.selectedDataUnit(sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue'));
10877 target.viewEditTotalData(false);
10878 }
10879 // �ײ�ʱ��ȡ���༭��ť�¼�
10880 function sf_editTotalTimeCancelHandler() {
10881 target.limitTimeMonth(sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue'));
10882 target.viewEditTotalTime(false);
10883 }
10884 // �ײ�ʱ���༭��ť�¼�
10885 function sf_editTotalTimeHandler() {
10886 sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue', target.limitTimeMonth());
10887 target.viewEditTotalTime(true);
10888 }
10889 // �ײ�ʱ�䱣���༭��ť�¼�
10890 function sf_editTotalTimeSaveHandler() {
10891 if (sv_trafficStaticalInfo.getEle('limitTimeMonth').valid()) {
10892 target.viewEditTotalTime(false);
10893 }
10894 }
10895
10896 // ��������ȡ���༭��ť�¼�
10897 function sf_editUsedDataCancelHandler() {
10898 target.dataUsed(sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue'));
10899 target.selectedDataUsedUnit(sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue'));
10900 sv_trafficStaticalInfo.getEle('editUsedDataCancel').siblings('label.error').hide();
10901 target.viewEditUsedData(false);
10902 }
10903 // ���������༭��ť�¼�
10904 function sf_editUsedDataHandler() {
10905 sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue', target.dataUsed());
10906 sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue', target.selectedDataUsedUnit());
10907 target.dataUsed(target.dataUsed());
10908 target.viewEditUsedData(true);
10909 }
10910 // �����������水ť�¼�
10911 function sf_editUsedDataSaveHandler() {
10912 if (sv_trafficStaticalInfo.getEle('dataUsed').valid()) {
10913 sv_usedDataModified = true;
10914 target.viewEditUsedData(false);
10915 }
10916 }
10917 // ����ʱ��ȡ���༭��ť�¼�
10918 function sf_editUsedTimeCancelHandler() {
10919 target.usedTime(sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue'));
10920 target.viewEditUsedTime(false);
10921 }
10922 // ����ʱ���༭��ť�¼�
10923 function sf_editUsedTimeHandler() {
10924 sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue', target.usedTime());
10925 target.viewEditUsedTime(true);
10926 }
10927
10928 // ����ʱ�䱣���༭��ť�¼�
10929 function sf_editUsedTimeSaveHandler() {
10930 if (sv_trafficStaticalInfo.getEle('usedTime').valid()) {
10931 target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
10932 target.viewEditUsedTime(false);
10933 sv_usedTimeModified = true;
10934 }
10935 }
10936
10937 // ʣ������������
10938 function sf_leftDataDesc() {
10939 var s_left = (target.limitDataMonth() * target.selectedDataUnit() - target.dataUsed() * target.selectedDataUsedUnit()) * 1048576;
10940 if(s_left < 0) {
10941 s_left = 0;
10942 }
10943
10944 if(isNaN(s_left)) {
10945 target.leftDataDescData('');
10946 return $.i18n.prop('traffic_data_left_text', ' ');
10947 }
10948
10949 target.leftDataDescData(transUnit(s_left, false));
10950 return $.i18n.prop('traffic_data_left_text', transUnit(s_left, false));
10951 }
10952 //ʣ��ʱ��������
10953 function sf_leftTimeDesc() {
10954 var s_surplus = target.limitTimeMonth() * target.selectedTimeUnit() - sv_trafficStaticalInfo.getTrafficTimeToSeconds(target.monthlyConnectedTime());
10955 if(s_surplus < 0) {
10956 s_surplus = 0;
10957 }
10958
10959 if(isNaN(s_surplus)) {
10960 target.leftTimeDescData(' ');
10961 return $.i18n.prop('traffic_data_left_text', ' ');
10962 }
10963 target.leftTimeDescData(transSecond2Time(s_surplus));
10964 return $.i18n.prop('traffic_data_left_text', transSecond2Time(s_surplus));
10965 }
10966 // �ײ�����������
10967 function sf_limitDataMonthDesc() {
10968 if(isNaN(target.limitDataMonth())) {
10969 target.limitDataMonthDescData("");
10970 return $.i18n.prop('traffic_limit_data_text', ' ');
10971 }else{
10972 // todo
10973 }
10974
10975 target.limitDataMonthDescData(target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
10976 return $.i18n.prop('traffic_limit_data_text', target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
10977 }
10978 // �ײ�ʱ��������
10979 function sf_limitTimeMonthDesc() {
10980 if(isNaN(target.limitTimeMonth())) {
10981 target.limitTimeMonthDescData(' ');
10982 target.limitTimeMonthDescText('traffic_limit_time_h');
10983 return $.i18n.prop('traffic_limit_time_h', ' ');
10984 }else{
10985 // todo:
10986 }
10987
10988 target.limitTimeMonthDescData(target.limitTimeMonth());
10989
10990 if(target.selectedTimeUnit() == "60"){
10991 target.limitTimeMonthDescText('traffic_limit_time_m');
10992 return $.i18n.prop('traffic_limit_time_m', target.limitTimeMonth());
10993 }else{
10994 target.limitTimeMonthDescText('traffic_limit_time_h');
10995 return $.i18n.prop('traffic_limit_time_h', target.limitTimeMonth());
10996 }
10997 }
10998
10999 // Ӧ�ð�ť�¼�
11000 function sf_save() {
11001 if (sv_trafficStaticalInfo.isFormEditable(target) && target.dataLimitChecked() == '1') {
11002 return false;
11003 }
11004
11005 if (target.selectedDataUnit() == '1' && target.selectedDataUsedUnit() == '1048576' && target.dataLimitTypeChecked() == "1" && target.dataLimitChecked() == '1' && !(parseInt(target.dataUsed(), 10) < parseInt('4096', 10)) ) {
11006 showAlert('traffic_over_note');
11007 return false;
11008 }
11009
11010 showLoading();
11011 service.setTrafficAlertInfo({
11012 alertDataReach: parseInt(target.alertDataReach(), 10),
11013 alertTimeReach: parseInt(target.alertTimeReach(), 10),
11014 dataLimitChecked: target.dataLimitChecked(),
11015 dataLimitTypeChecked: target.dataLimitTypeChecked(),
11016 limitDataMonth: target.limitDataMonth() + "_" + target.selectedDataUnit(),
11017 limitTimeMonth: target.selectedTimeUnit() == "60" ? target.limitTimeMonth()/60 : target.limitTimeMonth()//save by hours
11018 }, function (data) {
11019 if (data.result == 'success') {
11020 if(target.dataLimitTypeChecked() == "1" && sv_usedDataModified) {
11021 target.saveUsedData();
11022 } else if(target.dataLimitTypeChecked() == "0" && sv_usedTimeModified) {
11023 target.saveUsedTime();
11024 } else {
11025 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11026 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11027 status.setTrafficAlertPopuped(false);
11028 successOverlay();
11029 }
11030 } else {
11031 errorOverlay();
11032 }
11033 }, function () {
11034 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11035 errorOverlay();
11036 });
11037 }
11038
11039 // ����������������
11040 function sf_saveUsedData() {
11041 var val = target.dataUsed() * target.selectedDataUsedUnit();
11042 service.trafficCalibration({
11043 way: 'data',
11044 value: val
11045 }, function(){
11046 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11047 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11048 successOverlay();
11049 target.viewEditUsedData(false);
11050 status.setTrafficAlertPopuped(false);
11051 sv_usedDataModified = false;
11052 }, function(){
11053 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11054 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11055 errorOverlay();
11056 });
11057 }
11058
11059
11060
11061 function sf_saveUsedTime() {
11062 service.trafficCalibration({
11063 way: 'time',
11064 value: target.selectedTimeUsedUnit() == "60" ? parseFloat(target.usedTime())/60 : target.usedTime()
11065 }, function(){
11066 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11067 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11068 successOverlay();
11069 target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
11070 target.viewEditUsedTime(false);
11071 status.setTrafficAlertPopuped(false);
11072 sv_usedTimeModified = false;
11073 }, function(){
11074 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11075 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11076 errorOverlay();
11077 });
11078 }
11079
11080
11081 // ��������������
11082 function sf_usedDataTextDesc() {
11083 if(isNaN(target.dataUsed())) {
11084 target.usedDataTextDescData("");
11085 return $.i18n.prop('traffic_used_text', ' ');
11086 }
11087 target.usedDataTextDescData(target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
11088 return $.i18n.prop('traffic_used_text', target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
11089 }
11090 // ����ʱ��������
11091 function sf_usedTimeTextDesc() {
11092 target.usedTimeTextDescData(target.monthlyConnectedTime());
11093 return $.i18n.prop('traffic_used_text', target.monthlyConnectedTime());
11094 }
11095
11096
11097 }
11098
11099 function init() {
11100 sv_trafficGraph = echarts.init($("#traffic_graphic")[0]);
11101 window.onresize = sv_trafficGraph.resize;
11102 var s_container = $('#container');
11103 ko.cleanNode(s_container[0]);
11104 var fwVm = new trafficViewModel();
11105 ko.applyBindings(fwVm, s_container[0]);
11106 $('#trafficAlertForm').validate({
11107 submitHandler: function () {
11108 fwVm.save();
11109 },
11110
11111
11112 errorPlacement: function (error, para) {
11113 if (para.attr("name") == "alertDataReach") {
11114 error.insertAfter("#editAlertDataDiv");
11115 } else if (para.attr("name") == "alertTimeReach") {
11116 error.insertAfter("#editAlertTimeDiv");
11117 } else if (para.attr("name") == "dataUsed") {
11118 error.insertAfter("#editUsedDataDiv");
11119 } else if (para.attr("name") == "limitDataMonth") {
11120 error.insertAfter("#editTotalDataDiv");
11121 } else if (para.attr("name") == "limitTimeMonth") {
11122 error.insertAfter("#editTotalTimeDiv");
11123 } else if (para.attr("name") == "usedTime") {
11124 error.insertAfter("#editUsedTimeDiv");
11125 } else {
11126 error.insertAfter(para);
11127 }
11128 },
11129
11130 rules: {
11131 alertDataReach: {
11132 range: [ 1, 100 ],
11133 digits: true
11134 },
11135 alertTimeReach: {
11136 range: [ 1, 100 ],
11137 digits: true
11138 },
11139 dataUsed: {
11140 range : [ 0, 9999 ],
11141 decimalRange : true
11142 },
11143 limitDataMonth: {
11144 range : [ 1, 9999 ],
11145 decimalRange : true
11146 },
11147 limitTimeMonth: {
11148 range : [ 1, 9999 ],
11149 decimalRange : true
11150 },
11151 usedTime: {
11152 range : [ 0, 9999 ],
11153 decimalRange : true
11154 }
11155 }
11156
11157 });
11158
11159 var sv_originalLan = window.language;
11160 window.setInterval(function(){
11161 if(sv_originalLan != window.language){
11162 sv_originalLan = window.language;
11163 sv_trafficStaticalInfo.refreshFlowDiagramInfo(fwVm);
11164 }
11165 }, 1000);
11166
11167 }
11168
11169 return {
11170 init: init
11171 };
11172});
11173
11174// ״̬����ʾ��ʵ��
11175define("tooltip",[ "jquery" ],
11176
11177 function($) {
11178
11179
11180 // ����Ԫ��λ����Ϣ
11181 // @method calculatePositionInfo
11182 // @param trigger Ԫ��
11183 // @param tooltip ״̬��
11184 // @param {JSON} config �����
11185
11186 function calculatePositionInfo(trigger, tooltip, config) {
11187 var top = trigger.offset().top;
11188 var left = trigger.offset().left;
11189 var position = config.position[0];
11190 var height = tooltip.outerHeight() + trigger.outerHeight();
11191 var width = tooltip.outerWidth() + trigger.outerWidth();
11192
11193 top -= tooltip.outerHeight() - config.offset[0];
11194 left += trigger.outerWidth() + config.offset[1];
11195
11196 if (/iPad/i.test(navigator.userAgent)) {
11197 top -= $(window).scrollTop();
11198 }
11199
11200 if (position == 'center') {
11201 top += height / 2;
11202 }
11203 if (position == 'bottom') {
11204 top += height;
11205 }
11206 position = config.position[1];
11207 if (position == 'center') {
11208 left -= width / 2;
11209 }else if (position == 'left') {
11210 left -= width;
11211 }
11212
11213 return {
11214 top : top,
11215 left : left
11216 };
11217 }
11218
11219 // ״̬����ʼ��
11220 function init() {
11221
11222 $(".statusItem", "#statusBar").each(function(i, n){
11223 var $this = $(this);
11224 $this.attr("tipTitle", $this.attr("title")).removeAttr("title");
11225 }).hover(
11226 function() {
11227 var $this = $(this);
11228 var title = $this.attr("tipTitle");
11229 var tooltip = $("<div>").addClass("tooltip in").appendTo(document.body).hide()
11230 .append($this.attr("i18n") ? $.i18n.prop(title) : title);
11231 if ($this.attr("i18n")) {
11232 tooltip.attr("data-trans", title).attr("id", "tooltip_" + $this.attr("id"));
11233 }
11234 var pos = calculatePositionInfo($this, tooltip, {
11235 position : [ 'bottom', 'center' ],
11236 offset : [ 0, 0 ]
11237 });
11238 tooltip.css({
11239 position : 'absolute',
11240 top : pos.top,
11241 left : pos.left
11242 }).show();
11243 }, function() {
11244 $(".tooltip").hide().remove();
11245 });
11246 }
11247
11248 return {
11249 init : init
11250 };
11251 });
11252
11253define("menu","set service knockout underscore jquery".split(" "),
11254 function (set, fnc, libko, libus, libjq) {
11255 var displayMenuWhenLogout = false;
11256 var vmMenu;
11257 var menu = [];
11258 var menuResource = "";
11259
11260 function menuExistCheck(path) {
11261 for (var i = 0; i < menu.length; i++) {
11262 if (menu[i].path == path) {
11263 return true;
11264 }
11265 }
11266 return false;
11267 }
11268
11269 function getIsLoggedin() {
11270 var loginStatus = fnc.getLoginStatus();
11271 return (loginStatus.status == "loggedIn");
11272 }
11273
11274 function buildNew() {
11275 var loggedIn = getIsLoggedin();
11276 var menuMain = libus.filter(menu, function (param) {
11277 return (param.level == '1' && ((param.requireLogin && loggedIn) || !param.requireLogin) && param.hash != "#entry");
11278 });
11279 vmMenu.menuMain(menuMain);
11280 vmMenu.loggedIn(loggedIn);
11281
11282 getMainWth(vmMenu.menuMain().length);
11283 vmMenu.showMenu(loggedIn || displayMenuWhenLogout);
11284 libjq("#nav").translate();
11285 }
11286
11287 function getMainWth(len) {
11288 var width = 100 / len;
11289 libjq('ul#list-nav li').each(function () {
11290 libjq(this).css('width', width + '%');
11291 });
11292 }
11293
11294 function menuRefresh() {
11295 var currentHash = window.location.hash;
11296 var itmRoot = libus.find(menu, function (param) {
11297 return param.hash == currentHash;
11298 });
11299 while (itmRoot.parent) {
11300 itmRoot = libus.find(menu, function (param) {
11301 return param.hash == itmRoot.parent;
11302 });
11303 }
11304 if (!itmRoot.parent) {
11305 libjq("#list-nav li").removeClass("active");
11306 var mid = itmRoot.hash.substring(1, itmRoot.hash.length);
11307 libjq("#list-nav li[mid=" + mid + "]").addClass("active");
11308 }
11309 vmMenu.changeMenu(itmRoot);
11310 }
11311
11312 function menuSearch(hashVal) {
11313 hashVal = hashVal || window.location.hash;
11314 var loggedIn = getIsLoggedin();
11315 return libus.filter(menu, function (param) {
11316 return (hashVal == param.hash && ((param.requireLogin && loggedIn) || !param.requireLogin));
11317 });
11318 }
11319
11320 function menuRenderSub(level, baseItem) {
11321 var levelItem = libus.find(menu, function (param) {
11322 return param.parent == baseItem.hash && param.path == baseItem.path;
11323 });
11324 libjq(".menu-" + level + "-level").removeClass("active");
11325 if (levelItem) {
11326 if (level == "two") {
11327 menuRenderSub("three", levelItem);
11328 //forward/backward support
11329 clickMenuTrig(levelItem.hash, level);
11330 }
11331 libjq(".menu-" + level + "-level." + levelItem.hash.substring(1)).addClass("active");
11332 }
11333 }
11334
11335 function menuActSub() {
11336 var currentHash = window.location.hash;
11337 var itmRoot = libus.find(menu, function (param) {
11338 return param.hash == currentHash;
11339 });
11340 if (itmRoot.level == 1) {
11341 menuRenderSub("two", itmRoot);
11342 }
11343 if (itmRoot.level == 2) {
11344 menuRenderSub("three", itmRoot);
11345 //forward/backward support
11346 clickMenuTrig(itmRoot.hash, itmRoot.level);
11347 }
11348 if (itmRoot.level == 3) {
11349 //forward/backward support
11350 clickMenuTrig(itmRoot.parent, itmRoot.level);
11351 libjq(".menu-three-level").removeClass("active");
11352 libjq(".menu-three-level." + itmRoot.hash.substring(1)).addClass("active");
11353 }
11354 }
11355
11356 function clickMenuTrig(hash, level) {
11357 libjqobj = libjq(".menu-two-level." + hash.substring(1));
11358 var levelArr = ['3', 'three', '2', 'two'];
11359 if (libus.indexOf(levelArr, level) != -1 && libjqobj.hasClass('active')) {
11360 return;
11361 }
11362
11363 libjqobj.siblings().removeClass('active');
11364 libjqobj.addClass('active');
11365
11366 libjqobj.siblings().not('.menu-two-level').slideUp();
11367 libjqobj.next().has('ul li').slideDown();
11368 }
11369
11370 set.blc_wan_mode = fnc.getOpMode().blc_wan_mode;
11371 if (!set.RJ45_SUPPORT) {
11372 menuResource = "menu";
11373 } else {
11374 switch (set.blc_wan_mode) {
11375 case "PPPOE":
11376 case "AUTO_PPPOE":
11377 menuResource = "menu_pppoe";
11378 break;
11379 default:
11380 menuResource = "menu";
11381 break;
11382 }
11383 }
11384
11385 require([set.DEVICE + '/' + menuResource], function (otherMenu) {
11386 menu = otherMenu;
11387 if (set.SD_CARD_SUPPORT) {
11388 menu = menu.concat([{ hash: '#httpshare_guest', path: 'sd_httpshare', level: '', requireLogin: false, checkSIMStatus: false},
11389 { hash: '#sdcard', path: 'sd', level: '', requireLogin: true, checkSIMStatus: false},
11390 { hash: '#httpshare', path: 'sd_httpshare', level: '', requireLogin: true, checkSIMStatus: false}]);
11391 }
11392 });
11393
11394 function initialize() {
11395 vmMenu = new Menu_vm();
11396 }
11397
11398 function Menu_vm() {
11399 var loginState = getIsLoggedin();
11400 var target = this;
11401 target.loggedIn = libko.observable(loginState);
11402
11403 target.showMenu = libko.observable(loginState || displayMenuWhenLogout);
11404
11405 var menuMain = libus.filter(menu, function (param) {
11406 return (param.level == '1' && ((param.requireLogin && target.loggedIn()) || !param.requireLogin) && param.hash != "#entry");
11407 });
11408
11409 target.menuMain = libko.observableArray(menuMain);
11410 target.secondMenu = libko.observableArray([]);
11411 //target.curThirdMenu; cov_2
11412 target.changeMenu = function (data) {
11413 var secondMenu = getSubMenu(data);
11414 if (secondMenu.length == 0) {
11415 libjq("#container").addClass("fixContainerWidth");
11416 } else {
11417 libjq("#container").removeClass("fixContainerWidth");
11418 }
11419
11420 target.secondMenu(secondMenu);
11421 return true;
11422 };
11423 target.thirdMenu = function () {
11424 return target.curThirdMenu;
11425 };
11426 target.getThirdMenu = function (data) {
11427 target.curThirdMenu = getSubMenu(data);
11428 };
11429 function getSubMenu(data) {
11430 return libus.filter(menu, function (param) {
11431 return ((param.parent && param.parent == data.hash) && ((param.requireLogin && target.loggedIn()) || !param.requireLogin));
11432 });
11433 }
11434 }
11435
11436 return {
11437 activeSubMenu: menuActSub,
11438 checkIsMenuExist: menuExistCheck,
11439 findMenu: menuSearch,
11440 rebuild: buildNew,
11441 refreshMenu: menuRefresh,
11442 init: initialize
11443 };
11444});