blob: aa2213686691c59f38e786cdbeecbebb22de3bf3 [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";
w.dengf2f56832025-08-06 14:49:13 +08007102 location.reload();
you.chen808f8ef2025-04-02 13:58:10 +08007103 }
7104 else {
7105 errorOverlay();
7106 }
7107 }
7108
7109 // �任����ʱ����
7110 function sf_changeStep(i_step) {
7111 if (i_step > sv_maxStep) {
7112 i_step = sv_maxStep;
7113 } else if (i_step < sv_minStep) {
7114 i_step = sv_minStep;
7115 }
7116
7117 target.currentStep(i_step);
7118 return true;
7119 }
7120
7121 function sf_ipv6_selectedAuthMode_display() {
7122 var mode = target.ipv6_selectedAuthMode();
7123 return sf_getAuthModeNameByValue(mode);
7124 }
7125 // ���ݼ�Ȩģʽ��ֵ��������
7126 function sf_getAuthModeNameByValue(authMode) {
7127 for (var i = 0; i < config.APN_AUTH_MODES.length; i++) {
7128 if (authMode == config.APN_AUTH_MODES[i].value) {
7129 return config.APN_AUTH_MODES[i].name;
7130 }
7131 }
7132 }
7133
7134 function sf_getWepPassword(){
7135 return target.keyID() == '3' ? sv_quickSettingInfo.Key4Str1 : (target.keyID() == '2' ? sv_quickSettingInfo.Key3Str1 : target.keyID() == '1' ? sv_quickSettingInfo.Key2Str1 : sv_quickSettingInfo.Key1Str1);
7136 }
7137
7138 function sf_isDisabled_Wifi() {
7139 var s_wpsInfo = service.getWpsInfo();
7140 if(s_wpsInfo.radioFlag == "0"){
7141 return sv_wifiState.wifi_off;
7142 }else if (s_wpsInfo.wpsFlag == '1') {
7143 return sv_wifiState.wps_on;
7144 }
7145 return sv_wifiState.ok;
7146 }
7147 function sf_profileChangeHandler(i_data, i_event) {
7148 $("#pwdWepKey").parent().find("label[class='error']").hide();
7149 target.wepPassword(target.getWepPassword());
7150 return true;
7151 }
7152
7153 // ���������ύ(֧��IPv6��
7154 function sf_quickSetting4IPv6() {
7155 showLoading();
7156 var useIPv4ForV6 = config.IPV4V6_SUPPORT && target.currAPN().pdp_type == "IPv4v6";
7157
7158 var ciphertext = "";
7159 if (config.PASSWORD_ENCODE) {
7160 ciphertext = target.WPAKey();
7161 } else {
7162 var kparam = service.getDeviceInfoLow();
7163 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
7164 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
7165 ciphertext = CryptoJS.AES.encrypt(target.WPAKey(), tkey, {
7166 iv: tiv,
7167 mode: CryptoJS.mode.CBC,
7168 padding: CryptoJS.pad.ZeroPadding
7169 }).toString();
7170 }
7171
7172 var s_quickSettingParameters = {
7173 apn_index: sv_quickSettingInfo.apn_index,
7174 apnMode: target.apnMode(),
7175 Encryption_Mode_hid: target.selectedSecurityMode(),
7176 ipv6_ppp_auth_mode: useIPv4ForV6 ? target.selectedAuthMode() : target.ipv6_selectedAuthMode(),
7177 ipv6_ppp_username: useIPv4ForV6 ? target.username() : target.ipv6_username(),
7178 ipv6_ppp_passtmp: useIPv4ForV6 ? target.password() : target.ipv6_password(),
7179 ipv6_wan_apn: useIPv4ForV6 ? target.apn() : target.ipv6_apn(),
7180 pdp_type: target.ipType(),
7181 ppp_auth_mode: target.selectedAuthMode(),
7182 ppp_username: target.username(),
7183 ppp_passtmp: target.password(),
7184 profile_name: target.profileName(),
7185 //Ŀǰ����ģʽֻ��2�֣�����3������Ϊ�̶�ֵ
7186 //������Ҫ����Ϊ5�֣�����ֵ��Ҫ����
7187 security_shared_mode: "NONE",
7188 SSID_Broadcast: target.broadcast(),
7189 SSID_name: target.ssid(),
7190 wan_apn: target.apn(),
7191 wep_default_key: 0,
7192 WPA_ENCRYPTION_hid: target.selectedSecurityMode() == "OPEN" ? "NONE" : target.selectedSecurityMode() == "WPA2PSK" ? 1 : 2,
7193 WPA_PreShared_Key: ciphertext
7194 }
7195
7196 s_quickSettingParameters.wep_default_key = target.keyID();
7197
7198 if(target.encryptType() == "SHARED" || target.selectedSecurityMode() == "WEP") {
7199
7200 s_quickSettingParameters.security_shared_mode = "WEP";
7201
7202 s_quickSettingParameters.wep_key_1 = sv_quickSettingInfo.Key1Str1;
7203 s_quickSettingParameters.wep_key_2 = sv_quickSettingInfo.Key2Str1;
7204 s_quickSettingParameters.wep_key_3 = sv_quickSettingInfo.Key3Str1;
7205 s_quickSettingParameters.wep_key_4 = sv_quickSettingInfo.Key4Str1;
7206
7207 var WEPSelectTmp = '0';
7208
7209 if(target.wepPassword().length =='5' ||target.wepPassword().length =='13'){
7210 WEPSelectTmp = '1';
7211 }else{
7212 WEPSelectTmp = '0';
7213 }
7214
7215 if(target.keyID() =='3'){
7216 s_quickSettingParameters.wep_key_4 = target.wepPassword();
7217 s_quickSettingParameters.WEP4Select = WEPSelectTmp;
7218 }else if(target.keyID() =='2'){
7219 s_quickSettingParameters.wep_key_3 = target.wepPassword();
7220 s_quickSettingParameters.WEP3Select = WEPSelectTmp;
7221 }else if(target.keyID() =='1'){
7222 s_quickSettingParameters.wep_key_2 = target.wepPassword();
7223 s_quickSettingParameters.WEP2Select = WEPSelectTmp;
7224 }else{
7225 s_quickSettingParameters.wep_key_1 = target.wepPassword();
7226 s_quickSettingParameters.WEP1Select = WEPSelectTmp;
7227 }
7228 }else if(target.encryptType() == "WPAPSKWPA2PSK") {
7229 s_quickSettingParameters.security_shared_mode = "NONE";
7230 }else {
7231 s_quickSettingParameters.security_shared_mode = "NONE";
7232 }
7233
7234 service.setQuickSetting4IPv6(s_quickSettingParameters, target.callback);
7235 }
7236
7237 function sf_selectedAuthMode_display() {
7238 var mode = target.selectedAuthMode();
7239 return sf_getAuthModeNameByValue(mode);
7240 }
7241
7242 function sf_selectedSecurityMode_trans() {
7243 var mode = target.selectedSecurityMode();
7244 var modesOption = config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES;
7245 for (var i = 0; i < modesOption.length; i++) {
7246 if (mode == modesOption[i].value) {
7247 target.selectedSecurityMode_display($.i18n.prop("security_mode_" + modesOption[i].value));
7248 return "security_mode_" + modesOption[i].value;
7249 }
7250 }
7251 }
7252
7253 function sf_showWifiPasswordHandler(){
7254 $("#pwdWepKey").parent().find(".error").hide();
7255 $("#codeWPAKey").parent().find(".error").hide();
7256 var checkbox = $("#showWifiPassword:checked");
7257 if(checkbox && checkbox.length == 0){
7258 target.showWifiPassword(true);
7259 }else{
7260 target.showWifiPassword(false);
7261 }
7262 }
7263
7264 }
7265
7266 function init() {
7267 var container = $('#container');
7268 ko.cleanNode(container[0]);
7269 var fwVm = new quickSettingViewModel();
7270 ko.applyBindings(fwVm, container[0]);
7271
7272 $('#quickSettingForm').validate({
7273 submitHandler:function () {
7274 if (fwVm.currentStep() < 5) {
7275 fwVm.next();
7276 } else {
7277 fwVm.save();
7278 }
7279 },
7280 rules:{
7281 txtAPN:"apn_check",
7282 txtIPv6APN:"apn_check",
7283 txtSSID:'ssid',
7284 pwdWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
7285 txtWepKey:{wifi_wep_password_check:true,wifi_password_check: true},
7286 txtWPAKey:'wifi_password_check',
7287 codeWPAKey:'wifi_password_check',
7288 txtUserName:'ppp_username_check',
7289 txtIPv6UserName:'ppp_username_check',
7290 txtSecretCode:"ppp_secretcode_check",
7291 txtIPv6SecretCode:"ppp_secretcode_check"
7292 },
7293 errorPlacement:function (error, element) {
7294 var id = element.attr("id");
7295 if (id == "pwdWepKey" || id == "txtWepKey"){
7296 error.insertAfter("#lblShowWepPassword");
7297 } else if (id == "txtWPAKey" || id == "codeWPAKey") {
7298 error.insertAfter("#lblShowWifiPassword");
7299 } else {
7300 error.insertAfter(element);
7301 }
7302 }
7303 });
7304 }
7305
7306 return {
7307 init:init
7308 };
7309 }
7310);
7311
7312define("main","set service knockout underscore jquery statusBar echarts".split(" "), function (set, fnc, libko, libus, libjq, barStat, echarts) {
7313
7314 var chartOptions = {
7315 color: ['red', 'red', 'red', 'red', 'red'],
7316 series: [{
7317 name: '��������',
7318 type: 'pie',
7319 radius: ['0', '72'],
7320 itemStyle: {
7321 normal: {
7322 label: {
7323 show: false
7324 },
7325 labelLine: {
7326 show: false
7327 }
7328 }
7329 },
7330 data: [],
7331 selectedOffset: 3
7332 }
7333 ],
7334 animation: false,
7335 title: {
7336 text: '',
7337 x: 'center',
7338 y: 'center',
7339 itemGap: 0,
7340 textStyle: {
7341 color: '#FFF',
7342 fontFamily: '΢���ź�',
7343 fontSize: 20,
7344 fontWeight: 'bolder'
7345 },
7346 subtextStyle: {
7347 color: '#FFF',
7348 fontFamily: '΢���ź�',
7349 fontSize: 16,
7350 fontWeight: 'bolder'
7351 }
7352 },
7353 tooltip: {
7354 formatter: "{b}"
7355 },
7356 };
7357 var languageOld = window.language;
7358 var num_refresh = 0;
7359 var traffic_graphic_chart = null;
7360 var connStat = {
7361 CONNECTED: 1,
7362 DISCONNECTED: 2,
7363 CONNECTING: 3,
7364 DISCONNECTING: 4
7365 };
7366 function init() {
7367 num_refresh = 0;
7368 homeUtil.oldUsedData = null;
7369 homeUtil.oldAlarmData = null;
7370 traffic_graphic_chart = echarts.init(libjq("#traffic_graphic")[0]);
7371 var container = libjq('#container')[0];
7372 libko.cleanNode(container);
7373 var tmp = new VmHome();
7374 libko.applyBindings(tmp, container);
7375 var data = fnc.getLoginData();
7376 var psw_flg = data.psw_changed;
7377 if (psw_flg != "1") {
7378 showConfirm("password_note_first_change", function () {
7379 window.location.hash = '#pwd_mode';
7380 });
7381 return;
7382 }
7383 }
7384
7385 var homeUtil = {
7386 initStatus: null,
7387 initShownStatus: function (data) {
7388 this.initStatus = {};
7389 var ipv6Mode = data.ipv6PdpType.toLowerCase().indexOf("v6") > 0;
7390 if (set.RJ45_SUPPORT) {
7391 var mode = checkCableMode(data.blc_wan_mode);
7392 if (mode) {
7393 this.initStatus.showIpv6WanIpAddr = false;
7394 this.initStatus.showIpv4WanIpAddr = true;
7395 } else if (set.IPV6_SUPPORT) {
7396 if (data.pdpType == "IP") {
7397 this.initStatus.showIpv6WanIpAddr = false;
7398 this.initStatus.showIpv4WanIpAddr = true;
7399 } else if (ipv6Mode) {
7400 if (data.ipv6PdpType == "IPv6") {
7401 this.initStatus.showIpv6WanIpAddr = true;
7402 this.initStatus.showIpv4WanIpAddr = false;
7403 } else {
7404 this.initStatus.showIpv6WanIpAddr = true;
7405 this.initStatus.showIpv4WanIpAddr = true;
7406 }
7407 }
7408 } else {
7409 this.initStatus.showIpv6WanIpAddr = false;
7410 this.initStatus.showIpv4WanIpAddr = true;
7411 }
7412 } else {
7413 if (set.IPV6_SUPPORT) {
7414 if (data.pdpType == "IP") {
7415 this.initStatus.showIpv6WanIpAddr = false;
7416 this.initStatus.showIpv4WanIpAddr = true;
7417 } else if (ipv6Mode) {
7418 if (data.ipv6PdpType == "IPv6") {
7419 this.initStatus.showIpv6WanIpAddr = true;
7420 this.initStatus.showIpv4WanIpAddr = false;
7421 } else {
7422 this.initStatus.showIpv6WanIpAddr = true;
7423 this.initStatus.showIpv4WanIpAddr = true;
7424 }
7425 }
7426 } else {
7427 this.initStatus.showIpv6WanIpAddr = false;
7428 this.initStatus.showIpv4WanIpAddr = true;
7429 }
7430 }
7431 },
7432 wanIpGet: function (data) {
7433 var addrInfo = {
7434 wanIpAddress: '',
7435 ipv6WanIpAddress: ''
7436 };
7437 addrInfo.wanIpAddress = verifyDeviceInfo(data.wanIpAddress);
7438 addrInfo.ipv6WanIpAddress = verifyDeviceInfo(data.ipv6WanIpAddress);
7439 return addrInfo;
7440 },
7441 cachedAPStationBasic: null,
7442 cachedConnectionMode: null,
7443 getCanConnectNetWork: function (param) {
7444 var status = fnc.getStatusInfo();
7445 if (status.simStatus != "modem_init_complete") {
7446 return false;
7447 }
7448 var typeNetworkTmp = status.networkType.toLowerCase();
7449 if (typeNetworkTmp == 'searching') {
7450 return false;
7451 }
7452 if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
7453 typeNetworkTmp = 'limited_service';
7454 }
7455 if (typeNetworkTmp == 'no service') {
7456 typeNetworkTmp = 'no_service';
7457 }
7458 if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
7459 if (param.cStatus() != connStat.CONNECTED) {
7460 return false;
7461 }
7462 }
7463 if (set.AP_STATION_SUPPORT) {
7464 if (status.connectWifiStatus == "connect") {
7465 if (status.ap_station_mode == "wifi_pref") {
7466 return false;
7467 }
7468 }
7469 }
7470 return true;
7471 },
7472 doConnect: function () {
7473 showLoading('connecting');
7474 fnc.connect({}, function (data) {
7475 if (data.result) {
7476 successOverlay();
7477 } else {
7478 errorOverlay();
7479 }
7480 });
7481 },
7482 refreshHomeData: function (param) {
7483 var info = fnc.getConnectionInfo();
7484 param.connectStatus(info.connectStatus);
7485 param.canConnect(this.getCanConnectNetWork(param));
7486 param.networkType(homeUtil.getNetworkType(info.networkType));
7487 if (info.connectStatus == "ppp_connected") {
7488 param.current_Flux(transUnit(parseInt(info.data_counter.currentReceived, 10) + parseInt(info.data_counter.currentSent, 10), false));
7489 param.connected_Time(transSecond2Time(info.data_counter.currentConnectedTime));
7490 param.up_Speed(transUnit(info.data_counter.uploadRate, true));
7491 param.down_Speed(transUnit(info.data_counter.downloadRate, true));
7492 } else {
7493 param.current_Flux(transUnit(0, false));
7494 param.connected_Time(transSecond2Time(0));
7495 param.up_Speed(transUnit(0, true));
7496 param.down_Speed(transUnit(0, true));
7497 }
7498 param.trafficAlertEnable(info.limitVolumeEnable);
7499 if (info.limitVolumeEnable) {
7500 if (info.limitVolumeType == '1') {
7501 param.trafficUsed(transUnit(parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10), false));
7502 param.trafficLimited(transUnit(info.limitDataMonth, false));
7503 } else {
7504 param.trafficUsed(transSecond2Time(info.data_counter.monthlyConnectedTime));
7505 param.trafficLimited(transSecond2Time(info.limitTimeMonth));
7506 }
7507 }
7508 if (languageOld != window.language) {
7509 languageOld = window.language;
7510 num_refresh = 1;
7511 }
7512 if (param.showTraffic()) {
7513 homeUtil.updateEcharts(info);
7514 } else {
7515 homeUtil.allFreeEcharts();
7516 }
7517 homeUtil.refreshStationInfo(param);
7518 },
7519 allFreeEcharts: function () {
7520 var usedData = homeUtil.data.free;
7521 usedData.value = 1;
7522 usedData.selected = false;
7523 usedData.name = libjq.i18n.prop("echarts_no");
7524 chartOptions.series[0].data = [usedData];
7525 chartOptions.title.text = '';
7526 homeUtil.setEcharts(chartOptions, libjq.i18n.prop("echarts_no"));
7527 },
7528 getNetworkType: function (networkType) {
7529 var typeNetworkTmp = networkType.toLowerCase();
7530 if (typeNetworkTmp == '' || typeNetworkTmp == 'limited service') {
7531 typeNetworkTmp = 'limited_service';
7532 }
7533 if (typeNetworkTmp == 'no service') {
7534 typeNetworkTmp = 'no_service';
7535 }
7536 if (typeNetworkTmp == 'limited_service' || typeNetworkTmp == 'no_service') {
7537 return libjq.i18n.prop("network_type_" + typeNetworkTmp);
7538 } else {
7539 return networkType;
7540 }
7541 },
7542 data: {
7543 full: {
7544 value: 30,
7545 name: '��������',
7546 itemStyle: {
7547 normal: {
7548 color: '#DF4313'
7549 }
7550 }
7551 },
7552 used: {
7553 value: 30,
7554 name: '��ʹ��',
7555 itemStyle: {
7556 normal: {
7557 color: '#8CC916'
7558 }
7559 }
7560 },
7561 left1: {
7562 value: 50,
7563 name: '����ֵ��δʹ��',
7564 itemStyle: {
7565 normal: {
7566 color: '#D8D8D8'
7567 }
7568 }
7569 },
7570 free: {
7571 value: 50,
7572 name: 'δʹ��',
7573 itemStyle: {
7574 normal: {
7575 color: '#D8D8D8'
7576 }
7577 }
7578 },
7579 alert: {
7580 value: 1,
7581 name: '����ֵ',
7582 itemStyle: {
7583 normal: {
7584 color: '#FF5500'
7585 }
7586 }
7587 },
7588 alarm: {
7589 value: 19.7,
7590 name: '������',
7591 itemStyle: {
7592 normal: {
7593 color: '#8CC916'
7594 }
7595 }
7596 },
7597 start: {
7598 value: 50,
7599 name: '����ֵ��δʹ��',
7600 itemStyle: {
7601 normal: {
7602 color: '#D8D8D8'
7603 }
7604 }
7605 },
7606 },
7607 getDataInfo: function (value) {
7608 return {
7609 data: /\d+(.\d+)?/.exec(value)[0],
7610 unit: /[A-Z]{1,2}/.exec(value)[0]
7611 }
7612 },
7613 oldAlarmData: null,
7614 oldUsedData: null,
7615 updateEcharts: function (info) {
7616 var startName = libjq.i18n.prop("echarts_no");
7617 num_refresh++;
7618 if (num_refresh % 10 != 2) {
7619 return false;
7620 }
7621 var total = 0,
7622 used = 0,
7623 reach = 0,
7624 left = 0,
7625 alarm = 0,
7626 left1 = 0;
7627 if (info.limitVolumeEnable) {
7628 startName = libjq.i18n.prop("echarts_used");
7629 chartOptions.series[0].data = [];
7630 if (info.limitVolumeType == '1') {
7631 var limitedDataFormatted = transUnit(info.limitDataMonth, false);
7632 chartOptions.series[0].data = [];
7633 if (info.limitDataMonth == 0) {
7634 var usedData = homeUtil.data.used;
7635 usedData.value = 1;
7636 usedData.selected = false;
7637 usedData.name = libjq.i18n.prop("echarts_used");
7638 chartOptions.series[0].data.push(usedData);
7639 } else {
7640 var dataInfo = homeUtil.getDataInfo(limitedDataFormatted);
7641 total = dataInfo.data * homeUtil.getUnitValue(dataInfo.unit) * 1048576;
7642 used = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
7643 reach = total * info.limitVolumePercent / 100;
7644 if (used >= total) {
7645 var fullData = homeUtil.data.full;
7646 fullData.value = 100;
7647 fullData.name = libjq.i18n.prop("echarts_full");
7648 chartOptions.series[0].data.push(fullData);
7649 startName = libjq.i18n.prop("echarts_full");
7650 } else {
7651 if (reach - used > 0) {
7652 left1 = reach - used;
7653 left = total - reach;
7654 } else {
7655 alarm = used - reach;
7656 left = total - used;
7657 }
7658 var usedData = homeUtil.data.used;
7659 if (reach - used > 0) {
7660 usedData.value = used;
7661 } else {
7662 usedData.value = reach;
7663 }
7664 usedData.name = libjq.i18n.prop("echarts_used");
7665 chartOptions.series[0].data.push(usedData);
7666 if (left1 > 0) {
7667 var left1Data = homeUtil.data.left1;
7668 left1Data.value = left1;
7669 left1Data.name = libjq.i18n.prop("echarts_left1");
7670 chartOptions.series[0].data.push(left1Data);
7671 }
7672 var alertData = homeUtil.data.alert;
7673 alertData.value = total / 200;
7674 alertData.name = libjq.i18n.prop("echarts_alert");
7675 chartOptions.series[0].data.push(alertData);
7676 if (alarm > 0) {
7677 var alarmData = homeUtil.data.alarm;
7678 alarmData.value = alarm;
7679 alarmData.name = libjq.i18n.prop("echarts_alarm");
7680 chartOptions.series[0].data.push(alarmData);
7681 }
7682 var freeData = homeUtil.data.free;
7683 freeData.value = left;
7684 freeData.name = libjq.i18n.prop("echarts_free");
7685 chartOptions.series[0].data.push(freeData);
7686 }
7687 }
7688 } else {
7689 chartOptions.series[0].data = [];
7690 if (info.limitTimeMonth == 0) {
7691 var usedData = homeUtil.data.used;
7692 usedData.value = 1;
7693 usedData.selected = false;
7694 usedData.name = libjq.i18n.prop("echarts_used");
7695 chartOptions.series[0].data.push(usedData);
7696 } else {
7697 total = info.limitTimeMonth;
7698 used = info.data_counter.monthlyConnectedTime;
7699 reach = total * info.limitVolumePercent / 100;
7700 if (used >= total) {
7701 var fullTime = homeUtil.data.full;
7702 fullTime.value = 100;
7703 fullTime.name = libjq.i18n.prop("echarts_full");
7704 chartOptions.series[0].data.push(fullTime);
7705 startName = libjq.i18n.prop("echarts_full");
7706 } else {
7707 if (reach - used > 0) {
7708 left1 = reach - used;
7709 left = total - reach;
7710 } else {
7711 alarm = used - reach;
7712 left = total - used;
7713 }
7714 var usedTime = homeUtil.data.used;
7715 if (reach - used > 0) {
7716 usedTime.value = used;
7717 } else {
7718 usedTime.value = reach;
7719 }
7720 usedTime.name = libjq.i18n.prop("echarts_used");
7721 chartOptions.series[0].data.push(usedTime);
7722 if (left1 > 0) {
7723 var left1Time = homeUtil.data.left1;
7724 left1Time.value = left1;
7725 left1Time.name = libjq.i18n.prop("echarts_left1");
7726 chartOptions.series[0].data.push(left1Time);
7727 }
7728 var alertTime = homeUtil.data.alert;
7729 alertTime.value = total / 200;
7730 alertTime.name = libjq.i18n.prop("echarts_alert");
7731 chartOptions.series[0].data.push(alertTime);
7732 if (alarm > 0) {
7733 var alarmTime = homeUtil.data.alarm;
7734 alarmTime.value = alarm;
7735 alarmTime.name = libjq.i18n.prop("echarts_alarm");
7736 chartOptions.series[0].data.push(alarmTime);
7737 }
7738 var freeTime = homeUtil.data.free;
7739 freeTime.value = left;
7740 freeTime.name = libjq.i18n.prop("echarts_free");
7741 chartOptions.series[0].data.push(freeTime);
7742 }
7743 }
7744 }
7745 } else {
7746 var usedData = homeUtil.data.used;
7747 usedData.value = 1;
7748 usedData.selected = false;
7749 usedData.name = libjq.i18n.prop("echarts_no");
7750 chartOptions.series[0].data = [usedData];
7751 chartOptions.title.text = '';
7752 }
7753 var firstEle = libus.find(chartOptions.series[0].data, function (n) {
7754 return n.name == libjq.i18n.prop("echarts_used");
7755 });
7756 var alarmEle = libus.find(chartOptions.series[0].data, function (n) {
7757 return n.name == libjq.i18n.prop("echarts_alarm");
7758 });
7759 if (!alarmEle) {
7760 alarmEle = {
7761 value: 0
7762 };
7763 }
7764 if (typeof firstEle == "undefined") {
7765 homeUtil.setEcharts(chartOptions, startName);
7766 } else if (homeUtil.oldUsedData != firstEle.value || homeUtil.oldAlarmData != alarmEle.value) {
7767 homeUtil.oldUsedData = firstEle.value;
7768 homeUtil.oldAlarmData = alarmEle.value;
7769 homeUtil.setEcharts(chartOptions, startName);
7770 }
7771 },
7772 getUnitValue: function (unit) {
7773 unit = unit.toUpperCase();
7774 if (unit == 'GB') {
7775 return '1024';
7776 } else if (unit == 'TB') {
7777 return '1048576';
7778 } else {
7779 return '1';
7780 }
7781 },
7782 setEcharts: function (options, startName) {
7783 var startPart = homeUtil.data.start;
7784 startPart.value = 0;
7785 startPart.name = startName;
7786 startPart.selected = false;
7787 var arr = [startPart].concat(options.series[0].data);
7788 options.series[0].data = arr;
7789 traffic_graphic_chart.setOption(options, true);
7790 addTimeout(function () {
7791 traffic_graphic_chart.resize();
7792 }, 1000);
7793 },
7794 refreshStationInfo: function (param) {
7795 param.wirelessDeviceNum(fnc.getStatusInfo().wirelessDeviceNum);
7796 if (num_refresh % 10 == 2) {
7797 fnc.getAttachedCableDevices({}, function (data) {
7798 param.wireDeviceNum(data.attachedDevices.length);
7799 });
7800 }
7801 },
7802 getUnit: function (val) {
7803 if (val == '1024') {
7804 return 'GB';
7805 } else if (val == '1048576') {
7806 return 'TB';
7807 } else {
7808 return 'MB';
7809 }
7810 },
7811 refreshOpmodeInfo: function (param) {
7812 var obj = fnc.getOpMode();
7813 param.isLoggedIn(obj.loginfo == "ok");
7814 var currentMode = checkCableMode(obj.blc_wan_mode);
7815 if (param.opCurMode() && !currentMode) {
7816 var data = fnc.getLoginData();
7817 var state = data.modem_main_state;
7818 if (state == "modem_sim_undetected" || state == "modem_undetected" || state == "modem_sim_destroy" || state == "modem_waitpin" || state == "modem_waitpuk" || state == "modem_imsi_waitnck") {
7819 window.location.reload();
7820 return;
7821 }
7822 }
7823 param.opCurMode(currentMode);
7824 if (currentMode && obj.ethwan_mode == "DHCP") {
7825 param.enableFlag(false);
7826 } else if ((!currentMode && obj.ppp_status != "ppp_disconnected") || (currentMode && obj.rj45_state != "idle" && obj.rj45_state != "dead")) {
7827 param.enableFlag(true);
7828 } else {
7829 param.enableFlag(false);
7830 }
7831 var mode = (obj.blc_wan_mode == "AUTO_PPP" || obj.blc_wan_mode == "AUTO_PPPOE") ? "AUTO" : obj.blc_wan_mode;
7832 var currentOpMode = "";
7833 switch (mode) {
7834 case "AUTO":
7835 currentOpMode = "opmode_auto";
7836 break;
7837 case "PPPOE":
7838 currentOpMode = "opmode_cable";
7839 break;
7840 case "PPP":
7841 currentOpMode = "opmode_gateway";
7842 break;
7843 default:
7844 break;
7845 }
7846 libjq("#opmode").attr("data-trans", currentOpMode).text(libjq.i18n.prop(currentOpMode));
7847 param.isShowHomeConnect(!currentMode);
7848 param.showTraffic(set.TRAFFIC_SUPPORT && !currentMode);
7849 param.isSupportQuicksetting(set.HAS_QUICK_SETTING && !currentMode);
7850 }
7851 };
7852 function VmHome() {
7853 var target = this;
7854 target.hasSms = set.HAS_SMS;
7855 target.hasPhonebook = set.HAS_PHONEBOOK;
7856 target.isSupportSD = set.SD_CARD_SUPPORT;
7857 target.isCPE = set.PRODUCT_TYPE == 'CPE';
7858 target.hasRj45 = set.RJ45_SUPPORT;
7859 target.notDataCard = set.PRODUCT_TYPE != 'DATACARD';
7860 target.hasParentalControl = set.HAS_PARENTAL_CONTROL;
7861 target.hasUssd = set.HAS_USSD;
7862 var wifiInfo = fnc.getWifiBasic();
7863 if (set.WIFI_SUPPORT_QR_SWITCH) {
7864 target.showQRCode = set.WIFI_SUPPORT_QR_CODE && wifiInfo.show_qrcode_flag;
7865 } else {
7866 target.showQRCode = set.WIFI_SUPPORT_QR_CODE;
7867 }
7868 if(set.WIFI_SUPPORT_QR_CODE){
7869 target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + libjq.now();
7870 } else {
7871 target.qrcodeSrc = './pic/res_blacktrans.png';
7872 }
7873 if (target.hasRj45) {
7874 var opModeObj = checkCableMode(fnc.getOpMode().blc_wan_mode);
7875 target.opCurMode = libko.observable(opModeObj);
7876 target.isShowHomeConnect = libko.observable(!opModeObj);
7877 target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT && !opModeObj);
7878 target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING && !opModeObj);
7879 } else {
7880 target.isShowHomeConnect = libko.observable(true);
7881 target.showTraffic = libko.observable(set.TRAFFIC_SUPPORT);
7882 target.isSupportQuicksetting = libko.observable(set.HAS_QUICK_SETTING);
7883 }
7884 if (set.PRODUCT_TYPE == 'DATACARD') {
7885 libjq('#home_image').addClass('data-card');
7886 }
7887 var info = fnc.getConnectionInfo();
7888 target.networkType = libko.observable(homeUtil.getNetworkType(info.networkType));
7889 target.connectStatus = libko.observable(info.connectStatus);
7890 target.canConnect = libko.observable(false);
7891 target.cStatus = libko.computed(function () {
7892 if (target.connectStatus().indexOf('_connected') != -1) {
7893 return connStat.CONNECTED;
7894 } else if (target.connectStatus().indexOf('_disconnecting') != -1) {
7895 return connStat.DISCONNECTING;
7896 } else if (target.connectStatus().indexOf('_connecting') != -1) {
7897 return connStat.CONNECTING;
7898 } else {
7899 return connStat.DISCONNECTED;
7900 }
7901 });
7902 target.current_Flux = libko.observable(transUnit(0, false));
7903 target.connected_Time = libko.observable(transSecond2Time(0));
7904 target.up_Speed = libko.observable(transUnit(0, true));
7905 target.down_Speed = libko.observable(transUnit(0, true));
7906 target.isLoggedIn = libko.observable(false);
7907 target.enableFlag = libko.observable(true);
7908 target.simSerialNumber = libko.observable('');
7909 target.imei = libko.observable('');
7910 target.imsi = libko.observable('');
7911 target.iccid = libko.observable('');
7912 target.cellid = libko.observable('');
7913 target.ssid = libko.observable('');
7914 target.hasWifi = set.HAS_WIFI;
7915 target.showMultiSsid = libko.observable(set.HAS_MULTI_SSID && wifiInfo.multi_ssid_enable == "1");
7916 target.trafficAlertEnable = libko.observable(false);
7917 target.trafficUsed = libko.observable('');
7918 target.trafficLimited = libko.observable('');
7919 target.wireDeviceNum = libko.observable(fnc.getAttachedCableDevices().attachedDevices.length);
7920 target.wirelessDeviceNum = libko.observable(fnc.getStatusInfo().wirelessDeviceNum);
7921 target.showOpModeWindow = function () {
7922 if (target.enableFlag()) {
7923 return;
7924 }
7925 showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {});
7926 };
7927 target.currentOpMode = libko.observable("0");
7928 var popoverShown = false;
7929 libjq('#showDetailInfo').popover({
7930 html: true,
7931 placement: 'top',
7932 trigger: 'focus',
7933 title: function () {
7934 return libjq.i18n.prop('device_info')
7935 },
7936 content: function () {
7937 return getDetailInfoContent();
7938 }
7939 }).on('shown.bs.popover', function () {
7940 popoverShown = true;
7941 }).on('hidden.bs.popover', function () {
7942 popoverShown = false;
7943 });
7944 function fetchDeviceInfo() {
7945 var data = fnc.getDeviceInfo();
7946 target.simSerialNumber(verifyDeviceInfo(data.simSerialNumber));
7947 target.imei(verifyDeviceInfo(data.imei));
7948 target.imsi(verifyDeviceInfo(data.imsi));
7949 target.iccid(verifyDeviceInfo(data.iccid));
7950 target.cellid(verifyDeviceInfo(data.cellid));
7951 target.ssid(verifyDeviceInfo(data.ssid));
7952 target.showMultiSsid(set.HAS_MULTI_SSID && data.multi_ssid_enable == "1");
7953 return data;
7954 }
7955 fetchDeviceInfo();
7956 function getDetailInfoContent() {
7957 var data = fetchDeviceInfo();
7958 homeUtil.initShownStatus(data);
7959 var addrInfo = homeUtil.wanIpGet(data);
7960 var compiled = libus.template(libjq("#detailInfoTmpl").html());
7961 var tmpl = compiled({
7962 simSerialNumber: verifyDeviceInfo(data.simSerialNumber),
7963 imei: verifyDeviceInfo(data.imei),
7964 imsi: verifyDeviceInfo(data.imsi),
7965 iccid : verifyDeviceInfo(data.iccid),
7966 cellid: verifyDeviceInfo(data.cellid),
7967 signal: signalFormat(data.signal),
7968 hasWifi: set.HAS_WIFI,
7969 isCPE: set.PRODUCT_TYPE == 'CPE',
7970 hasRj45: set.RJ45_SUPPORT,
7971 showMultiSsid: set.HAS_MULTI_SSID && data.multi_ssid_enable == "1",
7972 ssid: verifyDeviceInfo(data.ssid),
7973 max_access_num: verifyDeviceInfo(data.max_access_num),
7974 m_ssid: verifyDeviceInfo(data.m_ssid),
7975 m_max_access_num: verifyDeviceInfo(data.m_max_access_num),
7976 wifi_long_mode: "wifi_des_" + data.wifiRange,
7977 lanDomain: verifyDeviceInfo(data.lanDomain),
7978 ipAddress: verifyDeviceInfo(data.ipAddress),
7979 showMacAddress: set.SHOW_MAC_ADDRESS,
7980 macAddress: verifyDeviceInfo(data.macAddress),
7981 showIpv4WanIpAddr: homeUtil.initStatus.showIpv4WanIpAddr,
7982 wanIpAddress: addrInfo.wanIpAddress,
7983 showIpv6WanIpAddr: homeUtil.initStatus.showIpv6WanIpAddr,
7984 ipv6WanIpAddress: addrInfo.ipv6WanIpAddress,
7985 sw_version: verifyDeviceInfo(data.sw_version),
7986 hw_version: verifyDeviceInfo(data.hw_version)
7987 });
7988 return libjq(tmpl).translate();
7989 }
7990 target.connectHandler = function () {
7991 if (target.connectStatus() == "ppp_connected") {
7992 showLoading('disconnecting');
7993 fnc.disconnect({}, function (data) {
7994 if (data.result) {
7995 successOverlay();
7996 } else {
7997 errorOverlay();
7998 }
7999 });
8000 } else {
8001 if (fnc.getStatusInfo().roamingStatus) {
8002 showConfirm('dial_roaming_connect', function () {
8003 target.connect();
8004 });
8005 } else {
8006 target.connect();
8007 }
8008 }
8009 };
8010 target.connect = function () {
8011 var statusInfo = fnc.getStatusInfo();
8012 var trafficResult = barStat.getTrafficResult(statusInfo);
8013 if (statusInfo.limitVolumeEnable && trafficResult.showConfirm) {
8014 var confirmMsg = null;
8015 if (trafficResult.usedPercent > 100) {
8016 confirmMsg = {
8017 msg: 'traffic_beyond_connect_msg'
8018 };
8019 barStat.setTrafficAlertPopuped(true);
8020 } else {
8021 confirmMsg = {
8022 msg: 'traffic_limit_connect_msg',
8023 params: [trafficResult.limitPercent]
8024 };
8025 barStat.setTrafficAlert100Popuped(false);
8026 }
8027 showConfirm(confirmMsg, function () {
8028 homeUtil.doConnect();
8029 });
8030 } else {
8031 homeUtil.doConnect();
8032 }
8033 };
8034 fnc.getSignalStrength({}, function (data) {
8035 var signalTxt = signalFormat(convertSignal(data));
8036 libjq("#fresh_signal_strength").text(signalTxt);
8037 if (popoverShown) {
8038 libjq("#popoverSignalTxt").text(signalTxt);
8039 }
8040 });
8041 homeUtil.refreshHomeData(target);
8042 addInterval(function () {
8043 fnc.getSignalStrength({}, function (data) {
8044 var signalTxt = signalFormat(convertSignal(data));
8045 libjq("#fresh_signal_strength").text(signalTxt);
8046 if (popoverShown) {
8047 libjq("#popoverSignalTxt").text(signalTxt);
8048 }
8049 });
8050 homeUtil.refreshHomeData(target);
8051 }, 1000);
8052 if (target.hasRj45) {
8053 homeUtil.refreshOpmodeInfo(target);
8054 addInterval(function () {
8055 homeUtil.refreshOpmodeInfo(target);
8056 }, 1000);
8057 }
8058 target.showNetworkSettingsWindow = function () {
8059 if (target.hasRj45) {
8060 fnc.getOpMode({}, function (data) {
8061 var mode = checkCableMode(data.blc_wan_mode);
8062 if (mode) {
8063 window.location.hash = '#network_set';
8064 } else {
8065 window.location.hash = '#conn_set';
8066 }
8067 });
8068 } else {
8069 window.location.hash = '#conn_set';
8070 }
8071 }
8072 };
8073 return {
8074 init: init
8075 };
8076});
8077
8078
8079define("language","knockout service jquery set underscore".split(" "),
8080 function(ko, service, $, config, _) {
8081
8082 // ��ȡ��ǰ������
8083 function getCurrentLanguage() {
8084 return service.getLanguage();
8085 }
8086
8087 // ��������������������Դ������ҳ���ϵ�body����
8088 // @param {String} current ������:zh-cn
8089 function loadLanguageAndRefresh(current){
8090 window.CURRENT_LANGUAGE = current;
8091 $("body").attr('lang', current);
8092 $.i18n.properties({
8093 name:'Messages',
8094 path:'i18n/',
8095 mode:'map',
8096 cache: true,
8097 language:current,
8098 callback: function() {
8099 jQuery.validator.messages = $.i18n.map;
8100 $('body').translate();
8101 }
8102 });
8103 }
8104
8105 window.language = null;
8106
8107
8108 function LanguageViewModel() {
8109 var target = this;
8110 var currentLan = getCurrentLanguage();
8111 var languages = _.map(config.LANGUAGES, function(item) {
8112 return new Option(item.name, item.value);
8113 });
8114
8115 document.title = config.WEBUI_TITLE;
8116 if($('#webui_title')[0]) {
8117 $('#webui_title').html(config.WEBUI_TITLE);
8118 }
8119
8120 target.languages = ko.observableArray(languages);
8121 target.currentLan = ko.observable(currentLan.Language);
8122 window.language = target.currentLan();
8123
8124 // �л������¼�����
8125 // @event langChangeHandler
8126 target.langChangeHandler = function(info, event) {
8127 clearValidateMsg();
8128
8129 service.setLanguage({Language: target.currentLan()}, function() {
8130 loadLanguageAndRefresh(target.currentLan());
8131 window.language = target.currentLan();
8132 });
8133 };
8134
8135 // ���������б���ˢ�½���
8136 loadLanguageAndRefresh(target.currentLan());
8137 }
8138
8139 // ��ʼ������VM������
8140 function init() {
8141 ko.applyBindings(new LanguageViewModel(), $('#language')[0]);
8142 }
8143
8144 return {
8145 init: init
8146 };
8147});
8148
8149
8150// ��½ ģ��
8151define("entry","jquery knockout set service underscore menu logout CryptoJS".split(" "),
8152 function($, ko,config, service, _, menu, logout, CryptoJS) {
8153
8154
8155 var pageState = {LOGIN:0, WAIT_PIN:1, WAIT_PUK:2, PUK_LOCKED:3, LOGGEDIN:4, LOADING:5};
8156 var timer = loginStatusCheckingTimer();
8157 var loginLockTimer = 0;
8158 var lastLoginStatus = "0";
8159
8160 function loginViewModel() {
8161 var target = this;
8162 var data = service.getLoginData();
8163 var loginStatus = service.getLoginStatus();
8164
8165 target.confirmPIN = ko.observable();
8166 target.leftSeconds = ko.observable(0);
8167 target.loginCount = ko.observable(0);
8168 target.loginSecuritySupport = ko.observable(config.LOGIN_SECURITY_SUPPORT);
8169 target.newPIN = ko.observable();
8170 target.password = ko.observable();
w.dengccefa882025-04-10 20:17:16 -07008171 target.username = ko.observable();
you.chen808f8ef2025-04-02 13:58:10 +08008172 target.PIN = ko.observable();
8173 target.pinNumber = ko.observable(data.pinnumber);
8174 target.PUK = ko.observable();
8175 target.pukNumber = ko.observable(data.puknumber);
8176 target.showEntrance = ko.observable(false);
8177 target.sharePathInvalid = ko.observable(false);
8178 target.uiLoginTimer = ko.observable(300);
8179
8180 // ע��˳�򣬵���ǰ�����޷�ˢ�³�����
8181 target.accountLocked = ko.computed(function () {
8182 return target.loginCount() == config.MAX_LOGIN_COUNT && target.leftSeconds() != '-1';
8183 });
8184
8185 target.leftUnlockTime = ko.computed(function () {
8186 target.leftSeconds();
8187 var formatted = transSecond2Time(target.uiLoginTimer());
8188 return formatted.substring(formatted.indexOf(':') + 1, formatted.length);
8189 });
8190
8191
8192 if(config.SD_CARD_SUPPORT){
8193 service.getSDConfiguration({}, function (data) {
8194 target.showEntrance(data.sd_status == "1" && data.share_status == "1" && data.sd_mode == "0");
8195 if(target.showEntrance()){
8196 service.checkFileExists({
8197 path: data.share_file
8198 }, function (data1) {
8199 if (data1.status == 'exist' || data1.status == 'processing') {
8200 target.sharePathInvalid(false);
8201 } else {
8202 target.sharePathInvalid(true);
8203 }
8204 });
8205 }
8206 });
8207 }
8208
8209 var state = computePageState(loginStatus, data);
8210 target.pageState = ko.observable(state);
8211 if (state == pageState.LOADING) {
8212 addTimeout(refreshPage, 500);
8213 }
8214 setFocus();
8215
8216
8217 // login �¼�����
8218
8219 target.login = function () {
8220 if(config.LOGIN_SECURITY_SUPPORT && target.accountLocked()){
8221 showAlert("password_error_account_lock_time", function () {
8222 setFocus();
8223 });
8224 return false;
8225 }
8226 target.pageState(pageState.LOADING);
8227 window.clearInterval(timer);
8228 var ciphertext = "";
8229 if (config.PASSWORD_ENCODE) {
8230 ciphertext = target.password();
w.dengccefa882025-04-10 20:17:16 -07008231 var username = target.username();
you.chen808f8ef2025-04-02 13:58:10 +08008232 } else {
8233 var kparam = service.getDeviceInfoLow();
8234 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
8235 var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
8236 ciphertext = CryptoJS.AES.encrypt(target.password(), tkey, {
8237 iv: tiv,
8238 mode: CryptoJS.mode.CBC,
8239 padding: CryptoJS.pad.ZeroPadding
8240 }).toString();
8241 }
8242 service.login({
w.dengccefa882025-04-10 20:17:16 -07008243 password:ciphertext,
8244 username: username
you.chen808f8ef2025-04-02 13:58:10 +08008245 }, function (info) {
8246 setTimeout(function () {
8247 timer = loginStatusCheckingTimer();
8248 }, 1300);
8249 if (info.result) {
8250 target.pageState(pageState.LOGGEDIN);
8251 if(config.LOGIN_SECURITY_SUPPORT){
8252 target.loginCount(0);
8253 target.uiLoginTimer(300);
8254 clearInterval(loginLockTimer);
8255 }
8256 $("#container").empty();
8257 window.location.hash = "#main";
8258 logout.init();
8259 } else {
8260 target.password("");
w.dengccefa882025-04-10 20:17:16 -07008261 target.username("");
you.chen808f8ef2025-04-02 13:58:10 +08008262 if(config.LOGIN_SECURITY_SUPPORT){
8263 target.checkLoginData(function(){
8264 if (target.loginCount() == config.MAX_LOGIN_COUNT) {
8265 showAlert("password_error_five_times", function () {
8266 setFocus();
8267 });
8268 target.startLoginLockInterval();
8269 } else {
8270 showAlert({msg: 'password_error_left', params: [config.MAX_LOGIN_COUNT - target.loginCount()]}, function () {
8271 setFocus();
8272 });
8273 }
8274 });
8275 }else {
8276 showAlert("password_error", function () {
8277 setFocus();
8278 });
8279 }
8280 target.pageState(pageState.LOGIN);
8281 }
8282 });
8283 };
8284
8285
8286
8287
8288 // ��ȡ��¼������Ϣ
8289 target.checkLoginData = function(cb){
8290 service.getLoginData({}, function(r){
8291 var failTimes = parseInt(r.psw_fail_num_str, 10);
8292 target.loginCount(config.MAX_LOGIN_COUNT - failTimes);
8293 target.leftSeconds(r.login_lock_time);
8294 target.uiLoginTimer(r.login_lock_time);
8295 if($.isFunction(cb)){
8296 cb();
8297 } else if (target.loginCount() == config.MAX_LOGIN_COUNT) {
8298 target.startLoginLockInterval();
8299 }
8300 });
8301 };
8302
8303 // ��������ʱ��ʱ����
8304 target.startLoginLockInterval = function () {
8305 loginLockTimer = setInterval(function () {
8306 service.getLoginData({}, function (data) {
8307 if (data.login_lock_time <= 0 || data.psw_fail_num_str == 5) {
8308 target.loginCount(0);
8309 clearInterval(loginLockTimer);
8310 }
8311 if(target.leftSeconds() != data.login_lock_time){
8312 target.leftSeconds(data.login_lock_time);
8313 target.uiLoginTimer(data.login_lock_time);
8314 } else {
8315 target.uiLoginTimer(target.uiLoginTimer() > 0 ? target.uiLoginTimer() - 1 : 0);
8316 }
8317 });
8318 }, 1000);
8319 };
8320
8321 target.checkLoginData();
8322
8323
8324
8325 // ��֤����PIN�¼�����
8326 target.enterPIN = function () {
8327 target.pageState(pageState.LOADING);
8328 var pin = target.PIN();
8329 service.enterPIN({
8330 PinNumber:pin
8331 }, function (data) {
8332 if (!data.result) {
8333 showAlert("pin_error", function () {
8334 refreshPage();
8335 });
8336 target.PIN('');
8337 } else {
8338 refreshPage();
8339 }
8340 });
8341 };
8342
8343 function setFocus(){
8344 setTimeout(function () {
8345 var txtAdmin = $('#txtAdmin:visible');
w.dengccefa882025-04-10 20:17:16 -07008346 var txtUser = $('#txtUser:visible');
you.chen808f8ef2025-04-02 13:58:10 +08008347 var txtPIN = $('#txtPIN:visible');
8348 var txtPUK = $('#txtPUK:visible');
w.dengccefa882025-04-10 20:17:16 -07008349 if(txtUser.length > 0) {
8350 txtUser.focus();
8351 } else if (txtAdmin.length > 0) {
you.chen808f8ef2025-04-02 13:58:10 +08008352 txtAdmin.focus();
8353 } else if (txtPIN.length > 0) {
8354 txtPIN.focus();
8355 } else if (txtPUK.length > 0) {
8356 txtPUK.focus();
8357 }
8358 }, 100);
8359 }
8360
8361
8362 // ˢ��ҳ��״̬
8363 function refreshPage() {
8364 var data = service.getLoginData();
8365 var loginStatus = service.getLoginStatus();
8366 var state = computePageState(loginStatus, data);
8367 if (state == pageState.LOADING) {
8368 addTimeout(refreshPage, 500);
8369 } else {
8370 target.pageState(state);
8371 target.pinNumber(data.pinnumber);
8372 target.pukNumber(data.puknumber);
8373 }
8374 setFocus();
8375 }
8376
8377 // ����PUK������PIN�¼�����
8378 target.enterPUK = function () {
8379 target.pageState(pageState.LOADING);
8380 var newPIN = target.newPIN();
8381 var confirmPIN = target.confirmPIN();
8382 var params = {};
8383 params.PinNumber = newPIN;
8384 params.PUKNumber = target.PUK();
8385 service.enterPUK(params, function (data) {
8386 if (!data.result) {
8387 showAlert("puk_error", function () {
8388 refreshPage();
8389 });
8390 target.PUK('');
8391 target.newPIN('');
8392 target.confirmPIN('');
8393 } else {
8394 refreshPage();
8395 }
8396 });
8397 };
8398
8399
8400
8401 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8402 function checkPinAfterLogin(loginStatus, data) {
8403 if (loginStatus.status == "loggedIn") {
8404 var currentState = data.modem_main_state; // cov_2
8405 if (currentState == "modem_waitpin") {
8406 return pageState.WAIT_PIN;
8407 } else if ((currentState == "modem_waitpuk" || data.pinnumber == 0) && (data.puknumber != 0)) {
8408 return pageState.WAIT_PUK;
8409 } else if ((data.puknumber == 0 || currentState == "modem_sim_destroy")
8410 && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
8411 return pageState.PUK_LOCKED;
8412 } else {
8413 return pageState.LOGGEDIN;
8414 }
8415 } else {
8416 var currentState = data.modem_main_state;
8417 if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8418 return pageState.LOADING;
8419 } else {
8420 return pageState.LOGIN;
8421 }
8422 }
8423 }
8424
8425 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8426 function computePageState(loginStatus, data) {
8427 //PX-880 �ȵ�¼�ٽ���PIN��֤������router����ԭ�򣬵�¼����PIN��֤���ڵ�¼ҳ�����У������ݿ�����֤����һ�¡�
8428 if (config.LOGIN_THEN_CHECK_PIN) {
8429 return checkPinAfterLogin(loginStatus, data);
8430 } else {
8431 return loginAfterCheckPin(loginStatus, data);
8432 }
8433 }
8434
8435 // ���ݵ�¼״̬��SIM��״̬����ҳ��״̬
8436 function loginAfterCheckPin(loginStatus, data) {
8437 if (loginStatus.status == "loggedIn") {
8438 return pageState.LOGGEDIN;
8439 } else {
8440 var currentState = data.modem_main_state;
8441 if ($.inArray(currentState, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8442 return pageState.LOADING;
8443 } else if (currentState == "modem_waitpin") {
8444 return pageState.WAIT_PIN;
8445 } else if ((currentState == "modem_waitpuk" || parseInt(data.pinnumber) === 0) && (parseInt(data.puknumber) != 0)) {
8446 return pageState.WAIT_PUK;
8447 } else if ((parseInt(data.puknumber) === 0 || currentState == "modem_sim_destroy") && currentState != "modem_sim_undetected" && currentState != "modem_undetected") {
8448 return pageState.PUK_LOCKED;
8449 } else {
8450 return pageState.LOGIN;
8451 }
8452 }
8453 }
8454 }
8455
8456
8457 // ���鵱ǰwindow.location.hash���쳣����ת��index.html
8458 function gotoLogin() {
8459 if (window.location.hash != config.defaultRoute && _.indexOf(config.GUEST_HASH, window.location.hash) == -1) {
8460 if (!manualLogout && lastLoginStatus == "1") {
8461 manualLogout = false;
8462 lastLoginStatus = 'UNREAL';
8463 showAlert('need_login_again', function () {
8464 window.location = "index.html";
8465 });
8466 } else if (lastLoginStatus == 'UNREAL') {
8467 //do nothing, only popup need_login_again alert one time
8468 return;
8469 } else {
8470 window.location = "index.html";
8471 }
8472 }
8473 }
8474
8475 // ��ʱ������¼״̬
8476 function loginStatusCheckingTimer() {
8477 return setInterval(function () {
8478 var info = service.getStatusInfo();
8479 if (!info.isLoggedIn) {
8480 gotoLogin();
8481 return;
8482 }
8483 lastLoginStatus = service.getStatusInfo().isLoggedIn ? "1" : "0";
8484 }, 1000);
8485 }
8486
8487 function init() {
8488 var info = service.getStatusInfo();
8489 if (info.isLoggedIn) {
8490 window.location.hash = '#main';
8491 return;
8492 }
8493
8494 var container = $('#container')[0];
8495 ko.cleanNode(container);
8496 var fwVm = new loginViewModel();
8497 ko.applyBindings(fwVm, container);
8498
8499 $('#frmLogin').validate({
8500 submitHandler:function () {
8501 fwVm.login();
8502 },
8503 rules: {
8504 txtAdmin: 'login_password_length_check'
8505 }
8506 });
8507 $('#frmPIN').validate({
8508 submitHandler:function () {
8509 fwVm.enterPIN();
8510 },
8511 rules:{
8512 txtPIN:"pin_check"
8513 }
8514 });
8515 $('#frmPUK').validate({
8516 submitHandler:function () {
8517 fwVm.enterPUK();
8518 },
8519 rules:{
8520 txtNewPIN:"pin_check",
8521 txtConfirmPIN:{equalToPin:"#txtNewPIN"},
8522 txtPUK:"puk_check"
8523 }
8524 });
8525 }
8526
8527
8528 return {
8529 init:init,
8530 gotoLogin:gotoLogin
8531 };
8532 });
8533
8534
8535// Logout �
8536define("logout","set service knockout underscore jquery".split(" "),
8537 function (config, service, ko, _, $) {
8538
8539 function logoutViewModel() {
8540 var target = this;
8541 // ��ȡ�Ƿ���¼
8542 var loginFlag = function () {
8543 var loginInfo = service.getLoginStatus();
8544 return (loginInfo.status == "loggedIn");
8545 }
8546 ();
8547 target.loggedIn = ko.observable(loginFlag);
8548
8549 // �˳�ϵͳ
8550 target.logout = function () {
8551 showConfirm("confirm_logout", function () {
8552 manualLogout = true;
8553 service.logout({}, setLocation());
8554 });
8555 };
8556
8557 // �Ƿ���ʾ�˳���ť
8558 target.showLogout = function () {
8559 if (config.HAS_LOGIN) {
8560 return target.loggedIn();
8561 } else {
8562 return false;
8563 }
8564 };
8565 }
8566 function setLocation() {
8567 window.location = 'index.html';
8568 }
8569 function initialize() {
8570 var fwVm = new logoutViewModel();
8571 bindContainer(fwVm);
8572 }
8573 function bindContainer(fwVm) {
8574 var con = $('#logout')[0];
8575 ko.cleanNode(con);
8576 ko.applyBindings(fwVm, con);
8577 }
8578 return {
8579 init: initialize
8580 };
8581});
8582
8583// operation mode �
8584define("opmode","knockout service jquery set underscore".split(" "),
8585
8586 function (ko, service, $, config, _) {
8587
8588 function currentOperationModeViewMode(){
8589 var target = this;
8590 target.isLoggedIn = ko.observable(false);
8591 target.enableFlag = ko.observable(false);
8592
8593 target.showOpModeWindow = function () {
8594 showSettingWindow("change_mode", "opmode_popup", "opmode_popup", 400, 300, function () {
8595 });
8596 };
8597 target.currentOpMode = ko.observable("0");
8598
8599 service.getOpMode({}, function(info){
8600 target.isLoggedIn(info.loginfo == "ok");
8601 if (info.opms_wan_mode != "PPP" && info.rj45_state != "idle" && info.rj45_state != "dead") {
8602 target.enableFlag(false);
8603 } else if (info.opms_wan_mode == "PPP" && info.ppp_status != "ppp_disconnected") {
8604 target.enableFlag(false);
8605 } else if(info.opms_wan_mode == "DHCP"){
8606 target.enableFlag(true);
8607 } else {
8608 target.enableFlag(true);
8609 }
8610
8611 var opmsWanMode = (info.opms_wan_mode == "DHCP" || info.opms_wan_mode == "STATIC") ? "PPPOE" : info.opms_wan_mode;
8612
8613 var currentOperationMode = "";
8614 switch(opmsWanMode){
8615 case "BRIDGE":
8616 currentOperationMode = "opmode_bridge";
8617 break;
8618 case "PPP":
8619 currentOperationMode = "opmode_gateway";
8620 break;
8621 case "PPPOE":
8622 currentOperationMode = "opmode_cable";
8623 break;
8624 default:
8625 break;
8626 }
8627 $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
8628 });
8629 // ��ʱ��ѯ����ģʽ����״̬�����ý���״̬
8630 setInterval(function(){
8631 var object = service.getConnectionInfo();
8632 if(object.opms_wan_mode == "DHCP") {
8633 target.enableFlag(true);
8634 } 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")) {
8635 target.enableFlag(false);
8636 } else {
8637 target.enableFlag(true);
8638 }
8639 }, 1000);
8640 }
8641
8642 function init() {
8643 var container = $('#currentOpMode')[0];
8644 ko.cleanNode(container);
8645 var fwVm = new currentOperationModeViewMode();
8646 ko.applyBindings(fwVm, container);
8647 }
8648
8649 return {
8650 init:init
8651 };
8652});
8653
8654// operation mode popup�
8655
8656define("opmode_popup","knockout service jquery set underscore".split(" "),
8657
8658 function (ko, service, $, config, _) {
8659
8660 function operationModeViewMode() {
8661 var target = this;
8662 var currentSelectedOperationMode = "";
8663 target.selectedMode = ko.observable("0");
8664
8665 // ��ʼ������ģʽ��ʾ
8666 service.getOpMode({}, function(info){
8667 if(info.blc_wan_mode == "AUTO_PPP"){
8668 currentSelectedOperationMode = "AUTO";
8669 }else if(info.blc_wan_mode == "AUTO_PPPOE"){
8670 currentSelectedOperationMode = "AUTO";
8671 }else if(info.blc_wan_mode == "PPPOE"){
8672 currentSelectedOperationMode = "PPPOE";
8673 }else{
8674 currentSelectedOperationMode = info.blc_wan_mode;
8675 }
8676 target.selectedMode(currentSelectedOperationMode);
8677 });
8678
8679 // ģʽ����/�л�
8680 target.changeOpMode = function(){
8681 var userSelectedOperationMode = $('input:radio[name="opMode"]:checked').val();
8682 var messageText = "";
8683 if(userSelectedOperationMode == currentSelectedOperationMode) {
8684 hidePopupSettingWindow();
8685 return;
8686 }
8687 if(userSelectedOperationMode == "LTE_BRIDGE"){
8688 messageText = "opmode_msg3";
8689 }else{
8690 messageText = "opmode_msg2";
8691 }
8692 showConfirm(messageText, function(){
8693 showLoading();
8694 service.SetOperationMode({
8695 opMode: userSelectedOperationMode
8696 },function(info){
8697 if (info && info.result == "success") {
8698 var currentOperationMode = "";
8699 switch(userSelectedOperationMode){
8700 case "AUTO":
8701 currentOperationMode = "opmode_auto"
8702 break;
8703 case "PPP":
8704 currentOperationMode = "opmode_gateway";
8705 break;
8706 case "PPPOE":
8707 currentOperationMode = "opmode_cable";
8708 break;
8709 default:
8710 break;
8711 }
8712 $("#opmode").attr("data-trans", currentOperationMode).text($.i18n.prop(currentOperationMode));
8713 successOverlay();
8714 } else {
8715 errorOverlay();
8716 }
8717 });
8718 });
8719
8720 }
8721
8722 }
8723
8724 function init() {
8725 var fwVm = new operationModeViewMode();
8726 ko.applyBindings(fwVm, $('#popupSettingWindow')[0]);
8727
8728 $("#opmode_form").validate({
8729 submitHandler: function(){
8730 fwVm.changeOpMode();
8731 }
8732 });
8733 }
8734
8735 return {
8736 init:init
8737 };
8738});
8739
8740define("router","underscore jquery menu set service".split(" "),
8741 function (_, $, menu, config, service) {
8742 var currentHash = '';
8743 var container = $('#container');
8744
8745 //�뿪����ʱ�����Ƿ��������޸ģ�����������ʾ
8746 checkFormContentModify = function (href) {
8747 if (config.CONTENT_MODIFIED.modified && window.location.hash != href) {
8748 if (config.CONTENT_MODIFIED.message == 'sms_to_save_draft') {
8749 config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
8750 config.resetContentModifyValue();
8751 window.location.hash = href;
8752 } else {
8753 showConfirm(config.CONTENT_MODIFIED.message, {
8754 ok: function () {
8755 config.CONTENT_MODIFIED.callback.ok(config.CONTENT_MODIFIED.data);
8756 config.resetContentModifyValue();
8757 window.location.hash = href;
8758 },
8759 no: function () {
8760 var result = config.CONTENT_MODIFIED.callback.no(config.CONTENT_MODIFIED.data);
8761 if (!result) {
8762 window.location.hash = href;
8763 config.resetContentModifyValue();
8764 }
8765 }
8766 });
8767 }
8768 return false;
8769 } else {
8770 return true;
8771 }
8772 };
8773
8774 //��ʱ�鿴SIM����״̬������ǰSIM��״̬��Ϊ����״̬��δ��ʾnosimcardҳ�棬����ʾnosimcardҳ��,�Ա��ⲻ�ر�webui�����²����豸�󣬲����ж�SIM��״̬������
8775 function checkSimCardStatus() {
8776 setInterval(function () {
8777 var data = service.getStatusInfo();
8778 var match = menu.findMenu();
8779 if (match.length == 0) {
8780 return false;
8781 }
8782 var requirePinHash = ["phonebook", "sms_list"];
8783 var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
8784 if (match[0].checkSIMStatus === true) {
8785 var simstatus = data.simStatus == "modem_sim_undetected"
8786 || data.simStatus == "modem_sim_destroy" || data.simStatus == "modem_waitpin"
8787 || data.simStatus == "modem_waitpuk";
8788 var netlockstatus = data.simStatus == "modem_imsi_waitnck";
8789 if (data.isLoggedIn && (
8790 ($('#div-nosimcard')[0] == undefined && simstatus)
8791 || ($('#div-network-lock')[0] == undefined && netlockstatus)
8792 || (($('#div-nosimcard')[0] != undefined || $('#div-network-lock')[0] != undefined) && data.simStatus == "modem_init_complete"))) {
8793 fixedLoadResources(match[0], data.simStatus, isRequirePin);
8794 }
8795 }
8796 }, 1000);
8797 }
8798
8799 //������¼ҳ�汳��
8800 function checkLoginPageBg() {
8801 var h = window.location.hash;
8802 if (h == '#entry' || _.indexOf(config.GUEST_HASH, h) != -1) {
8803 $("#manageContainer").attr("style", "margin-top:-36px;");
8804 } else {
8805 $("#manageContainer").attr("style", "margin-top:0px;");
8806 }
8807
8808 if (window.location.hash == '#entry') {
8809 $("#mainContainer").addClass('loginBackgroundBlue');
8810 } else {
8811 var mainContainer = $("#mainContainer");
8812 if (mainContainer.hasClass('loginBackgroundBlue')) {
8813 $("#container").css({
8814 margin: 0
8815 });
8816 mainContainer.removeClass('loginBackgroundBlue').height('auto');
8817 }
8818 }
8819 }
8820
8821 function fixedLoadResources(menuItem, simStatus, isRequirePin) {
8822 var item = {};
8823 $.extend(item, menuItem);
8824 //û��SIM��ʱ������homeҳ�治��������
8825 //���类��ʱ��homeҳ����ʾ����ҳ��
8826 if (simStatus == "modem_sim_undetected" || simStatus == "modem_sim_destroy") {
8827 if (!isRequirePin) {
8828 item.path = "sim_abnormal";
8829 }
8830 } else if (simStatus == "modem_waitpin" || simStatus == "modem_waitpuk") {
8831 item.path = "sim_abnormal";
8832 } else if (simStatus == "modem_imsi_waitnck") {
8833 item.path = "locknet";
8834 }
8835 //load tmpl and controller js
8836 loadResources(item);
8837 }
8838
8839 //���ݲ˵�����item���ض�Ӧ����Դ
8840 function loadResources(item) {
8841 var pId = item.path.replace(/\//g, '_');
8842 var $body = $('body').removeClass();
8843 if (pId != 'entry' && pId != 'main') {
8844 $body.addClass('beautiful_bg page_' + pId);
8845 } else {
8846 $body.addClass('page_' + pId);
8847 }
8848 clearTimer();
8849 hideLoading();
8850 var tmplPath = 'text!tmpl/' + item.path + '.html';
8851 //TODO: prevent first menu click cover the second menu content, need test with device
8852 require([tmplPath, item.path], function (tmpl, viewModel) {
8853 container.stop(true, true);
8854 container.hide();
8855 container.html(tmpl);
8856 viewModel.init();
8857 //support backward/forward
8858 menu.refreshMenu();
8859 $('#container').translate();
8860 menu.activeSubMenu();
8861
8862 $("form").attr("autocomplete", "off");
8863 container.fadeIn();
8864 });
8865 }
8866 //�ȶ�hash״̬, �����仯�������µ�hashƥ���˵�����,ƥ�䲻��ʱ��ת��homeҳ��, ƥ����ʱ��¼hashֵ����̬���ض�Ӧ����Դ�ļ�
8867 function hashCheck() {
8868 if (window.location.hash != currentHash) {
8869 //������½����������, ��½�û����ʷǵ�¼�û�ʱҳ�治��ת
8870 var info = service.getStatusInfo();
8871 if (window.location.hash == config.defaultRoute || _.indexOf(config.GUEST_HASH, window.location.hash) != -1) {
8872 if (info.isLoggedIn) {
8873 window.location.hash = currentHash == "" ? "#main" : currentHash;
8874 return;
8875 }
8876 }
8877
8878 var match = menu.findMenu();
8879
8880 if (match.length == 0) {
8881 window.location.hash = config.defaultRoute;
8882 } else {
8883 //��¼ʱ���鹤��ģʽ������ģʽ������������Ҫ����SIM��״̬�����¼���,����ģʽ�������治��Ҫ����SIM��״̬�����¼���
8884 if (config.RJ45_SUPPORT && window.location.hash == "#main") {
8885 if ((match[0].checkSIMStatus && checkCableMode(info.blc_wan_mode)) || (!match[0].checkSIMStatus && !checkCableMode(info.blc_wan_mode))) {
8886 window.location.reload();
8887 return;
8888 }
8889 }
8890 //TODO: �����˵�����Ӧ�����˵���һ����л�ʱ�����¼�������, ��TODO: click the same menu ʵ�ַ�ʽ����
8891 var oldMenu = menu.findMenu(currentHash);
8892 currentHash = match[0].hash;
8893 if (currentHash == "#entry") {
8894 $('#indexContainer').addClass('login-page-bg');
8895 menu.rebuild();
8896 } else {
8897 $('#indexContainer').removeClass('login-page-bg');
8898 }
8899
8900 if (oldMenu.length != 0 && match[0].path == oldMenu[0].path && match[0].level != oldMenu[0].level && match[0].level != '1' && oldMenu[0].level != '1') {
8901 return;
8902 }
8903
8904 checkLoginPageBg();
8905 var requirePinHash = ["phonebook", "sms_list"];
8906 var isRequirePin = ($.inArray(match[0].path, requirePinHash) != -1);
8907 if (match[0].checkSIMStatus === true || isRequirePin) {
8908 //simStatus is undefined when refreshing page
8909 if (info.simStatus == undefined) {
8910 showLoading('waiting');
8911 function checkSIM() {
8912 var data = service.getStatusInfo();
8913 if (data.simStatus == undefined || $.inArray(data.simStatus, config.TEMPORARY_MODEM_MAIN_STATE) != -1) {
8914 addTimeout(checkSIM, 500);
8915 } else {
8916 fixedLoadResources(match[0], data.simStatus, isRequirePin);
8917 hideLoading();
8918 }
8919 }
8920 checkSIM();
8921 } else {
8922 fixedLoadResources(match[0], info.simStatus, isRequirePin);
8923 }
8924 } else {
8925 loadResources(match[0]);
8926 }
8927 }
8928 }
8929 }
8930
8931 //Ĭ������ҳ��Ϊ#main, ��ʱ����hash״̬
8932 function init() {
8933 checkSimCardStatus();
8934 window.location.hash = window.location.hash || "#main";
8935 //if support onhashchange then use. If ie8 in ie7 mode, it doesn't trigger onhashchange.
8936 if (('onhashchange' in window) && ((typeof document.documentMode === 'undefined') || document.documentMode == 8)) {
8937 window.onhashchange = hashCheck;
8938 hashCheck();
8939 } else {
8940 setInterval(hashCheck, 200);
8941 }
8942
8943 //�����޸���ҳ������, �뿪ʱ������ʾ
8944 $("a[href^='#']").die('click').live('click', function () {
8945 var $this = $(this);
8946 config.CONTENT_MODIFIED.checkChangMethod();
8947 return checkFormContentModify($this.attr('href'));
8948 });
8949 }
8950
8951 return {
8952 init: init
8953 };
8954});
8955
8956// statusBar �
8957
8958define("statusBar", "knockout jquery underscore service set menu tooltip".split(" "),
8959
8960 function (ko, $, _, service, config, menu, tooltip) {
8961
8962 var sv__hasCheckedSMSCapacity = false;
8963 var sv__initSMSCompleted = false;
8964 var sv_newSMSMessageInDealing = false;
8965 var sv_fotaUpdateCancel = null;
8966 var sv_batteryCheckTimer = 0;
8967 var sv_dbMessageIds = [];
8968 var sv_fotaResultAlertPopuped = false;
8969 var sv_isFirstLoadNewMessage = true;
8970 var isLoggedIn = true;
8971 var sv_messagePopStack = {};
8972 var sv_newMessagePopTemplate = null;
8973 var sv_resetTrafficAlertPopuped = false;
8974 var sv_simMessageListTemplate = null;
8975 var sv_smsListTemplate = null;
8976 var sv_trafficAlertPopuped_100 = false;
8977 var sv_trafficAlertPopuped = false;
8978 var sv_timer = 0;
8979
8980 // ��ȡ״̬��Ϣ�������硢SIM��WIFI��
8981 var getCurrentStatusInfo = function () {
8982 return service.getStatusInfo();
8983 };
8984
8985 function statusViewModel() {
8986 var target = this;
8987 var info = getCurrentStatusInfo();
8988 var roamStatus = info.roamingStatus ? true : false;
8989 var $langLogoBar = $("#langLogoBar");
8990
8991
8992 // �������������¼�����
8993 function sf_connect() {
8994 showLoading("connecting");
8995 service.connect({}, function (data) {
8996 if (data.result) {
8997 refreshWifiConnectStatus(target, data.status);
8998 }
8999 successOverlay();
9000 }, function (data) {
9001 errorOverlay();
9002 });
9003 }
9004 // �Ͽ������¼�����
9005 function sf_disconnect() {
9006 showLoading("disconnecting");
9007 service.disconnect({}, function (data) {
9008 if (data.result) {
9009 refreshWifiConnectStatus(target, data.status);
9010 }
9011 successOverlay();
9012 }, function (data) {
9013 errorOverlay();
9014 });
9015 }
9016
9017 if(info.isLoggedIn){
9018 if(!$langLogoBar.hasClass("langborderBg")){
9019 $langLogoBar.addClass("langborderBg");
9020 }
9021 $("#statusBar:hidden").show();
9022 } else {
9023 if($langLogoBar.hasClass("langborderBg")){
9024 $langLogoBar.removeClass("langborderBg");
9025 }
9026 $("#statusBar:visible").hide();
9027 }
9028
9029
9030 //target.attachedDevices = ko.observable(info.attachedDevices);
9031 target.batteryLevel = ko.observable(info.batteryLevel + '%');
9032 target.batteryPers = ko.observable(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
9033 target.batteryStatus = ko.observable(info.batteryStatus);
9034 target.connectionCssClass = ko.observable("");
9035 target.connectStatus = ko.observable(info.connectStatus);
9036 target.connectStatusText = ko.observable();
9037 target.connectStatusTrans = ko.observable();
9038 target.hasWifi = ko.observable(config.HAS_WIFI);
9039 target.hasBattery = ko.observable(config.HAS_BATTERY);
9040 target.isLoggedIn = ko.observable(info.isLoggedIn);
9041 target.isShowConnectionIcon = ko.observable(false);
9042 target.isShowFotaNewversionIcon = ko.observable(info.new_version_state && info.fota_package_already_download != "yes" && !config.isShowFotaIcon);
9043 target.isShowRj45ConnectionIcon = ko.observable(false);
9044 target.networkOperator = ko.observable(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,roamStatus));
9045 target.networkType = ko.observable(getNetworkType(info.networkType));
9046 target.pinStatus = ko.observable(info.pinStatus);
9047 target.pinStatusText = ko.observable();
9048 target.rj45ConnectionCssClass = ko.observable("");
9049 target.roamingStatus = ko.observable(info.roamingStatus ? "R" : "");
9050 target.showAttachedDevices = ko.observable(info.wifiStatus);
9051 target.showSmsDeleteConfirm = ko.observable(false);
9052 target.smsUnreadCount = ko.observable(0);
9053 target.simStatus = ko.observable(sf_convertSimStatusToImage(info.simStatus));
9054 target.signalCssClass = ko.observable(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
9055 target.updateType = ko.observable(service.getUpdateType().update_type);
9056 target.wifiStatusCssClass = ko.observable(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
9057 target.wifiStatusImg = ko.observable(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
9058
9059 sf_getConnectionCssClass(target, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
9060
9061 target.connect = sf_connect;
9062 target.disconnect = sf_disconnect;
9063 }
9064
9065 function sf_gotoSmsList(){
9066 var s_href = '#msg_main';
9067 if(window.location.hash == '#msg_main'){
9068 s_href = '#msg_list';
9069 }
9070 config.CONTENT_MODIFIED.checkChangMethod();
9071 if(checkFormContentModify(s_href)){
9072 window.location.hash = s_href;
9073 }
9074 }
9075
9076 gotoSmsList = sf_gotoSmsList;
9077
9078 function sf_getNetWorkProvider(i_spnB1Flag, i_spnNameData, i_spnB2Flag, i_networkProvider, i_roamStatus) {
9079 if (i_spnNameData == "") {
9080 return i_networkProvider;
9081 } else {
9082 i_spnNameData = decodeMessage(i_spnNameData);
9083 if (i_spnB1Flag == "0" && i_spnB2Flag == "0") {
9084 if (i_roamStatus) {//����
9085 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9086 } else {//������
9087 return i_spnNameData;
9088 }
9089 }else if (i_spnB1Flag == "1" && i_spnB2Flag == "1") {
9090 if (i_roamStatus) {//����
9091 return i_networkProvider;
9092 } else {//������
9093 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9094 }
9095 } else if (i_spnB1Flag == "1") {
9096 return i_spnNameData == i_networkProvider ? i_networkProvider : (i_spnNameData + ' ' + i_networkProvider);
9097 } else if (i_spnB2Flag == "1") {
9098 if (i_roamStatus) {//����
9099 return i_networkProvider;
9100 } else {//������
9101 return i_spnNameData;
9102 }
9103 }
9104 return "";
9105 }
9106 }
9107
9108 // �����¶���Ϣ��ʾ����������������
9109 function sf_addNewMessage(i_message, i_isUpdate, i_type){
9110 config.smsMaxId = i_message.id;
9111 var now = $.now();
9112 sv_messagePopStack["m" + now] = now;
9113 var name = i_message.number;
9114 if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
9115 sv_isFirstLoadNewMessage = false;
9116 if(config.HAS_PHONEBOOK){
9117 sf_getPhoneBooks();
9118 }else{
9119 config.phonebook = [];
9120 }
9121 }
9122 for(i in config.phonebook){
9123 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9124 name = config.phonebook[i].pbm_name;
9125 break;
9126 }
9127 }
9128 var s_newMsg = {
9129 mark : "m" + now,
9130 name: name,
9131 title: $.i18n.prop("sms"),
9132 titleTrans: "sms",
9133 tag: i_message.tag,
9134 content : i_message.content,
9135 datetime : i_message.time
9136 };
9137 if(sv_newMessagePopTemplate == null){
9138 sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
9139 }
9140 $(".bubbleItem:not(.report)", "#buttom-bubble").remove();
9141 $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
9142 if((window.location.hash == "#msg_main" || window.location.hash == "#msg_list") && i_type == "1"){
9143 //sf_dealChosenNumber(s_newMsg.name, i_message.number);
9144 var s_inChating = config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
9145 var s_itemId = getLastNumber(i_message.number, config.SMS_MATCH_LENGTH);
9146 var item = $("#smslist-item-" + s_itemId);
9147 if(item && item.length > 0){
9148 // �Ѵ������ݣ��������ݵ���˳��
9149 for(var i = 0; config.listMsgs && i < config.listMsgs.length; i++){
9150 if(getLastNumber(config.listMsgs[i].number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9151 config.listMsgs[i].id = i_message.id;
9152 config.listMsgs[i].latestId = i_message.id;
9153 config.listMsgs[i].latestSms = i_message.content;
9154 config.listMsgs[i].latestTime = i_message.time;
9155 if(!i_isUpdate){
9156 config.listMsgs[i].newCount++;
9157 config.listMsgs[i].totalCount++;
9158 }
9159 break;
9160 }
9161 }
9162 item.find(".smslist-item-checkbox p.checkbox").attr("id", i_message.id);
9163 item.find(".smslist-item-checkbox input:checkbox").val(i_message.id).attr("id", "checkbox" + i_message.id);
9164 if(!i_isUpdate){
9165 var s_itemCount = item.find(".smslist-item-total-count").text();
9166 s_itemCount = Number(s_itemCount.substring(1, s_itemCount.length - 1));
9167 item.find(".smslist-item-total-count").text("(" + (s_itemCount + 1) + ")");
9168 if(!config.currentChatObject || config.currentChatObject != getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9169 var s_newNum = item.find(".smslist-item-new-count").removeClass("hide");
9170 if(s_newNum && s_newNum.text().length > 0){
9171 s_newNum.text(Number(s_newNum.text()) + 1);
9172 }else{
9173 s_newNum.text(1);
9174 }
9175 }
9176 }
9177 if(item.find(".smslist-item-draft-flag").length > 0){
9178 if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
9179 item.find(" td:nth-child(2)").removeClass("font-weight-bold");
9180 } else {
9181 item.find(" td:nth-child(2)").addClass("font-weight-bold");
9182 }
9183 }else{
9184 var msgContent = item.find(".smslist-item-msg").text(i_message.content);
9185 msgContent.closest('td').prop('title', i_message.content);
9186 item.find("span.clock-time").text(i_message.time);
9187 if (config.currentChatObject && config.currentChatObject == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)) {
9188 msgContent.closest('tr').removeClass("font-weight-bold");
9189 } else {
9190 msgContent.closest('tr').addClass("font-weight-bold");
9191 }
9192 }
9193 item.find(".smslist-item-repeat span").die().click(function() {
9194 forwardClickHandler(i_message.id);
9195 });
9196
9197 var s_tmpItem = item;
9198 item.hide().remove();
9199 $("#smslist-table").prepend(s_tmpItem.show());
9200 } else {
9201 // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
9202 var s_theName = "";
9203 if(config.phonebook && config.phonebook.length > 0) {
9204 for(i in config.phonebook){
9205 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9206 s_theName = config.phonebook[i].pbm_name;
9207 break;
9208 }
9209 }
9210 }
9211 var s_theNewMessage = {
9212 id : i_message.id,
9213 name : s_theName,
9214 number : i_message.number,
9215 latestId :i_message.id,
9216 totalCount : 1,
9217 newCount : s_inChating ? 0 : 1,
9218 latestSms : i_message.content,
9219 latestTime : i_message.time,
9220 checked : false,
9221 hasDraft : false,
9222 itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
9223 };
9224 if(sv_smsListTemplate == null){
9225 sv_smsListTemplate = $.template("smsTableTmpl", $("#smsTableTmpl"));
9226 }
9227 $.tmpl("smsTableTmpl", {data: [s_theNewMessage]}).prependTo("#smslist-table");
9228 }
9229 if(config.HAS_PHONEBOOK){
9230 $(".sms-add-contact-icon").removeClass("hide");
9231 }else{
9232 $(".sms-add-contact-icon").addClass("hide");
9233 }
9234 if(s_inChating){
9235 var talkItem = $("#talk-item-" + i_message.id, "#chatlist");
9236 if (talkItem && talkItem.length > 0) {// ���¼�����������
9237 $(".J_content pre", talkItem).html(dealContent(i_message.content));
9238 $(".time .smslist-item-time", talkItem).text(i_message.time);
9239 $(".smslist-item-repeat", talkItem).die().click(
9240 function() {
9241 forwardClickHandler(i_message.id);
9242 });
9243 $(".smslist-item-delete", talkItem).die().click(
9244 function() {
9245 deleteSingleItemClickHandler(i_message.id);
9246 });
9247 } else {// �����µĻظ�����
9248 $("#smsOtherTmpl").tmpl(i_message).appendTo("#chatlist");
9249 $(".clear-container", "#chatpanel").animate({
9250 scrollTop : $("#chatlist").height()
9251 });
9252 }
9253 if (!config.SMS_SET_READ_WHEN_COMPLETE) {
9254 service.setSmsRead({ids: [i_message.id]}, $.noop);
9255 } else if (config.SMS_SET_READ_WHEN_COMPLETE && i_message.receivedAll) {
9256 service.setSmsRead({ids: [i_message.id]}, $.noop);
9257 }
9258 }
9259 enableCheckbox($("#smslist-checkAll"));
9260 }
9261 if(window.location.hash == "#msg_sim" && i_type == "0"){
9262 // ���������б��в�������Ӧ����ϵ�˶�Ϣ��Ӧ�ڶ����б�����������
9263 var s_theName = "";
9264 if(config.phonebook && config.phonebook.length > 0) {
9265 for(i in config.phonebook){
9266 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9267 s_theName = config.phonebook[i].pbm_name;
9268 break;
9269 }
9270 }
9271 }
9272 var s_theNewMessage = {
9273 id : i_message.id,
9274 name : s_theName,
9275 number : i_message.number,
9276 content : i_message.content,
9277 time : i_message.time,
9278 tag: i_message.tag,
9279 checked : false,
9280 itemId : getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)
9281 };
9282 if(i_isUpdate){
9283 var s_item = $(".simMsgList-item-class-" + s_theNewMessage.id);
9284 s_item.hide().remove();
9285 }
9286 if(sv_simMessageListTemplate == null){
9287 sv_simMessageListTemplate = $.template("ssimMessageListTemplate", $("#simMessageListTemplate"));
9288 }
9289 $.tmpl("simMessageListTemplate", {data: [s_theNewMessage]}).prependTo("#simMsgList_container");
9290 }
9291 }
9292
9293 function sf_checkBatteryStatusForFota(){
9294 var s_state = service.getCurrentUpgradeState();
9295 if(s_state.current_upgrade_state == 'low_battery'){
9296 showInfo('ota_low_battery');
9297 clearInterval(sv_batteryCheckTimer);
9298 }
9299 }
9300
9301 // ��SIM��״̬ת��Ϊ��Ӧ����������
9302 function sf_convertSimStatusToImage(i_status) {
9303 var s_image;
9304 switch (i_status) {
9305 case "modem_destroy":
9306 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
9307 break;
9308 case "modem_imsi_waitnck":
9309 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitnck");
9310 break;
9311 case "modem_init_complete":
9312 s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
9313 break;
9314 case "modem_sim_destroy":
9315 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_destroy");
9316 break;
9317 case "modem_sim_undetected":
9318 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_undetected");
9319 break;
9320 case "modem_undetected":
9321 s_image = "./pic/simcard_undetected.png";
9322 break;
9323 case "modem_waitpin":
9324 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpin");
9325 break;
9326 case "modem_waitpuk":
9327 s_image = "./pic/simcard_undetected.png";//$.i18n.prop("sim_status_waitpuk");
9328 break;
9329
9330 default:
9331 s_image = "./pic/simcard_detected.png";//$.i18n.prop("sim_status_ready");
9332 break;
9333 }
9334 return s_image;
9335 }
9336
9337 function sf_dealChosenNumber(i_choosenName, i_choosenNum) {
9338 setTimeout(function () {
9339 var s_choosen = $("#chosenUserSelect");
9340 var s_options = $("option", s_choosen);
9341 for (var index = 0; index < s_options.length; index++) {
9342 if (getLastNumber(i_choosenNum, config.SMS_MATCH_LENGTH) == s_options[index].value) {
9343
9344 s_options[index].text = i_choosenName + '/' + i_choosenNum;
9345 s_options[index].value = i_choosenNum;
9346
9347 break;
9348 }
9349 }
9350 s_choosen.trigger("liszt:updated");
9351 }, 0);
9352 }
9353
9354 // ˫�첽��ȡ�豸����sim�����ö���Ϣ���������ϲ�
9355 function sf_dealPhoneBooksResult(i_books){
9356 if($.isArray(i_books.pbm_data) && i_books.pbm_data.length > 0){
9357 config.phonebook = i_books.pbm_data;
9358 }
9359 }
9360
9361 // �������µ�5������Ϣ����δ���ӵ������б��еĵ�����ʾ
9362 function sf_filterNewMessage(i_messages, i_type){
9363 if(!config.dbMsgs){
9364 config.dbMsgs = [];
9365 }
9366 if(sv_dbMessageIds.length == 0){
9367 $.each(config.dbMsgs, function(index_1, i_element){
9368 sv_dbMessageIds.push(i_element.id);
9369 });
9370 }
9371 $.each(i_messages, function(index_2, i_element){
9372 if($.inArray(i_element.id, sv_dbMessageIds) == -1){//�����¶���
9373 sv_dbMessageIds.push(i_element.id);
9374 config.dbMsgs.push(i_element);
9375 if(i_element.tag == '1'){
9376 sf_addNewMessage(i_element, false, i_type);
9377 }
9378 }else{
9379 for(var index = 0; index < config.dbMsgs.length; index++){//���¼�������
9380 if(config.dbMsgs[index].id == i_element.id && config.dbMsgs[index].content != i_element.content && i_element.tag == '1'){
9381 config.dbMsgs[index].content = i_element.content;
9382 sf_addNewMessage(i_element, true, i_type);
9383 break;
9384 }
9385 }
9386 }
9387 });
9388 }
9389
9390 // ������ת��Ϊ��ӦͼƬ
9391 function sf_getBatteryLevelImage(pers, i_status) {
9392 var s_Image = null;
9393 if ("0" == i_status) {
9394 if ("1" == pers) {
9395 s_Image = "pic/power_one.png";
9396 } else if ("2" == pers) {
9397 s_Image = "pic/power_two.png";
9398 } else if ("3" == pers) {
9399 s_Image = "pic/power_three.png";
9400 } else if ("4" == pers) {
9401 s_Image = "pic/power_full.png";
9402 } else { //"5" == pers || "0" == pers
9403 s_Image = "pic/power_out.png";
9404 }
9405 } else {
9406 s_Image = "pic/power_charging.gif";
9407 }
9408 return s_Image;
9409 }
9410
9411 // ��ȡ����״̬��CSS��ʽ
9412 function sf_getConnectionCssClass(i_fwVm, i_status, i_data_counter, i_wifiSSID, i_wifiStatus, i_rj45Status) {
9413
9414 var s_rj45ConnectionStatus = "icon_connection ";
9415 var s_connectionStatus = "icon_connection ";
9416
9417 if(i_rj45Status == "connect"){
9418 s_rj45ConnectionStatus += "connecting";
9419 }else if(i_rj45Status == "working"){
9420 s_rj45ConnectionStatus += "rj45_connected";
9421 }else{
9422 s_rj45ConnectionStatus += "disconnect";
9423 }
9424
9425 if (i_status == "ppp_connecting" || i_status == "wifi_connecting") {
9426 s_connectionStatus += "connecting";
9427 } else if(i_status == "ppp_connected") {//CPE ppp_statusΪnone ready��ֵ
9428 if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate != '0') {
9429 s_connectionStatus += "connectionBoth";
9430 } else if (i_data_counter.uploadRate != '0' && i_data_counter.downloadRate == '0') {
9431 s_connectionStatus += "connectionUp";
9432 } else if (i_data_counter.uploadRate == '0' && i_data_counter.downloadRate != '0') {
9433 s_connectionStatus += "connectionDown";
9434 } else {
9435 s_connectionStatus += "connectionNone";
9436 }
9437 } else if (i_status == "ppp_disconnected") {
9438 if (i_wifiSSID && i_wifiStatus == "connect") {
9439 service.getHotspotList({}, function (data) {
9440 var s_cssName = "icon_connection ";
9441 var s_css = "connecting ";
9442 for (var i = 0, len = data.hotspotList.length; i < len; i++) {
9443 if (data.hotspotList[i].connectStatus == "1") {
9444 s_css = "wifi_connected";
9445 break;
9446 }
9447 }
9448 s_cssName += s_css;
9449 i_fwVm.connectionCssClass(s_cssName);
9450 });
9451 i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
9452 return;
9453 } else if (i_wifiSSID && (i_wifiStatus == "connecting" || i_wifiStatus =="dhcping")) {
9454 s_connectionStatus += "connecting";
9455 } else {
9456 s_connectionStatus += "disconnect";
9457 }
9458 } else {
9459 s_connectionStatus += "disconnect";
9460 }
9461
9462 i_fwVm.connectionCssClass(s_connectionStatus);
9463 i_fwVm.rj45ConnectionCssClass(s_rj45ConnectionStatus);
9464 }
9465
9466 // ��ȡ�绰����Ϣ
9467 function sf_getPhoneBooks() {
9468 var s_books = service.getPhoneBooks({
9469 page : 0,
9470 data_per_page : 2000,
9471 orderBy : "id",
9472 isAsc : false
9473 });
9474 sf_dealPhoneBooksResult(s_books);
9475 }
9476
9477 // ��ȡ�ź�����CSS��ʽ
9478 function sf_getSignalCssClass(siganl, networkType, simStatus) {
9479 networkType = networkType.toLowerCase();
9480 simStatus = simStatus ? simStatus.toLowerCase() : '';
9481 if(networkType == '' || networkType == 'limited_service' || networkType == 'no_service' || networkType == 'limited service' || networkType == 'no service'
9482 || simStatus != 'modem_init_complete'){
9483 siganl = '_none';
9484 }
9485 return "signal signal" + siganl;
9486 }
9487
9488 function sf_getWifiStatusCssClass(i_status, i_deviceSize) {
9489 if (i_status) {
9490 if (i_deviceSize == 0) {
9491 return "wifi_status0";
9492 } else {
9493 return "wifi_status" + i_deviceSize;
9494 }
9495 } else {
9496 return "wifi_status_off";
9497 }
9498 }
9499
9500 // ����wifi״̬��ȡwifi��ͼƬ��Դ
9501 function sf_getWifiStatusImage(i_status, i_deviceSize) {
9502 if (i_status) {
9503 if (i_deviceSize == 0) {
9504 return "./pic/wlan0.png";
9505 } else {
9506 return "./pic/wlan" + i_deviceSize + ".png";
9507 }
9508 } else {
9509 return "./pic/wlan_off.png";
9510 }
9511 }
9512
9513 // ��ȡ��������������С���������ؽ���
9514 function sf_refreshFotaDownloadProgress(){
9515 service.getPackSizeInfo({}, function (data) {
9516 var percents;
9517 if (parseInt(data.fota_pkg_total_size) == 0) {
9518 percents = 0;
9519 } else {
9520 percents = parseInt(parseInt(data.fota_dl_pkg_size) * 100 / parseInt(data.fota_pkg_total_size));
9521 }
9522 if (percents > 100) {
9523 percents = 100;
9524 }
9525 if (percents >= 0) {
9526 if (percents > 95) {
9527 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
9528 }
9529 setProgressBar(percents);
9530 }
9531 });
9532 }
9533
9534 // �������ŷ��ͱ���
9535 function sf_responseSmsReport(){
9536 if(sv_isFirstLoadNewMessage && config.phonebook && config.phonebook.length == 0){
9537
9538 sv_isFirstLoadNewMessage = false;
9539
9540 if(config.HAS_PHONEBOOK){
9541 sf_getPhoneBooks();
9542 }else{
9543 config.phonebook = [];
9544 }
9545 }
9546 service.getSMSDeliveryReport({
9547 page: 0,
9548 smsCount: 10
9549 }, function(data){
9550 var s_messages = data.messages;
9551 var s_nums = [];
9552 $.each(s_messages, function(i, i_message){
9553 if($.inArray(i_message.number, s_nums) == -1){
9554 s_nums.push(i_message.number);
9555 window.setTimeout(function(){
9556 var s_now = $.now();
9557 sv_messagePopStack["m" + s_now] = s_now;
9558 i_message.name = i_message.number;
9559 for(i in config.phonebook){
9560 if(getLastNumber(config.phonebook[i].pbm_number, config.SMS_MATCH_LENGTH) == getLastNumber(i_message.number, config.SMS_MATCH_LENGTH)){
9561 i_message.name = config.phonebook[i].pbm_name;
9562 break;
9563 }
9564 }
9565 var s_msgContent = $.i18n.prop("sms_delivery_report_" + i_message.content);
9566
9567 var s_newMsg = {
9568 mark : "m" + s_now,
9569 name: i_message.name,
9570 title: $.i18n.prop("sms_report"),
9571 titleTrans: "sms_report",
9572 content : s_msgContent,
9573 datetime : i_message.time,
9574 report : 'report'
9575 };
9576
9577 if(sv_newMessagePopTemplate == null){
9578 sv_newMessagePopTemplate = $.template("newMessagePopTmpl", $("#newMessagePopTmpl"));
9579 }
9580
9581 $(".report", "#buttom-bubble").remove();
9582 $.tmpl("newMessagePopTmpl", s_newMsg).appendTo("#buttom-bubble");
9583 }, 100);
9584 }
9585 });
9586 }, function(){
9587 //No Deal
9588 });
9589 }
9590
9591 function sf_simStatusInvalid(simStatus){
9592 return simStatus == 'modem_sim_undetected' || simStatus == 'modem_undetected' || simStatus == 'modem_sim_destroy'
9593 || simStatus == 'modem_waitpin' || simStatus == 'modem_waitpuk' || simStatus == 'modem_imsi_waitnck';
9594 }
9595
9596 // ��ʾFOTA������ǰ״̬
9597 function sf_showFotaCurrentStatus() {
9598 sv_fotaUpdateCancel = true;
9599 var r = service.getNewVersionState();
9600
9601 function showProgress() {
9602 var upgradingState = ["downloading"];
9603 var info = service.getCurrentUpgradeState();
9604 if(info.current_upgrade_state.toLowerCase() == "idle") {
9605 addTimeout(showProgress, 1000);
9606 } else if(($.inArray(info.current_upgrade_state, upgradingState) != -1)&&(r.fota_new_version_state != "already_has_pkg")) {
9607 hideLoading();
9608 sf_showFotaUpgradeStatus();
9609 }
9610 }
9611 if (!($("#progress").is(":visible"))) {
9612 showProgress();
9613 }
9614 var times = 0;
9615 var getOTAUpgradeState = function () {
9616 var data = null;
9617 if (times <= 3) {
9618 times = times + 1;
9619 data = service.getCurrentUpgradeState();
9620 } else {
9621 data = getCurrentStatusInfo();
9622 }
9623 var state = data.current_upgrade_state;
9624 if(sv_fotaUpdateCancel && isLoggedIn == true){
9625
9626 if(r.fota_new_version_state == "already_has_pkg"){
9627 if(state == 'low_battery'){
9628 hideProgressBar();
9629 sv_fotaUpdateCancel = false;
9630 service.removeTimerThings('fota_current_upgrade_state',function(){});
9631 showInfo('ota_pkg_low_battery');
9632 window.clearTimeout(sv_timer);
9633 return;
9634 }else if(state == 'prepare_install'){
9635 hideProgressBar();
9636 sv_fotaUpdateCancel = false;
9637 service.removeTimerThings('fota_current_upgrade_state',function(){});
9638 showInfo('ota_pkg_download_success');
9639 window.clearTimeout(sv_timer);
9640 sv_batteryCheckTimer = setInterval(function () {
9641 sf_checkBatteryStatusForFota();
9642 }, 1000);
9643 return;
9644 }
9645 }else if(state == 'downloading') {
9646 sf_refreshFotaDownloadProgress();
9647 }else if(state == 'download_failed') {
9648 hideProgressBar();
9649 sv_fotaUpdateCancel = false;
9650 showAlert('ota_download_failed');
9651 window.clearTimeout(sv_timer);
9652 return;
9653 }else if(state == 'low_battery'){
9654 hideProgressBar();
9655 sv_fotaUpdateCancel = false;
9656 service.removeTimerThings('fota_current_upgrade_state',function(){});
9657 showInfo('ota_low_battery');
9658 window.clearTimeout(sv_timer);
9659 return;
9660 }else if(state == 'prepare_install'){
9661 hideProgressBar();
9662 sv_fotaUpdateCancel = false;
9663 service.removeTimerThings('fota_current_upgrade_state',function(){});
9664 showInfo('ota_download_success');
9665 window.clearTimeout(sv_timer);
9666 sv_batteryCheckTimer = setInterval(function () {
9667 sf_checkBatteryStatusForFota();
9668 }, 1000);
9669 return;
9670 }else{
9671 sv_fotaUpdateCancel = false;
9672 hideProgressBar();
9673 window.clearTimeout(sv_timer);
9674 return;
9675 }
9676 sv_timer = window.setTimeout(getOTAUpgradeState , 1000);
9677 }
9678 };
9679
9680 if(sv_fotaUpdateCancel && isLoggedIn == true){
9681 sv_timer = window.setTimeout(getOTAUpgradeState , 100);
9682 }else{
9683 window.clearTimeout(sv_timer);
9684 }
9685 }
9686
9687 // ��ʾFota��������
9688 function sf_showFotaUpdateResult(i_otaResult) {
9689 if ((!($("#loading").is(":visible"))) && (!($("#confirm").is(":visible")))) {
9690 var s_message = i_otaResult ? "ota_update_success" : "ota_update_failed";
9691 sv_fotaResultAlertPopuped = true;
9692 showAlert(s_message, function () {
9693 sv_fotaResultAlertPopuped = false;
9694 if (config.UPGRADE_TYPE == "OTA") {
9695 service.clearUpdateResult({}, $.noop());
9696 }
9697 });
9698 } else {
9699 window.setTimeout(function () {
9700 sf_showFotaUpdateResult(i_otaResult)
9701 }, 1000);
9702 }
9703 }
9704
9705 // ��ʾ��ǰ����״̬
9706 function sf_showFotaUpgradeStatus() {
9707 var s_data = service.getMandatory();
9708 var s_isMandatory = s_data.is_mandatory;
9709 var s_sizeInfo =service.getPackSizeInfo();
9710 var s_percents;
9711
9712 if (parseInt(s_sizeInfo.fota_pkg_total_size) == 0) {
9713 s_percents = 0;
9714 } else {
9715 s_percents = parseInt(parseInt(s_sizeInfo.fota_dl_pkg_size) * 100 / parseInt(s_sizeInfo.fota_pkg_total_size));
9716 }
9717 if (s_percents > 100) {
9718 s_percents = 100;
9719 }
9720
9721 if (s_isMandatory) {
9722 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning"));
9723 } else {
9724 var cancelHtml = "";
9725 if (config.UPGRADE_TYPE == "OTA") {
9726 cancelHtml = "<br/><br/><button id='btnStopUpgrade' onclick='stopOTAUpgrade();' class='btn-1 btn-primary'>" + $.i18n.prop("cancel") + "</button>";
9727 }
9728 showProgressBar("ota_update", "<br/>" + $.i18n.prop("ota_update_warning") + cancelHtml);
9729 }
9730
9731 //setProgressBar(0);
9732 if (s_percents >= 0) {
9733 setProgressBar(s_percents);
9734 }
9735 }
9736
9737
9738
9739
9740
9741 function sf_startFotaUpgrade(){
9742 service.setUpgradeSelectOp({selectOp:'1'},function(result){
9743 if (result.result == "success"){
9744 sf_showFotaCurrentStatus();
9745 }});
9746 }
9747
9748 function cancelFotaUpgrade(){
9749 service.setUpgradeSelectOp({selectOp:'0'},function(result){ });
9750 }
9751
9752
9753 function refreshFotaStatusForUserSelector(choice){
9754 var info = getCurrentStatusInfo();
9755 if(choice){
9756 var modeData = service.getOpMode();
9757 if (!checkConnectedStatus(info.connectStatus, modeData.rj45_state, info.connectWifiStatus)) {
9758 showAlert("ota_network_disconnected");
9759 return;
9760 }
9761
9762 if(info.fota_user_selector == 'none'){
9763 sf_startFotaUpgrade();
9764 }else if(info.fota_user_selector == 'accept'){
9765 sf_showFotaCurrentStatus();
9766 }else if(info.fota_user_selector == 'cancel'){
9767 showAlert("ota_have_cancel");
9768 }else if(info.fota_user_selector == 'downloading_cancel'){
9769 showAlert("ota_have_cancel");
9770 }
9771 }else{
9772 if(info.fota_user_selector == 'none'){
9773 cancelFotaUpgrade();
9774 }else if(info.fota_user_selector == 'accept'){
9775 sf_showFotaCurrentStatus();
9776 }else if(info.fota_user_selector == 'cancel'){
9777 // todo:
9778 }else if(info.fota_user_selector == 'downloading_cancel'){
9779 // todo:
9780 }
9781 }
9782 }
9783
9784
9785 // ��ʾ���°汾�������ж��Ƿ�������ʾ
9786 function showFotaStatusForUserToConfirm(upgradeState) {
9787 var upgState = upgradeState.current_upgrade_state;
9788 if (upgState == 'upgrade_pack_redownload') {
9789 showConfirm("ota_interrupted", {ok: function () {
9790 refreshFotaStatusForUserSelector(1);
9791 }, no: function () {
9792 refreshFotaStatusForUserSelector(0);
9793 }});
9794 } else {
9795 var upgradingState = ["prepare_install", "low_battery",
9796 "connecting_server", "connect_server_success", "downloading", "accept"];
9797 if ($.inArray(upgState, upgradingState) != -1) {
9798 sf_showFotaCurrentStatus();
9799 } else {
9800
9801 showConfirm($.i18n.prop('ota_new_version'), {ok: function () {
9802 refreshFotaStatusForUserSelector(1);
9803 config.ISNOW_NOTICE = false;
9804 }, no: function () {
9805 refreshFotaStatusForUserSelector(0);
9806 config.ISNOW_NOTICE = false;
9807 }});
9808 }
9809 }
9810 }
9811
9812 showOTAAlert = function () {
9813 config.ISNOW_NOTICE = true;
9814 var is_mandatory = service.getMandatory().is_mandatory;
9815 if (is_mandatory) {
9816 sf_showFotaCurrentStatus();
9817 } else {
9818 var upgradeState = {};
9819 upgradeState = service.getCurrentUpgradeState();
9820 showFotaStatusForUserToConfirm(upgradeState);
9821 }
9822 };
9823
9824 // ��ֹFota����
9825 stopOTAUpgrade = function () {
9826 service.setUpgradeSelectOp({selectOp:'2'},function(result){ });
9827 sv_fotaUpdateCancel = false;
9828 window.clearTimeout(sv_timer);
9829 hideLoading();
9830 showAlert('ota_cancel');
9831 };
9832
9833 // �������������Ƿ����ѹ�
9834 function setTrafficAlertPopuped(val){
9835 sv_trafficAlertPopuped = !!val;
9836 sv_trafficAlertPopuped_100 = !!val;
9837 if(!val){
9838 sv_resetTrafficAlertPopuped = true;
9839 }
9840 }
9841
9842 function setTrafficAlert100Popuped(val){
9843 sv_trafficAlertPopuped_100 = !!val;
9844 if(!val){
9845 sv_resetTrafficAlertPopuped = true;
9846 }
9847 }
9848
9849 // ���������ṹ
9850 function getTrafficResult(info){
9851 var s_trafficResult = {
9852 showConfirm : false,
9853 limitPercent : info.limitVolumePercent
9854 };
9855 if(info.limitVolumeType == '1'){
9856 var monthlyTraffic = parseInt(info.data_counter.monthlySent, 10) + parseInt(info.data_counter.monthlyReceived, 10);
9857 s_trafficResult.usedPercent = monthlyTraffic / info.limitVolumeSize * 100;
9858 if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
9859 s_trafficResult.showConfirm = true;
9860 s_trafficResult.type = 'data';
9861 }
9862 }else{
9863 s_trafficResult.usedPercent = info.data_counter.monthlyConnectedTime / info.limitVolumeSize * 100;
9864 if(s_trafficResult.usedPercent > s_trafficResult.limitPercent){
9865 s_trafficResult.showConfirm = true;
9866 s_trafficResult.type = 'time';
9867 }
9868 }
9869 return s_trafficResult;
9870 }
9871
9872 // ��ʼ�� ViewModel����������ͼ����
9873 function init() {
9874 if(config.PRODUCT_TYPE == 'DATACARD') {
9875 $('#statusBar').addClass('padding-right-90');
9876 $('#language').addClass('data-card-language');
9877 }
9878 //preload img
9879 var imgAlert = $('<img />').attr('src', 'pic/res_alert.png');
9880 var imgConfirm = $('<img />').attr('src', 'pic/res_confirm.png');
9881 var imgInfo = $('<img />').attr('src', 'pic/res_info.png');
9882
9883 window.setTimeout(function () {
9884
9885 var fwVm = new statusViewModel();
9886
9887 ko.applyBindings(fwVm, $('#statusBar')[0]);
9888
9889 window.setInterval(function () {
9890 var info = getCurrentStatusInfo();
9891 var s_roamStatus = info.roamingStatus ? true : false;
9892 var $langLogoBar = $("#langLogoBar");
9893 isLoggedIn = info.isLoggedIn;
9894
9895
9896 //fwVm.attachedDevices(info.attachedDevices);
9897 fwVm.batteryLevel(info.batteryLevel + '%');
9898 fwVm.batteryPers(sf_getBatteryLevelImage(info.batteryPers, info.batteryStatus));
9899 fwVm.batteryStatus(info.batteryStatus);
9900 fwVm.isShowFotaNewversionIcon(info.new_version_state && info.fota_user_selector && info.fota_package_already_download != "yes" && config.ISNOW_NOTICE && fwVm.updateType() == 'mifi_fota');
9901 fwVm.isShowRj45ConnectionIcon(config.RJ45_SUPPORT);
9902 fwVm.networkOperator(sf_getNetWorkProvider(info.spn_b1_flag,info.spn_name_data,info.spn_b2_flag,info.networkOperator,s_roamStatus));
9903 fwVm.networkType(getNetworkType(info.networkType));
9904 fwVm.pinStatus(info.pinStatus);
9905 fwVm.roamingStatus(info.roamingStatus ? "R" : "");
9906 fwVm.showAttachedDevices(info.wifiStatus);
9907 fwVm.simStatus(sf_convertSimStatusToImage(info.simStatus));
9908 fwVm.signalCssClass(sf_getSignalCssClass(info.signalImg, info.networkType, info.simStatus));
9909 fwVm.isLoggedIn(info.isLoggedIn);
9910 fwVm.wifiStatusCssClass(sf_getWifiStatusCssClass(info.wifiStatus, info.wirelessDeviceNum));
9911 fwVm.wifiStatusImg(sf_getWifiStatusImage(info.wifiStatus, info.wirelessDeviceNum));
9912
9913 if(config.HAS_SMS ){
9914 if(!sv__hasCheckedSMSCapacity && info.isLoggedIn){
9915 checkSMSCapacity(info.smsUnreadCount);
9916 } else {
9917 fwVm.smsUnreadCount(info.smsUnreadCount);
9918 }
9919 }
9920
9921 sf_getConnectionCssClass(fwVm, info.connectStatus, info.data_counter, info.connectWifiSSID, info.connectWifiStatus, info.rj45ConnectStatus);
9922 refreshWifiConnectStatus(fwVm, info.connectStatus,info.connectWifiSSID,info.connectWifiStatus);
9923 checkTrafficLimitAlert(fwVm, info);
9924 updateStatusBarTrans({simStatus: info.simStatus, wifiStatus: info.wifiStatus, deviceSize: info.wirelessDeviceNum, networkType: info.networkType});
9925
9926 if(info.isLoggedIn){
9927 $("#statusBar:hidden").show();
9928 } else {
9929 $("#statusBar:visible").hide();
9930 }
9931 }, 500);
9932
9933 if(config.HAS_SMS){
9934 window.setInterval(function(){
9935 if(fwVm.isLoggedIn()){
9936 checkSMSCapacity();
9937 }
9938 }, 10000);
9939 checkSmsModelReady();
9940 }
9941
9942 window.setInterval(function() {
9943 var data = getCurrentStatusInfo();
9944 var upgradingState = ["prepare_install", "low_battery", "download_success","downloading"];
9945
9946 if (fwVm.isLoggedIn() == true && !($("#progress").is(":visible")) && data.defaultWanName != ""){
9947 if ($.inArray(data.current_upgrade_state, upgradingState) != -1){
9948 if(null == sv_fotaUpdateCancel){
9949 if(!data.is_mandatory){
9950 $.modal.close();
9951 }
9952 sf_showFotaCurrentStatus();
9953 }else if(false == sv_fotaUpdateCancel){
9954 sv_fotaUpdateCancel = null;
9955 }
9956 }
9957 }
9958 }, 1000);
9959
9960 var checkFotaUpgradeResult = function () {
9961 var info = service.getStatusInfo();
9962 if (info.isLoggedIn) {
9963 service.getUpgradeResult({}, function (data) {
9964 if (data.upgrade_result == "success") {
9965 sf_showFotaUpdateResult(true);
9966 } else if (data.upgrade_result == "fail") {
9967 sf_showFotaUpdateResult(false);
9968 } else {
9969 window.setTimeout(checkFotaUpgradeResult, 1000);
9970 }
9971 }, function () {
9972 window.setTimeout(checkFotaUpgradeResult, 1000);
9973 });
9974 } else {
9975 window.setTimeout(checkFotaUpgradeResult, 1000);
9976 }
9977 };
9978 if(fwVm.updateType() == "mifi_fota"){
9979 checkFotaUpgradeResult();
9980 window.setInterval(function () {
9981 var info = getCurrentStatusInfo();
9982 if (info.isLoggedIn && info.defaultWanName != "") {
9983 if(info.new_version_state && info.fota_package_already_download != "yes" && !config.ALREADY_NOTICE){
9984 service.getUpgradeResult({}, function (data) {
9985 if (data.upgrade_result == "success") {
9986 sf_showFotaUpdateResult(true);
9987 } else if (data.upgrade_result == "fail") {
9988 sf_showFotaUpdateResult(false);
9989 } else {
9990 if(sv_fotaResultAlertPopuped == false){
9991 config.ALREADY_NOTICE = true;
9992 showOTAAlert();
9993 }
9994 }
9995 });
9996 }
9997 }
9998 }, 1000);
9999 }
10000 function checkSMSCapacity(unreadCount){
10001 service.getSmsCapability({}, function(info){
10002 var showSmsConfirm = false;
10003 if(info.nvTotal != 0 && info.nvUsed >= info.nvTotal){
10004 $("#sms_unread_count").attr("tipTitle", "sms_capacity_is_full");
10005 showSmsConfirm = true;
10006 } else if(info.nvTotal != 0 && info.nvUsed + 5 >= info.nvTotal) {
10007 $("#sms_unread_count").attr("tipTitle", "sms_capacity_will_full");
10008 showSmsConfirm = true;
10009 } else {
10010 $("#sms_unread_count").attr("tipTitle", "sms_unread_count");
10011 }
10012 fwVm.showSmsDeleteConfirm(showSmsConfirm);
10013 if(typeof unreadCount != "undefined"){
10014 fwVm.smsUnreadCount(unreadCount);
10015 }
10016 sv__hasCheckedSMSCapacity = true;
10017 });
10018 }
10019 }, 1200);
10020
10021 tooltip.init();
10022
10023 // ������Ϣģ����ʼ��״̬
10024 function checkSmsModelReady(){
10025 var info = getCurrentStatusInfo();
10026 if(info.isLoggedIn){
10027 service.getSMSReady({}, function (data) {
10028 if (data.sms_cmd_status_result == "1") {
10029 window.setTimeout(function(){checkSmsModelReady();}, 1000);
10030 } else {
10031 sv__initSMSCompleted = true;
10032 }
10033 });
10034 } else {
10035 window.setTimeout(function(){checkSmsModelReady();}, 1000);
10036 }
10037 }
10038
10039 // ������������״̬
10040 checkTrafficLimitAlert = function(fwVm, info){
10041 if(window.location.hash == '#entry'){
10042 return false;
10043 }
10044 var APStationEnabled = config.AP_STATION_SUPPORT ? service.getStatusInfo().ap_station_enable : 'undefined';
10045 var trafficResult = getTrafficResult(info);
10046 var inShow = $("#confirm-container:visible").length > 0;
10047 var notPPP = (config.PRODUCT_TYPE == 'CPE' && checkCableMode(info.blc_wan_mode)) ? true : false;
10048
10049 // ��ȡAp Stationʹ��״̬���������ѷ�ʽ
10050 if (config.AP_STATION_SUPPORT && (typeof APStationEnabled == "undefined" || APStationEnabled === '')) {
10051 service.refreshAPStationStatus({}, $.noop());
10052 return false;
10053 }
10054 APStationEnabled = APStationEnabled == 1;
10055
10056 if (!info.isLoggedIn || inShow || (sv_trafficAlertPopuped && sv_trafficAlertPopuped_100) || !info.limitVolumeEnable || (!APStationEnabled && !(info.connectStatus == "ppp_connected")) || notPPP) {
10057 return false;
10058 }
10059
10060 if(sv_resetTrafficAlertPopuped){
10061 window.setTimeout(function () {
10062 sv_resetTrafficAlertPopuped = false;
10063 }, 2000);
10064 return false;
10065 }
10066
10067 if(trafficResult.showConfirm){
10068
10069 var confirmMessage = null;
10070
10071 if(trafficResult.usedPercent > 100 && !sv_trafficAlertPopuped_100){
10072
10073 sv_trafficAlertPopuped = true;
10074 sv_trafficAlertPopuped_100 = true;
10075
10076 confirmMessage = {msg: APStationEnabled ? 'traffic_beyond_msg' : 'traffic_beyond_disconnect_msg'};
10077
10078 } else if (!sv_trafficAlertPopuped) {
10079
10080 sv_trafficAlertPopuped = true;
10081 sv_trafficAlertPopuped_100 = false;
10082 confirmMessage = {msg: APStationEnabled ? 'traffic_limit_msg' : 'traffic_limit_disconnect_msg',
10083 params: [trafficResult.limitPercent]};
10084 }
10085
10086 if (confirmMessage != null) {
10087 if (APStationEnabled) {
10088 showAlert(confirmMessage);
10089 } else {
10090 showConfirm(confirmMessage, function () {
10091 showLoading("disconnecting");
10092 service.disconnect({}, function (data) {
10093 if (data.result) {
10094 successOverlay();
10095 } else {
10096 errorOverlay();
10097 }
10098 });
10099 });
10100 }
10101 }
10102 }
10103 return true;
10104 };
10105
10106 // ����״̬�е�tooltip
10107 function updateStatusBarTrans(status){
10108 $("#statusItemSimStatus").attr("tipTitle", "sim_status_" + status.simStatus);
10109 if (status.wifiStatus) {
10110 if (status.deviceSize == 0) {
10111 $("#wifi_status").attr("tipTitle","wifi_status_on");
10112 } else {
10113 $("#wifi_status").attr("tipTitle","wifi_status" + status.deviceSize);
10114 }
10115 } else {
10116 $("#wifi_status").attr("tipTitle","wifi_status_off");
10117 }
10118 }
10119
10120
10121 // ˢ��wifi��������״̬
10122 function refreshWifiConnectStatus(fwVm, status, wifiSSID, wifiStatus) {
10123 fwVm.connectStatus(status);
10124 if (status == "ppp_disconnecting") {
10125 fwVm.connectStatusTrans("disconnecting");
10126 fwVm.connectStatusText($.i18n.prop("disconnecting"));
10127 } else if (status == "ppp_connecting") {
10128 fwVm.connectStatusTrans("connecting");
10129 fwVm.connectStatusText($.i18n.prop("connecting"));
10130 } else if (status == "ppp_connected") {
10131 fwVm.connectStatusTrans("connected");
10132 fwVm.connectStatusText($.i18n.prop("connected"));
10133 } else if(wifiSSID){
10134 if(wifiStatus =="dhcping" || wifiStatus =="connecting"){
10135 fwVm.connectStatus("wifi_connecting");
10136 fwVm.connectStatusTrans("connecting");
10137 fwVm.connectStatusText($.i18n.prop("connecting"));
10138 }else if(wifiStatus =="connect"){
10139 fwVm.connectStatus("wifi_connect");
10140 fwVm.connectStatusTrans("connected");
10141 fwVm.connectStatusText($.i18n.prop("connected"));
10142 }else{
10143 fwVm.connectStatus("ppp_disconnected");
10144 fwVm.connectStatusTrans("disconnected");
10145 fwVm.connectStatusText($.i18n.prop("disconnected"));
10146 }
10147 }else{
10148 fwVm.connectStatusTrans("disconnected");
10149 fwVm.connectStatusText($.i18n.prop("disconnected"));
10150 }
10151 }
10152
10153 // ��ȡ��ǰ����״̬
10154 getNetworkType = function(networkType) {
10155 var networkTypeTmp = networkType.toLowerCase();
10156 if (networkTypeTmp == '' || networkTypeTmp == 'limited service') {
10157 networkTypeTmp = 'limited_service';
10158 }
10159 if(networkTypeTmp == 'no service') {
10160 networkTypeTmp = 'no_service';
10161 }
10162 if (networkTypeTmp == 'limited_service' || networkTypeTmp == 'no_service') {
10163 $("#networkType", "#statusBar").attr("data-trans", "network_type_" + networkTypeTmp);
10164 return $.i18n.prop("network_type_" + networkTypeTmp);
10165 } else {
10166 $("#networkType", "#statusBar").removeAttr("data-trans");
10167 return networkType;
10168 }
10169 };
10170
10171 if(config.HAS_SMS && menu.checkIsMenuExist("sms_list")){
10172 window.setInterval(function () {
10173 var info = getCurrentStatusInfo();
10174 if(window.location.hash == "#entry" || sf_simStatusInvalid(info.simStatus)){
10175 return;
10176 }
10177 for(key in sv_messagePopStack){
10178 var val = sv_messagePopStack[key];
10179 if($.now() - val > 5000){
10180 delete(sv_messagePopStack["m" + val]);
10181 var node = $(".bubbleItem#m" + val, "#buttom-bubble");
10182 node.fadeOut(1000, function(){
10183 $(this).remove();
10184 });
10185 }
10186 }
10187 if(info.isLoggedIn){
10188 if(info.newSmsReceived && !sv_newSMSMessageInDealing){
10189 sv_newSMSMessageInDealing = true;
10190 service.resetNewSmsReceivedVar();
10191 sf_checkNewMessages();
10192 }
10193 if(info.smsReportReceived){
10194 service.resetSmsReportReceivedVar();
10195 sf_responseSmsReport();
10196 }
10197 }
10198 }, 1000);
10199
10200 if(config.SMS_DATABASE_SORT_SUPPORT){
10201 window.setInterval(function(){
10202 if(menu.checkIsMenuExist("sms_list")){
10203 var info = getCurrentStatusInfo();
10204 if(info.isLoggedIn && sv__initSMSCompleted && !sv_newSMSMessageInDealing && !sf_simStatusInvalid(info.simStatus)){
10205 sv_newSMSMessageInDealing = true;
10206 sf_checkNewMessages();
10207 }
10208 }
10209 }, 20001);
10210 }
10211 }
10212
10213 function sf_checkNewMessages(){
10214
10215 var s_tags = 1;
10216 var s_smsCount = 5;
10217
10218 if(!config.dbMsgs || config.dbMsgs.length == 0){
10219 s_smsCount = 500;
10220 s_tags = 10;
10221 }
10222 service.getSMSMessages({
10223 page : 0,
10224 smsCount : s_smsCount,
10225 nMessageStoreType : 0,
10226 tags : s_tags,
10227 orderBy : "order by id desc"
10228 }, function(data){
10229 if(data && data.messages){
10230 sf_filterNewMessage(data.messages, 0);
10231 }
10232 sv_newSMSMessageInDealing = false;
10233 });
10234 service.getSMSMessages({
10235 page : 0,
10236 smsCount : s_smsCount,
10237 nMessageStoreType : 1,
10238 tags : s_tags,
10239 orderBy : "order by id desc"
10240 }, function(data){
10241 if(data && data.messages){
10242 sf_filterNewMessage(data.messages, 1);
10243 }
10244 sv_newSMSMessageInDealing = false;
10245 });
10246 }
10247
10248 if(config.HAS_SMS){
10249 $(".bubbleItem", "#buttom-bubble").live("mouseover", function(){
10250 var $this = $(this);
10251 delete(sv_messagePopStack[$this.attr("id")]);
10252 }).live("mouseout", function(){
10253 var $this = $(this);
10254 var now = $.now();
10255 sv_messagePopStack["m" + now] = now;
10256 $this.attr("id", "m" + now);
10257 $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").data("targetid", "m" + now);
10258 });
10259
10260 $(".bubbleItem h3 a.bubbleCloseBtn", "#buttom-bubble").die().live("click", function(){
10261 var id = $(this).data("targetid");
10262 delete(sv_messagePopStack[id]);
10263 var node = $(".bubbleItem#" + id, "#buttom-bubble");
10264 node.fadeOut(1000, function(){
10265 $(this).remove();
10266 });
10267 });
10268 }
10269 }
10270
10271
10272 return {
10273 init:init,
10274 setTrafficAlertPopuped: setTrafficAlertPopuped,
10275 setTrafficAlert100Popuped: setTrafficAlert100Popuped,
10276 getTrafficResult: getTrafficResult,
10277 showOTAAlert:showOTAAlert
10278 };
10279});
10280
10281// ����ͳ������ģ��
10282define("status_traffic_alert","jquery knockout service statusBar echarts".split(" "),
10283
10284 function ($, ko, service, status, echarts) {
10285
10286 var sv_trafficGraph = null;
10287 var sv_sourceData = null;
10288 var sv_usedDataModified = false;
10289 var sv_usedTimeModified = false;
10290
10291 var sv_trafficStaticalInfo = {
10292 // ����ͼ��ʼֵ
10293 data: {
10294 alarm: {
10295
10296 itemStyle: {
10297 normal: {
10298 color: '#8CC916'
10299 }
10300 },
10301 name: '������',
10302 value: 19.7
10303 },
10304 alert: {
10305
10306 itemStyle: {
10307 normal: {
10308 color: '#FF5500'
10309 }
10310 },
10311 name: '����ֵ',
10312 value: 1
10313 },
10314 free: {
10315
10316 itemStyle: {
10317 normal: {
10318 color: '#D8D8D8'
10319 }
10320 },
10321 name: 'δʹ��',
10322 value: 50
10323 },
10324 full: {
10325
10326
10327 itemStyle: {
10328 normal: {
10329 color: '#DF4313'
10330 }
10331 },
10332 name: '��������',
10333 value: 30
10334 },
10335 left1: {
10336
10337 itemStyle: {
10338 normal: {
10339 color: '#D8D8D8'
10340 }
10341 },
10342 name: '����ֵ��δʹ��',
10343 value: 50,
10344 },
10345 start: {
10346
10347 itemStyle: {
10348 normal: {
10349 color: '#D8D8D8'
10350 }
10351 },
10352 name: '����ֵ��δʹ��',
10353 value: 50
10354 },
10355 used: {
10356
10357 itemStyle: {
10358 normal: {
10359 color: '#8CC916'
10360 }
10361 },
10362 name: '��ʹ��',
10363 value: 30
10364 }
10365 },
10366 cacheEle: {},
10367 // Ԫ�ػ�ȡ
10368 getEle: function (i_elementId) {
10369 if (this.cacheEle.hasOwnProperty('id')) {
10370 return this.cacheEle[i_elementId];
10371 } else {
10372 this.cacheEle[i_elementId] = $("#" + i_elementId);
10373 return this.cacheEle[i_elementId];
10374 }
10375 },
10376 // ��ȡ�����澯״ֵ̬
10377 fetchTrafficAlertInfo: function(){
10378 sv_sourceData = getTrafficAlertInfo();
10379 return sv_sourceData;
10380 },
10381 // ��ȡ����ֵ�Ͷ�Ӧ��λֵ
10382 getTrafficStatisticalDatalnfo: function (i_valueInfo) {
10383 return {
10384 data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
10385 unit: /[A-Z]{1,2}/.exec(i_valueInfo)[0]
10386 }
10387 },
10388
10389 // ��ȡʱ��ʱ���֡���
10390 getTrafficTimeHours: function (i_time) {
10391 var s_timeArray = i_time.split(':');
10392 return {
10393 h: parseInt(s_timeArray[0], 10),
10394 m: parseInt(s_timeArray[1], 10),
10395 s: parseInt(s_timeArray[2], 10)
10396 }
10397 },
10398 // ��ȡͳ��ʱ���Ͷ�Ӧ��λֵ
10399 getTrafficTimeInfo: function (i_valueInfo) {
10400 return {
10401 data: /\d+(.\d+)?/.exec(i_valueInfo)[0],
10402 unit: /[a-z]{4,6}/.exec(i_valueInfo)[0]
10403 }
10404 },
10405 // ʱ�任����S
10406 getTrafficTimeToSeconds: function (i_time) {
10407 var s_FormattedTime = this.getTrafficTimeHours(i_time);
10408 return s_FormattedTime.h * 3600 + s_FormattedTime.m * 60 + s_FormattedTime.s;
10409 },
10410 // ͨ�����ƻ�ȡ������λ
10411 getTrafficUnitByScale: function (i_scale) {
10412 if (i_scale == '1024') {
10413 return 'GB';
10414 } else if (i_scale == '1048576') {
10415 return 'TB';
10416 } else {
10417 return 'MB';
10418 }
10419 },
10420 // ��λ��Ӧֵ��ȡ
10421 getTrafficValueByStatisticalUnit: function (i_unit) {
10422 i_unit = i_unit.toLowerCase();
10423 if(i_unit == 'minute'){
10424 return '60';
10425 } else if (i_unit == 'gb') {
10426 return '1024';
10427 } else if(i_unit == 'hour'){
10428 return '3600';
10429 } else if (i_unit == 'tb') {
10430 return '1048576';
10431 } else {
10432 return '1';
10433 }
10434 },
10435
10436 // ���������Ƿ��ɱ༭
10437 isFormEditable: function (fwVm) {
10438 var s_dataPageEditState = fwVm.dataLimitTypeChecked() == '1' && (fwVm.viewEditUsedData() || fwVm.viewEditAlertData() || fwVm.viewEditTotalData());
10439 var s_timePageEditState = fwVm.dataLimitTypeChecked() == '0' && (fwVm.viewEditUsedTime() || fwVm.viewEditAlertTime() || fwVm.viewEditTotalTime());
10440 if (s_dataPageEditState || s_timePageEditState) {
10441 $('.border-color-transition:visible').addClass('attention-focus');
10442 addTimeout(function () {
10443 $('.border-color-transition:visible').removeClass('attention-focus');
10444 }, 1500);
10445 return true;
10446 } else {
10447 var s_result = false;
10448 if (fwVm.dataLimitTypeChecked() == 1) {
10449 if (fwVm.alertDataReach() == '0') {
10450 fwVm.editAlertDataHandler();
10451 s_result = true;
10452 }
10453 if (fwVm.limitDataMonth() == '0') {
10454 fwVm.editTotalDataHandler();
10455 s_result = true;
10456 }
10457 } else {
10458 if (fwVm.alertTimeReach() == '0') {
10459 fwVm.editAlertTimeHandler();
10460 s_result = true;
10461 }
10462 if (fwVm.limitTimeMonth() == '0') {
10463 fwVm.editTotalTimeHandler();
10464 s_result = true;
10465 }
10466 }
10467
10468 if (s_result) {
10469 $('.border-color-transition:visible').addClass('attention-focus');
10470 addTimeout(function () {
10471 $('.border-color-transition:visible').removeClass('attention-focus');
10472 }, 1500);
10473 }
10474 return s_result;
10475 }
10476 },
10477
10478 // ˢ������ͼ��Ϣ������������ֵ����ʾ����
10479
10480 refreshFlowDiagramInfo: function (fwVm) {
10481 var s_alarm = 0;
10482 var s_left = 0;
10483 var s_left1 = 0;
10484 var s_reach = 0;
10485 var s_total = 0;
10486 var s_used = 0;
10487
10488
10489 var s_startName = $.i18n.prop("echarts_no");
10490
10491 if (sv_sourceData.dataLimitChecked == '1') { //if (fwVm.dataLimitChecked() == '1') { //����
10492 s_startName = $.i18n.prop("echarts_used");
10493 sv_trafficGraphOptions.series[0].data = [];
10494
10495 if (fwVm.dataLimitTypeChecked() == '1') { // ����
10496 sv_trafficGraphOptions.title.text = "";
10497 sv_trafficGraphOptions.series[0].data = [];
10498
10499 if (fwVm.limitDataMonth() == 0) {
10500 var s_usedData = sv_trafficStaticalInfo.data.used;
10501 s_usedData.value = 1;
10502 s_usedData.name = $.i18n.prop("echarts_used");
10503 s_usedData.selected = false;
10504 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10505 } else {
10506 s_total = fwVm.limitDataMonth() * fwVm.selectedDataUnit() * 1048576;
10507 s_used = parseInt(sv_sourceData.monthlySent, 10) + parseInt(sv_sourceData.monthlyReceived, 10);
10508 s_reach = s_total * fwVm.alertDataReach() / 100;
10509
10510 if (s_used >= s_total) {
10511 var s_fullData = sv_trafficStaticalInfo.data.full;
10512 s_fullData.value = 100;
10513 s_fullData.name = $.i18n.prop("echarts_full");
10514 sv_trafficGraphOptions.series[0].data.push(s_fullData);
10515 s_startName = $.i18n.prop("echarts_full");
10516 } else {
10517 if (s_reach > s_used) {
10518 s_left1 = s_reach - s_used;
10519 s_left = s_total - s_reach;
10520 } else {
10521 s_alarm = s_used - s_reach;
10522 s_left = s_total - s_used;
10523 }
10524
10525 var s_usedData = sv_trafficStaticalInfo.data.used;
10526 if (s_reach - s_used > 0) {
10527 s_usedData.value = s_used;
10528 } else {
10529 s_usedData.value = s_reach;
10530 }
10531 s_usedData.name = $.i18n.prop("echarts_used");
10532 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10533
10534 if (s_left1 > 0) {
10535 var s_left1Data = sv_trafficStaticalInfo.data.left1;
10536 s_left1Data.value = s_left1;
10537 s_left1Data.name = $.i18n.prop("echarts_left1");
10538 sv_trafficGraphOptions.series[0].data.push(s_left1Data);
10539 }
10540
10541 var s_alertData = sv_trafficStaticalInfo.data.alert;
10542 s_alertData.value = s_total / 200;
10543 s_alertData.name = $.i18n.prop("echarts_alert");
10544 sv_trafficGraphOptions.series[0].data.push(s_alertData);
10545
10546 if (s_alarm > 0) {
10547 var s_alarmData = sv_trafficStaticalInfo.data.alarm;
10548 s_alarmData.value = s_alarm;
10549 s_alarmData.name = $.i18n.prop("echarts_alarm");
10550 sv_trafficGraphOptions.series[0].data.push(s_alarmData);
10551 }
10552
10553 var s_freeData = sv_trafficStaticalInfo.data.free;
10554 s_freeData.value = s_left;
10555 s_freeData.name = $.i18n.prop("echarts_free");
10556 sv_trafficGraphOptions.series[0].data.push(s_freeData);
10557 }
10558 }
10559
10560 }else{// ʱ��
10561
10562 sv_trafficGraphOptions.series[0].data = [];
10563
10564 if (fwVm.limitTimeMonth() == 0) {
10565 var s_usedData = sv_trafficStaticalInfo.data.used;
10566 s_usedData.value = 1;
10567 s_usedData.selected = false;
10568 s_usedData.name = $.i18n.prop("echarts_used");
10569 sv_trafficGraphOptions.series[0].data.push(s_usedData);
10570 } else {
10571 s_total = fwVm.limitTimeMonth() * fwVm.selectedTimeUnit();
10572 s_used = sv_sourceData.monthlyConnectedTime;
10573 s_reach = s_total * fwVm.alertTimeReach() / 100;
10574
10575 if (s_used >= s_total) {
10576 var fullTime = sv_trafficStaticalInfo.data.full;
10577 fullTime.value = 100;
10578 fullTime.name = $.i18n.prop("echarts_full");
10579 sv_trafficGraphOptions.series[0].data.push(fullTime);
10580 s_startName = $.i18n.prop("echarts_full");
10581 } else {
10582 if (s_reach - s_used > 0) {
10583 s_left1 = s_reach - s_used;
10584 s_left = s_total - s_reach;
10585 } else {
10586 s_alarm = s_used - s_reach;
10587 s_left = s_total - s_used;
10588 }
10589
10590 var s_usedTime = sv_trafficStaticalInfo.data.used;
10591 if (s_reach - s_used > 0) {
10592 s_usedTime.value = s_used;
10593 } else {
10594 s_usedTime.value = s_reach;
10595 }
10596 s_usedTime.name = $.i18n.prop("echarts_used");
10597 sv_trafficGraphOptions.series[0].data.push(s_usedTime);
10598
10599 if (s_left1 > 0) {
10600 var s_left1Time = sv_trafficStaticalInfo.data.left1;
10601 s_left1Time.value = s_left1;
10602 s_left1Time.name = $.i18n.prop("echarts_left1");
10603 sv_trafficGraphOptions.series[0].data.push(s_left1Time);
10604 }
10605
10606 var s_alertTime = sv_trafficStaticalInfo.data.alert;
10607 s_alertTime.value = s_total / 200;
10608 s_alertTime.name = $.i18n.prop("echarts_alert");
10609 sv_trafficGraphOptions.series[0].data.push(s_alertTime);
10610
10611 if (s_alarm > 0) {
10612 var s_alarmTime = sv_trafficStaticalInfo.data.alarm;
10613 s_alarmTime.value = s_alarm;
10614 s_alarmTime.name = $.i18n.prop("echarts_alarm");
10615 sv_trafficGraphOptions.series[0].data.push(s_alarmTime);
10616 }
10617
10618 var s_freeTime = sv_trafficStaticalInfo.data.free;
10619 s_freeTime.value = s_left;
10620 s_freeTime.name = $.i18n.prop("echarts_free");
10621 sv_trafficGraphOptions.series[0].data.push(s_freeTime);
10622 }
10623 }
10624 }
10625 } else {
10626 var s_usedData = sv_trafficStaticalInfo.data.used;
10627 s_usedData.value = 1;
10628 s_usedData.selected = false;
10629 s_usedData.name = $.i18n.prop("echarts_no");
10630
10631 sv_trafficGraphOptions.series[0].data = [s_usedData];
10632 sv_trafficGraphOptions.title.text = '';
10633 }
10634 sv_trafficStaticalInfo.setFlowDiagramInfo(sv_trafficGraphOptions, s_startName);
10635 },
10636
10637
10638 // �ػ�����ͼ
10639 setFlowDiagramInfo: function (i_options, i_startName) {
10640 var s_startPart = sv_trafficStaticalInfo.data.start;
10641
10642 s_startPart.name = i_startName;
10643 s_startPart.selected = false;
10644 s_startPart.value = 0;
10645
10646 var s_arr = [s_startPart].concat(i_options.series[0].data);
10647 i_options.series[0].data = s_arr;
10648 sv_trafficGraph.setOption(i_options, true);
10649
10650 addTimeout(function () {
10651 sv_trafficGraph.resize();
10652 }, 1000);
10653 }
10654 };
10655
10656
10657 // ����ͼ��������
10658 var sv_trafficGraphOptions = {
10659 animation: false,
10660 color: ['red', 'red', 'red', 'red', 'red'],
10661 series: [
10662 {
10663 name: '��������',
10664 radius: ['0', '75'],
10665 selectedOffset: 3,
10666 type: 'pie',
10667 data: [
10668
10669 ],
10670 itemStyle: {
10671 normal: {
10672 labelLine: {
10673 show: false
10674 },
10675 label: {
10676 show: false
10677 }
10678 }
10679 }
10680 }
10681 ],
10682 title: {
10683 itemGap: 0,
10684 text: '',
10685 subtextStyle: {
10686 color: '#FFF',
10687 fontFamily: '΢���ź�',
10688 fontSize: 16,
10689 fontWeight: 'bolder'
10690 },
10691 textStyle: {
10692 color: '#FFF',
10693 fontFamily: '΢���ź�',
10694 fontSize: 20,
10695 fontWeight: 'bolder'
10696 },
10697 x: 'center',
10698 y: 'center'
10699 },
10700 tooltip: {
10701 formatter: "{b}"
10702 }
10703 };
10704
10705
10706 // ��ȡ������������
10707 function getTrafficAlertInfo() {
10708 return service.getTrafficAlertInfo();
10709 }
10710
10711
10712
10713 // ��������ViewModel
10714
10715 function trafficViewModel() {
10716
10717 var target = this;
10718
10719 var info = sv_trafficStaticalInfo.fetchTrafficAlertInfo();
10720 var dataMonth = info.limitDataMonth.split("_");
10721
10722 sv_usedDataModified = false;
10723 sv_usedTimeModified = false;
10724
10725 target.alertDataReach = ko.observable(info.alertDataReach || 0);
10726 target.alertTimeReach = ko.observable(info.alertTimeReach || 0);
10727 target.dataLimitChecked = ko.observable(info.dataLimitChecked == '0' ? '0' : '1');
10728 target.dataLimitTypeChecked = ko.observable(info.dataLimitTypeChecked == '0' ? '0' : '1');
10729 target.limitTimeMonth = ko.observable(info.limitTimeMonth || 0);
10730
10731
10732 // ע��˳��
10733 target.usedDataText = ko.observable(transUnit(parseInt(info.monthlySent, 10) + parseInt(info.monthlyReceived, 10), false));
10734 var sv_staticalDataInfo = sv_trafficStaticalInfo.getTrafficStatisticalDatalnfo(target.usedDataText());
10735 var sv_staticalInfoData = sv_staticalDataInfo.data;
10736 target.dataUsed = ko.observable(sv_staticalInfoData);
10737 var sv_staticalInfoUnit = sv_staticalDataInfo.unit;
10738 target.selectedDataUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_staticalInfoUnit));
10739 target.usedDataTextDescData = ko.observable("");
10740
10741 target.limitDataMonth = ko.observable(dataMonth[0] || 0);
10742 target.selectedDataUnit = ko.observable(dataMonth[1] || 1);
10743
10744 var limitDataMonthTmp = transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1024 * 1024, false);
10745 var limitDataMonthUnitTmp = limitDataMonthTmp.substring(limitDataMonthTmp.length-2);
10746 target.limitDataMonth(limitDataMonthTmp.substring(0, limitDataMonthTmp.length-2));
10747 target.selectedDataUnit(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(limitDataMonthUnitTmp));
10748
10749 target.usedDataTextDesc = ko.computed(sf_usedDataTextDesc);
10750 target.limitDataMonthDescData = ko.observable("");
10751 target.limitDataMonthDesc = ko.computed(sf_limitDataMonthDesc);
10752 target.alertDataReachDescData = ko.observable("");
10753 target.alertDataReachDesc = ko.computed(sf_alertDataReachDesc);
10754 target.leftDataDescData = ko.observable("");
10755 target.leftDataDesc = ko.computed(sf_leftDataDesc);
10756 target.monthlyConnectedTime = ko.observable(transSecond2Time(info.monthlyConnectedTime));
10757
10758 var sv_timeInfo1 = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(info.monthlyConnectedTime));
10759 target.usedTime = ko.observable(sv_timeInfo1.data);
10760 target.selectedTimeUsedUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfo1.unit));
10761
10762 target.usedTimeTextDescData = ko.observable("");
10763 target.usedTimeTextDesc = ko.computed(sf_usedTimeTextDesc);
10764
10765 var sv_timeInfoNew = sv_trafficStaticalInfo.getTrafficTimeInfo(transTimeUnit(parseFloat(target.limitTimeMonth()) * 3600));
10766 target.selectedTimeUnit = ko.observable(sv_trafficStaticalInfo.getTrafficValueByStatisticalUnit(sv_timeInfoNew.unit));
10767 target.limitTimeMonth(sv_timeInfoNew.data);
10768
10769
10770 target.limitTimeMonthDescData = ko.observable("");
10771 target.limitTimeMonthDescText = ko.observable("traffic_limit_time_h");
10772 target.limitTimeMonthDesc = ko.computed(sf_limitTimeMonthDesc);
10773 target.alertTimeReachDescData = ko.observable("");
10774 target.alertTimeReachDesc = ko.computed(sf_alertTimeReachDesc);
10775 target.leftTimeDescData = ko.observable("");
10776 target.leftTimeDesc = ko.computed(sf_leftTimeDesc);
10777 target.save = sf_save;
10778 target.viewEditUsedData = ko.observable(false);
10779 target.editUsedDataHandler = sf_editUsedDataHandler;
10780 target.editUsedDataSaveHandler = sf_editUsedDataSaveHandler;
10781 target.saveUsedData = sf_saveUsedData;
10782 target.editUsedDataCancelHandler = sf_editUsedDataCancelHandler;
10783 target.viewEditTotalData = ko.observable(false);
10784 target.editTotalDataHandler = sf_editTotalDataHandler;
10785 target.editTotalDataSaveHandler = sf_editTotalDataSaveHandler;
10786 target.editTotalDataCancelHandler = sf_editTotalDataCancelHandler;
10787 target.viewEditAlertData = ko.observable(false);
10788 target.editAlertDataHandler = sf_editAlertDataHandler;
10789 target.editAlertDataSaveHandler = sf_editAlertDataSaveHandler;
10790 target.editAlertDataCancelHandler = sf_editAlertDataCancelHandler;
10791 target.viewEditUsedTime = ko.observable(false);
10792 target.editUsedTimeHandler = sf_editUsedTimeHandler;
10793 target.saveUsedTime = sf_saveUsedTime;
10794 target.editUsedTimeSaveHandler = sf_editUsedTimeSaveHandler;
10795 target.editUsedTimeCancelHandler = sf_editUsedTimeCancelHandler;
10796 target.viewEditTotalTime = ko.observable(false);
10797 target.editTotalTimeHandler = sf_editTotalTimeHandler ;
10798 target.editTotalTimeSaveHandler = sf_editTotalTimeSaveHandler;
10799 target.editTotalTimeCancelHandler = sf_editTotalTimeCancelHandler;
10800 target.viewEditAlertTime = ko.observable(false);
10801 target.editAlertTimeHandler = sf_editAlertTimeHandler;
10802 target.editAlertTimeSaveHandler = sf_editAlertTimeSaveHandler;
10803 target.editAlertTimeCancelHandler = sf_editAlertTimeCancelHandler;
10804 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
10805
10806
10807 // ��������������
10808 function sf_alertDataReachDesc() {
10809 if(isNaN(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach())) {
10810 target.alertDataReachDescData(target.alertDataReach() + ', ');
10811 return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), ' ');
10812 }
10813
10814 var s_value = transUnit(target.limitDataMonth() * target.selectedDataUnit() * target.alertDataReach() * 1048576 / 100, false);
10815 target.alertDataReachDescData(target.alertDataReach() + ',' + s_value);
10816 return $.i18n.prop('traffic_alert_reach_text', target.alertDataReach(), s_value);
10817 }
10818 // ʱ������������
10819 function sf_alertTimeReachDesc() {
10820 if(isNaN(target.limitTimeMonth() * target.alertTimeReach())) {
10821 target.alertTimeReachDescData(target.alertTimeReach() + ', ');
10822 return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), ' ');
10823 }
10824 var s_value = transSecond2Time(target.limitTimeMonth() * target.selectedTimeUnit() * target.alertTimeReach() / 100);
10825 target.alertTimeReachDescData(target.alertTimeReach() + ',' + s_value);
10826 return $.i18n.prop('traffic_alert_reach_text', target.alertTimeReach(), s_value);
10827 }
10828
10829
10830 // ��������ֵȡ���༭��ť�¼�
10831 function sf_editAlertDataCancelHandler() {
10832 target.alertDataReach(sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue'));
10833 target.viewEditAlertData(false);
10834 }
10835
10836 // ��������ֵ�༭��ť�¼�
10837 function sf_editAlertDataHandler() {
10838 sv_trafficStaticalInfo.getEle('editAlertData').data('oldValue', target.alertDataReach());
10839 target.viewEditAlertData(true);
10840 }
10841
10842 // ��������ֵ�����༭��ť�¼�
10843 function sf_editAlertDataSaveHandler() {
10844 if (sv_trafficStaticalInfo.getEle('alertDataReach').valid()) {
10845 target.viewEditAlertData(false);
10846 }
10847 }
10848
10849 // ʱ������ֵȡ���༭��ť�¼�
10850 function sf_editAlertTimeCancelHandler() {
10851 target.alertTimeReach(sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue'));
10852 target.viewEditAlertTime(false);
10853 }
10854 // ʱ������ֵ�༭��ť�¼�
10855 function sf_editAlertTimeHandler() {
10856 sv_trafficStaticalInfo.getEle('editAlertTime').data('oldValue', target.alertTimeReach());
10857 target.viewEditAlertTime(true);
10858 }
10859 // ʱ������ֵ�����༭��ť�¼�
10860 function sf_editAlertTimeSaveHandler() {
10861 if (sv_trafficStaticalInfo.getEle('alertTimeReach').valid()) {
10862 target.viewEditAlertTime(false);
10863 }
10864 }
10865
10866 // �ײ������༭��ť�¼�
10867 function sf_editTotalDataHandler() {
10868 sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue', target.limitDataMonth());
10869 sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue', target.selectedDataUnit());
10870 target.viewEditTotalData(true);
10871 }
10872
10873 // �ײ����������༭��ť�¼�
10874 function sf_editTotalDataSaveHandler() {
10875 if (sv_trafficStaticalInfo.getEle('limitDataMonth').valid()) {
10876 target.usedDataText(transUnit(target.limitDataMonth() * target.selectedDataUnit() * 1048576, false));
10877 target.viewEditTotalData(false);
10878 }
10879 }
10880
10881 // �ײ�����ȡ���༭��ť�¼�
10882 function sf_editTotalDataCancelHandler() {
10883 target.limitDataMonth(sv_trafficStaticalInfo.getEle('editTotalData').data('oldValue'));
10884 target.selectedDataUnit(sv_trafficStaticalInfo.getEle('selectedDataUnit').data('oldValue'));
10885 target.viewEditTotalData(false);
10886 }
10887 // �ײ�ʱ��ȡ���༭��ť�¼�
10888 function sf_editTotalTimeCancelHandler() {
10889 target.limitTimeMonth(sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue'));
10890 target.viewEditTotalTime(false);
10891 }
10892 // �ײ�ʱ���༭��ť�¼�
10893 function sf_editTotalTimeHandler() {
10894 sv_trafficStaticalInfo.getEle('editTotalTime').data('oldValue', target.limitTimeMonth());
10895 target.viewEditTotalTime(true);
10896 }
10897 // �ײ�ʱ�䱣���༭��ť�¼�
10898 function sf_editTotalTimeSaveHandler() {
10899 if (sv_trafficStaticalInfo.getEle('limitTimeMonth').valid()) {
10900 target.viewEditTotalTime(false);
10901 }
10902 }
10903
10904 // ��������ȡ���༭��ť�¼�
10905 function sf_editUsedDataCancelHandler() {
10906 target.dataUsed(sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue'));
10907 target.selectedDataUsedUnit(sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue'));
10908 sv_trafficStaticalInfo.getEle('editUsedDataCancel').siblings('label.error').hide();
10909 target.viewEditUsedData(false);
10910 }
10911 // ���������༭��ť�¼�
10912 function sf_editUsedDataHandler() {
10913 sv_trafficStaticalInfo.getEle('editUsedData').data('oldValue', target.dataUsed());
10914 sv_trafficStaticalInfo.getEle('selectedDataUsedUnit').data('oldValue', target.selectedDataUsedUnit());
10915 target.dataUsed(target.dataUsed());
10916 target.viewEditUsedData(true);
10917 }
10918 // �����������水ť�¼�
10919 function sf_editUsedDataSaveHandler() {
10920 if (sv_trafficStaticalInfo.getEle('dataUsed').valid()) {
10921 sv_usedDataModified = true;
10922 target.viewEditUsedData(false);
10923 }
10924 }
10925 // ����ʱ��ȡ���༭��ť�¼�
10926 function sf_editUsedTimeCancelHandler() {
10927 target.usedTime(sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue'));
10928 target.viewEditUsedTime(false);
10929 }
10930 // ����ʱ���༭��ť�¼�
10931 function sf_editUsedTimeHandler() {
10932 sv_trafficStaticalInfo.getEle('editUsedTime').data('oldValue', target.usedTime());
10933 target.viewEditUsedTime(true);
10934 }
10935
10936 // ����ʱ�䱣���༭��ť�¼�
10937 function sf_editUsedTimeSaveHandler() {
10938 if (sv_trafficStaticalInfo.getEle('usedTime').valid()) {
10939 target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
10940 target.viewEditUsedTime(false);
10941 sv_usedTimeModified = true;
10942 }
10943 }
10944
10945 // ʣ������������
10946 function sf_leftDataDesc() {
10947 var s_left = (target.limitDataMonth() * target.selectedDataUnit() - target.dataUsed() * target.selectedDataUsedUnit()) * 1048576;
10948 if(s_left < 0) {
10949 s_left = 0;
10950 }
10951
10952 if(isNaN(s_left)) {
10953 target.leftDataDescData('');
10954 return $.i18n.prop('traffic_data_left_text', ' ');
10955 }
10956
10957 target.leftDataDescData(transUnit(s_left, false));
10958 return $.i18n.prop('traffic_data_left_text', transUnit(s_left, false));
10959 }
10960 //ʣ��ʱ��������
10961 function sf_leftTimeDesc() {
10962 var s_surplus = target.limitTimeMonth() * target.selectedTimeUnit() - sv_trafficStaticalInfo.getTrafficTimeToSeconds(target.monthlyConnectedTime());
10963 if(s_surplus < 0) {
10964 s_surplus = 0;
10965 }
10966
10967 if(isNaN(s_surplus)) {
10968 target.leftTimeDescData(' ');
10969 return $.i18n.prop('traffic_data_left_text', ' ');
10970 }
10971 target.leftTimeDescData(transSecond2Time(s_surplus));
10972 return $.i18n.prop('traffic_data_left_text', transSecond2Time(s_surplus));
10973 }
10974 // �ײ�����������
10975 function sf_limitDataMonthDesc() {
10976 if(isNaN(target.limitDataMonth())) {
10977 target.limitDataMonthDescData("");
10978 return $.i18n.prop('traffic_limit_data_text', ' ');
10979 }else{
10980 // todo
10981 }
10982
10983 target.limitDataMonthDescData(target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
10984 return $.i18n.prop('traffic_limit_data_text', target.limitDataMonth() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUnit()));
10985 }
10986 // �ײ�ʱ��������
10987 function sf_limitTimeMonthDesc() {
10988 if(isNaN(target.limitTimeMonth())) {
10989 target.limitTimeMonthDescData(' ');
10990 target.limitTimeMonthDescText('traffic_limit_time_h');
10991 return $.i18n.prop('traffic_limit_time_h', ' ');
10992 }else{
10993 // todo:
10994 }
10995
10996 target.limitTimeMonthDescData(target.limitTimeMonth());
10997
10998 if(target.selectedTimeUnit() == "60"){
10999 target.limitTimeMonthDescText('traffic_limit_time_m');
11000 return $.i18n.prop('traffic_limit_time_m', target.limitTimeMonth());
11001 }else{
11002 target.limitTimeMonthDescText('traffic_limit_time_h');
11003 return $.i18n.prop('traffic_limit_time_h', target.limitTimeMonth());
11004 }
11005 }
11006
11007 // Ӧ�ð�ť�¼�
11008 function sf_save() {
11009 if (sv_trafficStaticalInfo.isFormEditable(target) && target.dataLimitChecked() == '1') {
11010 return false;
11011 }
11012
11013 if (target.selectedDataUnit() == '1' && target.selectedDataUsedUnit() == '1048576' && target.dataLimitTypeChecked() == "1" && target.dataLimitChecked() == '1' && !(parseInt(target.dataUsed(), 10) < parseInt('4096', 10)) ) {
11014 showAlert('traffic_over_note');
11015 return false;
11016 }
11017
11018 showLoading();
11019 service.setTrafficAlertInfo({
11020 alertDataReach: parseInt(target.alertDataReach(), 10),
11021 alertTimeReach: parseInt(target.alertTimeReach(), 10),
11022 dataLimitChecked: target.dataLimitChecked(),
11023 dataLimitTypeChecked: target.dataLimitTypeChecked(),
11024 limitDataMonth: target.limitDataMonth() + "_" + target.selectedDataUnit(),
11025 limitTimeMonth: target.selectedTimeUnit() == "60" ? target.limitTimeMonth()/60 : target.limitTimeMonth()//save by hours
11026 }, function (data) {
11027 if (data.result == 'success') {
11028 if(target.dataLimitTypeChecked() == "1" && sv_usedDataModified) {
11029 target.saveUsedData();
11030 } else if(target.dataLimitTypeChecked() == "0" && sv_usedTimeModified) {
11031 target.saveUsedTime();
11032 } else {
11033 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11034 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11035 status.setTrafficAlertPopuped(false);
11036 successOverlay();
11037 }
11038 } else {
11039 errorOverlay();
11040 }
11041 }, function () {
11042 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11043 errorOverlay();
11044 });
11045 }
11046
11047 // ����������������
11048 function sf_saveUsedData() {
11049 var val = target.dataUsed() * target.selectedDataUsedUnit();
11050 service.trafficCalibration({
11051 way: 'data',
11052 value: val
11053 }, function(){
11054 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11055 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11056 successOverlay();
11057 target.viewEditUsedData(false);
11058 status.setTrafficAlertPopuped(false);
11059 sv_usedDataModified = false;
11060 }, function(){
11061 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11062 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11063 errorOverlay();
11064 });
11065 }
11066
11067
11068
11069 function sf_saveUsedTime() {
11070 service.trafficCalibration({
11071 way: 'time',
11072 value: target.selectedTimeUsedUnit() == "60" ? parseFloat(target.usedTime())/60 : target.usedTime()
11073 }, function(){
11074 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11075 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11076 successOverlay();
11077 target.monthlyConnectedTime(transSecond2Time(parseFloat(target.usedTime()) * target.selectedTimeUsedUnit()));
11078 target.viewEditUsedTime(false);
11079 status.setTrafficAlertPopuped(false);
11080 sv_usedTimeModified = false;
11081 }, function(){
11082 sv_trafficStaticalInfo.fetchTrafficAlertInfo();
11083 sv_trafficStaticalInfo.refreshFlowDiagramInfo(target);
11084 errorOverlay();
11085 });
11086 }
11087
11088
11089 // ��������������
11090 function sf_usedDataTextDesc() {
11091 if(isNaN(target.dataUsed())) {
11092 target.usedDataTextDescData("");
11093 return $.i18n.prop('traffic_used_text', ' ');
11094 }
11095 target.usedDataTextDescData(target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
11096 return $.i18n.prop('traffic_used_text', target.dataUsed() + sv_trafficStaticalInfo.getTrafficUnitByScale(target.selectedDataUsedUnit()));
11097 }
11098 // ����ʱ��������
11099 function sf_usedTimeTextDesc() {
11100 target.usedTimeTextDescData(target.monthlyConnectedTime());
11101 return $.i18n.prop('traffic_used_text', target.monthlyConnectedTime());
11102 }
11103
11104
11105 }
11106
11107 function init() {
11108 sv_trafficGraph = echarts.init($("#traffic_graphic")[0]);
11109 window.onresize = sv_trafficGraph.resize;
11110 var s_container = $('#container');
11111 ko.cleanNode(s_container[0]);
11112 var fwVm = new trafficViewModel();
11113 ko.applyBindings(fwVm, s_container[0]);
11114 $('#trafficAlertForm').validate({
11115 submitHandler: function () {
11116 fwVm.save();
11117 },
11118
11119
11120 errorPlacement: function (error, para) {
11121 if (para.attr("name") == "alertDataReach") {
11122 error.insertAfter("#editAlertDataDiv");
11123 } else if (para.attr("name") == "alertTimeReach") {
11124 error.insertAfter("#editAlertTimeDiv");
11125 } else if (para.attr("name") == "dataUsed") {
11126 error.insertAfter("#editUsedDataDiv");
11127 } else if (para.attr("name") == "limitDataMonth") {
11128 error.insertAfter("#editTotalDataDiv");
11129 } else if (para.attr("name") == "limitTimeMonth") {
11130 error.insertAfter("#editTotalTimeDiv");
11131 } else if (para.attr("name") == "usedTime") {
11132 error.insertAfter("#editUsedTimeDiv");
11133 } else {
11134 error.insertAfter(para);
11135 }
11136 },
11137
11138 rules: {
11139 alertDataReach: {
11140 range: [ 1, 100 ],
11141 digits: true
11142 },
11143 alertTimeReach: {
11144 range: [ 1, 100 ],
11145 digits: true
11146 },
11147 dataUsed: {
11148 range : [ 0, 9999 ],
11149 decimalRange : true
11150 },
11151 limitDataMonth: {
11152 range : [ 1, 9999 ],
11153 decimalRange : true
11154 },
11155 limitTimeMonth: {
11156 range : [ 1, 9999 ],
11157 decimalRange : true
11158 },
11159 usedTime: {
11160 range : [ 0, 9999 ],
11161 decimalRange : true
11162 }
11163 }
11164
11165 });
11166
11167 var sv_originalLan = window.language;
11168 window.setInterval(function(){
11169 if(sv_originalLan != window.language){
11170 sv_originalLan = window.language;
11171 sv_trafficStaticalInfo.refreshFlowDiagramInfo(fwVm);
11172 }
11173 }, 1000);
11174
11175 }
11176
11177 return {
11178 init: init
11179 };
11180});
11181
11182// ״̬����ʾ��ʵ��
11183define("tooltip",[ "jquery" ],
11184
11185 function($) {
11186
11187
11188 // ����Ԫ��λ����Ϣ
11189 // @method calculatePositionInfo
11190 // @param trigger Ԫ��
11191 // @param tooltip ״̬��
11192 // @param {JSON} config �����
11193
11194 function calculatePositionInfo(trigger, tooltip, config) {
11195 var top = trigger.offset().top;
11196 var left = trigger.offset().left;
11197 var position = config.position[0];
11198 var height = tooltip.outerHeight() + trigger.outerHeight();
11199 var width = tooltip.outerWidth() + trigger.outerWidth();
11200
11201 top -= tooltip.outerHeight() - config.offset[0];
11202 left += trigger.outerWidth() + config.offset[1];
11203
11204 if (/iPad/i.test(navigator.userAgent)) {
11205 top -= $(window).scrollTop();
11206 }
11207
11208 if (position == 'center') {
11209 top += height / 2;
11210 }
11211 if (position == 'bottom') {
11212 top += height;
11213 }
11214 position = config.position[1];
11215 if (position == 'center') {
11216 left -= width / 2;
11217 }else if (position == 'left') {
11218 left -= width;
11219 }
11220
11221 return {
11222 top : top,
11223 left : left
11224 };
11225 }
11226
11227 // ״̬����ʼ��
11228 function init() {
11229
11230 $(".statusItem", "#statusBar").each(function(i, n){
11231 var $this = $(this);
11232 $this.attr("tipTitle", $this.attr("title")).removeAttr("title");
11233 }).hover(
11234 function() {
11235 var $this = $(this);
11236 var title = $this.attr("tipTitle");
11237 var tooltip = $("<div>").addClass("tooltip in").appendTo(document.body).hide()
11238 .append($this.attr("i18n") ? $.i18n.prop(title) : title);
11239 if ($this.attr("i18n")) {
11240 tooltip.attr("data-trans", title).attr("id", "tooltip_" + $this.attr("id"));
11241 }
11242 var pos = calculatePositionInfo($this, tooltip, {
11243 position : [ 'bottom', 'center' ],
11244 offset : [ 0, 0 ]
11245 });
11246 tooltip.css({
11247 position : 'absolute',
11248 top : pos.top,
11249 left : pos.left
11250 }).show();
11251 }, function() {
11252 $(".tooltip").hide().remove();
11253 });
11254 }
11255
11256 return {
11257 init : init
11258 };
11259 });
11260
11261define("menu","set service knockout underscore jquery".split(" "),
11262 function (set, fnc, libko, libus, libjq) {
11263 var displayMenuWhenLogout = false;
11264 var vmMenu;
11265 var menu = [];
11266 var menuResource = "";
11267
11268 function menuExistCheck(path) {
11269 for (var i = 0; i < menu.length; i++) {
11270 if (menu[i].path == path) {
11271 return true;
11272 }
11273 }
11274 return false;
11275 }
11276
11277 function getIsLoggedin() {
11278 var loginStatus = fnc.getLoginStatus();
11279 return (loginStatus.status == "loggedIn");
11280 }
11281
11282 function buildNew() {
11283 var loggedIn = getIsLoggedin();
11284 var menuMain = libus.filter(menu, function (param) {
11285 return (param.level == '1' && ((param.requireLogin && loggedIn) || !param.requireLogin) && param.hash != "#entry");
11286 });
11287 vmMenu.menuMain(menuMain);
11288 vmMenu.loggedIn(loggedIn);
11289
11290 getMainWth(vmMenu.menuMain().length);
11291 vmMenu.showMenu(loggedIn || displayMenuWhenLogout);
11292 libjq("#nav").translate();
11293 }
11294
11295 function getMainWth(len) {
11296 var width = 100 / len;
11297 libjq('ul#list-nav li').each(function () {
11298 libjq(this).css('width', width + '%');
11299 });
11300 }
11301
11302 function menuRefresh() {
11303 var currentHash = window.location.hash;
11304 var itmRoot = libus.find(menu, function (param) {
11305 return param.hash == currentHash;
11306 });
11307 while (itmRoot.parent) {
11308 itmRoot = libus.find(menu, function (param) {
11309 return param.hash == itmRoot.parent;
11310 });
11311 }
11312 if (!itmRoot.parent) {
11313 libjq("#list-nav li").removeClass("active");
11314 var mid = itmRoot.hash.substring(1, itmRoot.hash.length);
11315 libjq("#list-nav li[mid=" + mid + "]").addClass("active");
11316 }
11317 vmMenu.changeMenu(itmRoot);
11318 }
11319
11320 function menuSearch(hashVal) {
11321 hashVal = hashVal || window.location.hash;
11322 var loggedIn = getIsLoggedin();
11323 return libus.filter(menu, function (param) {
11324 return (hashVal == param.hash && ((param.requireLogin && loggedIn) || !param.requireLogin));
11325 });
11326 }
11327
11328 function menuRenderSub(level, baseItem) {
11329 var levelItem = libus.find(menu, function (param) {
11330 return param.parent == baseItem.hash && param.path == baseItem.path;
11331 });
11332 libjq(".menu-" + level + "-level").removeClass("active");
11333 if (levelItem) {
11334 if (level == "two") {
11335 menuRenderSub("three", levelItem);
11336 //forward/backward support
11337 clickMenuTrig(levelItem.hash, level);
11338 }
11339 libjq(".menu-" + level + "-level." + levelItem.hash.substring(1)).addClass("active");
11340 }
11341 }
11342
11343 function menuActSub() {
11344 var currentHash = window.location.hash;
11345 var itmRoot = libus.find(menu, function (param) {
11346 return param.hash == currentHash;
11347 });
11348 if (itmRoot.level == 1) {
11349 menuRenderSub("two", itmRoot);
11350 }
11351 if (itmRoot.level == 2) {
11352 menuRenderSub("three", itmRoot);
11353 //forward/backward support
11354 clickMenuTrig(itmRoot.hash, itmRoot.level);
11355 }
11356 if (itmRoot.level == 3) {
11357 //forward/backward support
11358 clickMenuTrig(itmRoot.parent, itmRoot.level);
11359 libjq(".menu-three-level").removeClass("active");
11360 libjq(".menu-three-level." + itmRoot.hash.substring(1)).addClass("active");
11361 }
11362 }
11363
11364 function clickMenuTrig(hash, level) {
11365 libjqobj = libjq(".menu-two-level." + hash.substring(1));
11366 var levelArr = ['3', 'three', '2', 'two'];
11367 if (libus.indexOf(levelArr, level) != -1 && libjqobj.hasClass('active')) {
11368 return;
11369 }
11370
11371 libjqobj.siblings().removeClass('active');
11372 libjqobj.addClass('active');
11373
11374 libjqobj.siblings().not('.menu-two-level').slideUp();
11375 libjqobj.next().has('ul li').slideDown();
11376 }
11377
11378 set.blc_wan_mode = fnc.getOpMode().blc_wan_mode;
11379 if (!set.RJ45_SUPPORT) {
11380 menuResource = "menu";
11381 } else {
11382 switch (set.blc_wan_mode) {
11383 case "PPPOE":
11384 case "AUTO_PPPOE":
11385 menuResource = "menu_pppoe";
11386 break;
11387 default:
11388 menuResource = "menu";
11389 break;
11390 }
11391 }
11392
11393 require([set.DEVICE + '/' + menuResource], function (otherMenu) {
11394 menu = otherMenu;
11395 if (set.SD_CARD_SUPPORT) {
11396 menu = menu.concat([{ hash: '#httpshare_guest', path: 'sd_httpshare', level: '', requireLogin: false, checkSIMStatus: false},
11397 { hash: '#sdcard', path: 'sd', level: '', requireLogin: true, checkSIMStatus: false},
11398 { hash: '#httpshare', path: 'sd_httpshare', level: '', requireLogin: true, checkSIMStatus: false}]);
11399 }
11400 });
11401
11402 function initialize() {
11403 vmMenu = new Menu_vm();
11404 }
11405
11406 function Menu_vm() {
11407 var loginState = getIsLoggedin();
11408 var target = this;
11409 target.loggedIn = libko.observable(loginState);
11410
11411 target.showMenu = libko.observable(loginState || displayMenuWhenLogout);
11412
11413 var menuMain = libus.filter(menu, function (param) {
11414 return (param.level == '1' && ((param.requireLogin && target.loggedIn()) || !param.requireLogin) && param.hash != "#entry");
11415 });
11416
11417 target.menuMain = libko.observableArray(menuMain);
11418 target.secondMenu = libko.observableArray([]);
11419 //target.curThirdMenu; cov_2
11420 target.changeMenu = function (data) {
11421 var secondMenu = getSubMenu(data);
11422 if (secondMenu.length == 0) {
11423 libjq("#container").addClass("fixContainerWidth");
11424 } else {
11425 libjq("#container").removeClass("fixContainerWidth");
11426 }
11427
11428 target.secondMenu(secondMenu);
11429 return true;
11430 };
11431 target.thirdMenu = function () {
11432 return target.curThirdMenu;
11433 };
11434 target.getThirdMenu = function (data) {
11435 target.curThirdMenu = getSubMenu(data);
11436 };
11437 function getSubMenu(data) {
11438 return libus.filter(menu, function (param) {
11439 return ((param.parent && param.parent == data.hash) && ((param.requireLogin && target.loggedIn()) || !param.requireLogin));
11440 });
11441 }
11442 }
11443
11444 return {
11445 activeSubMenu: menuActSub,
11446 checkIsMenuExist: menuExistCheck,
11447 findMenu: menuSearch,
11448 rebuild: buildNew,
11449 refreshMenu: menuRefresh,
11450 init: initialize
11451 };
11452});