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