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