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