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