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