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