| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | define("wifi_advance","underscore jquery knockout set service jqui".split(" "),
 | 
 | 2 |     function (_, $, ko, config, service, jqui) {
 | 
 | 3 |     var $sliderRange = null;
 | 
 | 4 |     //当前是否WiFi连接
 | 
 | 5 |     var viaWifi = false;
 | 
 | 6 | 
 | 
 | 7 |     function paintRateOption(data) {
 | 
 | 8 |         var opts = [];
 | 
 | 9 |         for (var i = 0; i < data.length; i++) {
 | 
 | 10 |             var rate = data[i].rate == 0 ? "Auto" : data[i].rate + " Mbps";
 | 
 | 11 |             opts.push(new Option(rate, data[i].index));
 | 
 | 12 |         }
 | 
 | 13 |         return opts;
 | 
 | 14 |     }
 | 
 | 15 | 
 | 
 | 16 |     //wifi传输速率
 | 
 | 17 |     var transpeed = [0, 1, 2, 5.5, 6, 6.5, 9, 11, 12, 13, 18, 19.5, 24, 26, 36, 39, 48, 52, 54, 58.5, 65];
 | 
 | 18 | 
 | 
 | 19 |     function rateSort(a, b) {
 | 
 | 20 |         return a.rate - b.rate;
 | 
 | 21 |     }
 | 
 | 22 |     //删除重复速率值
 | 
 | 23 |     function unionRate(rateTable) {
 | 
 | 24 |         var rates = [],
 | 
 | 25 |         result = [];
 | 
 | 26 |         for (var i = 0; i < rateTable.length; i++) {
 | 
 | 27 |             for (var j = 0; j < rateTable[i].length; j++) {
 | 
 | 28 |                 if (ko.utils.arrayIndexOf(rates, rateTable[i][j]) == -1) {
 | 
 | 29 |                     rates.push(rateTable[i][j]);
 | 
 | 30 |                     result.push({
 | 
 | 31 |                         index: rateTable[i][j],
 | 
 | 32 |                         rate: transpeed[rateTable[i][j]]
 | 
 | 33 |                     });
 | 
 | 34 |                 }
 | 
 | 35 |             }
 | 
 | 36 |         }
 | 
 | 37 |         result.sort(rateSort);
 | 
 | 38 |         return result;
 | 
 | 39 |     }
 | 
 | 40 | 
 | 
 | 41 |     //根据模式生成速率选项
 | 
 | 42 |     function modeRateOption(wifimode) {
 | 
 | 43 |         var wifimodeN = [0, 5, 9, 11, 13, 15, 17, 19, 20];
 | 
 | 44 |         var wifimodeG = [0, 4, 6, 8, 10, 12, 14, 16, 18];
 | 
 | 45 |         var wifimodeB = [0, 1, 2, 3, 7];
 | 
 | 46 |         var rate = [];
 | 
 | 47 | 
 | 
 | 48 |         switch (wifimode) {
 | 
 | 49 |             //--wifimode
 | 
 | 50 |         case '5':
 | 
 | 51 |             rate.push(wifimodeN);
 | 
 | 52 |             rate.push(wifimodeG);
 | 
 | 53 |             rate.push(wifimodeB);
 | 
 | 54 |             break;
 | 
 | 55 |         case '4':
 | 
 | 56 |             rate.push(wifimodeN);
 | 
 | 57 |             rate.push(wifimodeG);
 | 
 | 58 |             rate.push(wifimodeB);
 | 
 | 59 |             break;
 | 
 | 60 |         case '3':
 | 
 | 61 |             rate.push(wifimodeG);
 | 
 | 62 |             rate.push(wifimodeB);
 | 
 | 63 |             break;
 | 
 | 64 |         case '2':
 | 
 | 65 |             rate.push(wifimodeN);
 | 
 | 66 |             break;
 | 
 | 67 |         case '1':
 | 
 | 68 |             rate.push(wifimodeG);
 | 
 | 69 |             break;
 | 
 | 70 |         case '0':
 | 
 | 71 |             rate.push(wifimodeB);
 | 
 | 72 |             break;
 | 
 | 73 | 
 | 
 | 74 |         default:
 | 
 | 75 |             rate.push(wifimodeN);
 | 
 | 76 |             break;
 | 
 | 77 |         }
 | 
 | 78 |         var union = unionRate(rate);
 | 
 | 79 |         return paintRateOption(union);
 | 
 | 80 |     }
 | 
 | 81 | 
 | 
 | 82 |     function getCountryCode(country) {
 | 
 | 83 |         var countryCodeArr = config.countryCode;
 | 
 | 84 |         var type = '';
 | 
 | 85 |         for (key in countryCodeArr) {
 | 
 | 86 |             var codes = countryCodeArr[key];
 | 
 | 87 |             if ($.inArray(country, codes) != -1) {
 | 
 | 88 |                 type = key;
 | 
 | 89 |                 break;
 | 
 | 90 |             }
 | 
 | 91 |         }
 | 
 | 92 |         var typeCode = config.countryCodeType[type];
 | 
 | 93 |         return typeCode ? typeCode : "0";
 | 
 | 94 |     }
 | 
 | 95 | 
 | 
 | 96 |     function channelOption(country) {
 | 
 | 97 |         var showOption = [new Option('Auto', '0')];
 | 
 | 98 |         var type = getCountryCode(country) + '';
 | 
 | 99 |         switch (type) {
 | 
 | 100 |             //--type
 | 
 | 101 |         case '9':
 | 
 | 102 |             generateChannelOption(showOption, 2307, 13);
 | 
 | 103 |             break;
 | 
 | 104 |         case '7':
 | 
 | 105 |             generateChannelOption(showOption, 2307, 13);
 | 
 | 106 |             generateChannelOption(showOption, 2407, 11);
 | 
 | 107 |             generateChannelOption(showOption, 2462, 2);
 | 
 | 108 |             break;
 | 
 | 109 |         case '3':
 | 
 | 110 |             generateChannelOption(showOption, 2407, 11);
 | 
 | 111 |             generateChannelOption(showOption, 2462, 2);
 | 
 | 112 |             break;
 | 
 | 113 |             //--type
 | 
 | 114 |         case '2':
 | 
 | 115 |             generateChannelOption(showOption, 2307, 13);
 | 
 | 116 |             generateChannelOption(showOption, 2407, 11);
 | 
 | 117 |             break;
 | 
 | 118 |         case '1':
 | 
 | 119 |             generateChannelOption(showOption, 2407, 11);
 | 
 | 120 |             break;
 | 
 | 121 |         default:
 | 
 | 122 |             generateChannelOption(showOption, 2407, 11);
 | 
 | 123 |         }
 | 
 | 124 |         return showOption;
 | 
 | 125 |     }
 | 
 | 126 |     function generateChannelOption(showOption, start, count) {
 | 
 | 127 |         for (var i = 1; i <= count; i++) {
 | 
 | 128 |             var txt = start + i * 5 + "MHz (Channel " + showOption.length + ")";
 | 
 | 129 |             showOption.push(new Option(txt, showOption.length + "_" + (start + i * 5)));
 | 
 | 130 |         }
 | 
 | 131 |     }
 | 
 | 132 | 
 | 
 | 133 |     function channelOption5g(country) {
 | 
 | 134 |         for (key in config.countryCode_5g) {
 | 
 | 135 |             var item = config.countryCode_5g[key];
 | 
 | 136 |             if ($.inArray(country, item.codes) != -1) {
 | 
 | 137 |                 return generate5gChannelOption(item.channels);
 | 
 | 138 |             }
 | 
 | 139 |         }
 | 
 | 140 |         return [new Option('Auto', '0')];
 | 
 | 141 |     }
 | 
 | 142 |     function generate5gChannelOption(channels) {
 | 
 | 143 |         var showOption = [new Option('Auto', '0')];
 | 
 | 144 |         for (var i = 0; i < channels.length; i++) {
 | 
 | 145 |             var channel = channels[i];
 | 
 | 146 |             var mhz = channel * 5 + 5000;
 | 
 | 147 |             var txt = mhz + "MHz (Channel " + channel + ")";
 | 
 | 148 |             showOption.push(new Option(txt, channel + "_" + (mhz)));
 | 
 | 149 |         }
 | 
 | 150 |         return showOption;
 | 
 | 151 |     }
 | 
 | 152 | 
 | 
 | 153 |     function getBandOptions() {
 | 
 | 154 |         var showOption = [];
 | 
 | 155 |         if (!config.WIFI_HAS_5G) {
 | 
 | 156 |             showOption.push(new Option('2.4GHz', 'b'));
 | 
 | 157 |         } else {
 | 
 | 158 |             showOption.push(new Option('5GHz', 'a'));
 | 
 | 159 |             showOption.push(new Option('2.4GHz', 'b'));
 | 
 | 160 |         }
 | 
 | 161 |         return showOption;
 | 
 | 162 |     }
 | 
 | 163 | 
 | 
 | 164 |     function getChannelBandwidthsOptions(isSupport40) {
 | 
 | 165 |         var showOption = [];
 | 
 | 166 |         if (isSupport40) {
 | 
 | 167 |             showOption.push(new Option('20MHz', '0'));
 | 
 | 168 |             showOption.push(new Option('20MHz/40MHz', '1'));
 | 
 | 169 |         } else {
 | 
 | 170 |             showOption.push(new Option('20MHz', '0'));
 | 
 | 171 |         }
 | 
 | 172 |         return showOption;
 | 
 | 173 |     }
 | 
 | 174 | 
 | 
 | 175 |     function countryCodeOption(is5G) {
 | 
 | 176 |         var countries = is5G ? config.countries_5g : config.countries;
 | 
 | 177 |         var showOption = [];
 | 
 | 178 |         for (key in countries) {
 | 
 | 179 |             showOption.push(new Option(countries[key], key));
 | 
 | 180 |         }
 | 
 | 181 |         showOption = _.sortBy(showOption, function (opt) {
 | 
 | 182 |             return opt.text;
 | 
 | 183 |         });
 | 
 | 184 |         return showOption;
 | 
 | 185 |     }
 | 
 | 186 | 
 | 
 | 187 |     function getWifiAdvance() {
 | 
 | 188 |         return service.getWifiAdvance();
 | 
 | 189 |     }
 | 
 | 190 | 
 | 
 | 191 |     function getWpsState() {
 | 
 | 192 |         return service.getWpsInfo();
 | 
 | 193 |     }
 | 
 | 194 | 
 | 
 | 195 |     function getModeOption(wifiBand) {
 | 
 | 196 |         var modes = wifiBand == 'a' ? config.NETWORK_MODES_BAND : config.NETWORK_MODES;
 | 
 | 197 |         if (wifiBand == 'a') {
 | 
 | 198 |             $("#mode").hide();
 | 
 | 199 |             $("#modeFor5HZ").show();
 | 
 | 200 |             $("#modeLabel").attr('for', 'modeFor5HZ');
 | 
 | 201 |         } else if (modes.length == 1) {
 | 
 | 202 |             $("#mode").hide();
 | 
 | 203 |             $("#modeFor5HZ").hide();
 | 
 | 204 |         } else {
 | 
 | 205 |             $("#mode").show();
 | 
 | 206 |             $("#modeFor5HZ").hide();
 | 
 | 207 |         }
 | 
 | 208 |         var modeOptions = [];
 | 
 | 209 |         for (var i = 0; i < modes.length; i++) {
 | 
 | 210 |             modeOptions.push(new Option(modes[i].name, modes[i].value));
 | 
 | 211 |         }
 | 
 | 212 |         return modeOptions;
 | 
 | 213 |     }
 | 
 | 214 | 
 | 
 | 215 |     function getSelectedRateV(rate, rates) {
 | 
 | 216 |         for (var i = 0; i < rates.length; i++) {
 | 
 | 217 |             var opt = rates[i];
 | 
 | 218 |             if (opt.text == rate + " Mbps") {
 | 
 | 219 |                 return opt.value;
 | 
 | 220 |             }
 | 
 | 221 |         }
 | 
 | 222 |         return '0';
 | 
 | 223 |     }
 | 
 | 224 |     //获取所选的信道对应的value值
 | 
 | 225 |     function getSelectedChannelV(channel, channels) {
 | 
 | 226 |         for (var i = 0; i < channels.length; i++) {
 | 
 | 227 |             var opt = $(channels[i]);
 | 
 | 228 |             if (opt.val().split("_")[0] == channel) {
 | 
 | 229 |                 return opt.val();
 | 
 | 230 |             }
 | 
 | 231 |         }
 | 
 | 232 |         return '0';
 | 
 | 233 |     }
 | 
 | 234 | 
 | 
 | 235 |     function WifiAdvanceViewModel() {
 | 
 | 236 |         // Data
 | 
 | 237 |         var target = this;
 | 
 | 238 | 
 | 
 | 239 |         var wifiInfo = service.getWifiAdvance();
 | 
 | 240 |         target.origin_ap_station_enable = wifiInfo.ap_station_enable;
 | 
 | 241 |         target.modes = ko.observableArray(getModeOption(wifiInfo.wifiBand));
 | 
 | 242 |         target.bands = ko.observableArray(getBandOptions());
 | 
 | 243 | 
 | 
 | 244 |         var countryOpts = countryCodeOption(wifiInfo.wifiBand == 'a');
 | 
 | 245 |         target.countries = ko.observableArray(countryOpts);
 | 
 | 246 |         target.channels = ko.observableArray(wifiInfo.wifiBand == 'a' ? channelOption5g(wifiInfo.countryCode) : channelOption(wifiInfo.countryCode));
 | 
 | 247 |         target.rates = ko.observableArray(modeRateOption(wifiInfo.mode));
 | 
 | 248 | 
 | 
 | 249 |         target.hasAPStation = config.AP_STATION_SUPPORT;
 | 
 | 250 |         target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
 | 
 | 251 |         target.hasMultiSSID = config.HAS_MULTI_SSID;
 | 
 | 252 |         target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
 | 
 | 253 |         target.hasWifiBand = ko.observable(config.WIFI_BAND_SUPPORT);
 | 
 | 254 |         target.hasBandwidth = ko.observable(config.WIFI_BANDWIDTH_SUPPORT);
 | 
 | 255 | 
 | 
 | 256 |         target.selectedMode = ko.observable(wifiInfo.mode);
 | 
 | 257 |         target.selectedChannel = ko.observable(getSelectedChannelV(wifiInfo.channel, target.channels()));
 | 
 | 258 |         target.selectedChannelBandwidth = ko.observable(wifiInfo.bandwidth); //5:a, 2.5:b
 | 
 | 259 |         target.selectedCountry = ko.observable(wifiInfo.countryCode.toUpperCase());
 | 
 | 260 |         target.selectedBand = ko.observable(wifiInfo.wifiBand); //5:a, 2.5:b
 | 
 | 261 |         target.selectedRate = ko.observable(getSelectedRateV(wifiInfo.rate, target.rates()));
 | 
 | 262 | 
 | 
 | 263 |         var baseInfo = service.getWifiBasic();
 | 
 | 264 |         target.wifi_enable = ko.observable(baseInfo.wifi_enable);
 | 
 | 265 |         if (config.HAS_MULTI_SSID && ((baseInfo.m_AuthMode == "OPEN" && baseInfo.m_encryptType == "WEP") || (baseInfo.m_AuthMode == "SHARED" && baseInfo.m_encryptType == "WEP") || baseInfo.m_encryptType == "TKIP")) {
 | 
 | 266 |             target.isF = ko.observable(true);
 | 
 | 267 |         } else if ((baseInfo.AuthMode == "OPEN" && baseInfo.encryptType == "WEP") || (baseInfo.AuthMode == "SHARED" && baseInfo.encryptType == "WEP") || baseInfo.encryptType == "TKIP") {
 | 
 | 268 |             target.isF = ko.observable(true);
 | 
 | 269 |         } else {
 | 
 | 270 |             target.isF = ko.observable(false);
 | 
 | 271 |         }
 | 
 | 272 |         target.isShowSSIDInfoDiv = ko.observable(false);
 | 
 | 273 |         if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 274 |             if (baseInfo.wifi_enable == "1") {
 | 
 | 275 |                 target.isShowSSIDInfoDiv(true);
 | 
 | 276 |             } else {
 | 
 | 277 |                 target.isShowSSIDInfoDiv(false);
 | 
 | 278 |             }
 | 
 | 279 |         } else {
 | 
 | 280 |             target.isShowSSIDInfoDiv(true);
 | 
 | 281 |         }
 | 
 | 282 |         target.multi_ssid_enable = ko.observable(baseInfo.multi_ssid_enable);
 | 
 | 283 |         target.origin_multi_ssid_enable = baseInfo.multi_ssid_enable;
 | 
 | 284 |         target.maxStationNumber = ko.observable(wifiInfo.MAX_Station_num);
 | 
 | 285 |         target.selectedStation = ko.observable(wifiInfo.MAX_Access_num);
 | 
 | 286 |         target.selectedStationM = ko.observable(wifiInfo.m_MAX_Access_num);
 | 
 | 287 | 
 | 
 | 288 |         target.oneBandTrans = ko.observable(wifiInfo.wifiBand == 'a' ? '5G' : '2.4G');
 | 
 | 289 |         target.oneModeTrans = ko.observable((wifiInfo.wifiBand == 'a' ? 'network_modes_band_select_' : 'network_mode_select_') + wifiInfo.mode);
 | 
 | 290 | 
 | 
 | 291 |         target.channelBandwidths = ko.computed(function () {
 | 
 | 292 |             if (config.WIFI_BANDWIDTH_SUPPORT_40MHZ) {
 | 
 | 293 |                 return getChannelBandwidthsOptions(true);
 | 
 | 294 |             } else {
 | 
 | 295 |                 return getChannelBandwidthsOptions(false);
 | 
 | 296 |             }
 | 
 | 297 |         });
 | 
 | 298 | 
 | 
 | 299 |         wifiInfo = $.extend(wifiInfo, target);
 | 
 | 300 | 
 | 
 | 301 |         //Event Handler 频段切换时更新对应的国家/地区码、信道和网络模式选项
 | 
 | 302 |         target.bandChangeHandler = function () {
 | 
 | 303 |             if (target.selectedBand() == 'a') { //5g
 | 
 | 304 |                 //802.11a only   802.11n only   802.11a/n
 | 
 | 305 |                 target.modes(getModeOption(target.selectedBand()));
 | 
 | 306 |                 target.countries(countryCodeOption(true));
 | 
 | 307 |             } else { // 2.4g
 | 
 | 308 |                 //802.11 n only   802.11 b/g/n
 | 
 | 309 |                 target.modes(getModeOption(target.selectedBand()));
 | 
 | 310 |                 target.countries(countryCodeOption(false));
 | 
 | 311 |             }
 | 
 | 312 |             target.selectedCountry('0');
 | 
 | 313 |             target.channels(target.generateChannelOption());
 | 
 | 314 |             target.selectedChannel('0');
 | 
 | 315 |         };
 | 
 | 316 | 
 | 
 | 317 |         target.countryChangeHandler = function (data, event) {
 | 
 | 318 |             var opts = target.generateChannelOption();
 | 
 | 319 |             target.channels(opts);
 | 
 | 320 |             target.selectedChannel('0');
 | 
 | 321 |         };
 | 
 | 322 | 
 | 
 | 323 |         target.modeChangeHandler = function (data, event) {
 | 
 | 324 |             var opts = modeRateOption(target.selectedMode());
 | 
 | 325 |             target.rates(opts);
 | 
 | 326 |             target.selectedRate('0');
 | 
 | 327 |         };
 | 
 | 328 | 
 | 
 | 329 |         target.generateChannelOption = function () {
 | 
 | 330 |             if (target.selectedBand() == 'a') {
 | 
 | 331 |                 return channelOption5g(target.selectedCountry());
 | 
 | 332 |             } else {
 | 
 | 333 |                 return channelOption(target.selectedCountry());
 | 
 | 334 |             }
 | 
 | 335 |         };
 | 
 | 336 | 
 | 
 | 337 |         target.save = function () {
 | 
 | 338 |             var status = getWpsState();
 | 
 | 339 |             if (status.wpsFlag == '1') {
 | 
 | 340 |                 showAlert('wps_on_info');
 | 
 | 341 |                 return;
 | 
 | 342 |             }
 | 
 | 343 |             var selectedRateTxt = $("#rate option:selected").text();
 | 
 | 344 |             var rateVal = null;
 | 
 | 345 |             if (selectedRateTxt != $.i18n.prop('rate_0')) {
 | 
 | 346 |                 rateVal = $.trim(selectedRateTxt.replace('Mbps', ''));
 | 
 | 347 |             } else {
 | 
 | 348 |                 rateVal = 0;
 | 
 | 349 |             }
 | 
 | 350 |             var wifiParam = {};
 | 
 | 351 |             wifiParam.countryCode = target.selectedCountry();
 | 
 | 352 |             wifiParam.mode = target.selectedMode();
 | 
 | 353 |             var selectedChannel = target.selectedChannel();
 | 
 | 354 |             wifiParam.channel = selectedChannel == '0' ? '0' : selectedChannel.split("_")[0];
 | 
 | 355 |             wifiParam.rate = rateVal;
 | 
 | 356 |             wifiParam.wifiBand = target.selectedBand();
 | 
 | 357 |             if (config.WIFI_BANDWIDTH_SUPPORT) {
 | 
 | 358 |                 wifiParam.bandwidth = target.selectedChannelBandwidth();
 | 
 | 359 |             }
 | 
 | 360 |             wifiParam.station = target.selectedStation();
 | 
 | 361 |             wifiParam.m_station = target.selectedStationM();
 | 
 | 362 |             showConfirm('wifi_disconnect_confirm', function () {
 | 
 | 363 |                 showLoading('waiting');
 | 
 | 364 |                 service.setWifiAdvance(wifiParam, function (result) {
 | 
 | 365 |                     if (result.result == "success") {
 | 
 | 366 |                         if (viaWifi) {
 | 
 | 367 |                             setTimeout(advanceReloadVarWifi, 15000);
 | 
 | 368 |                         } else {
 | 
 | 369 |                             addInterval(advanceReload, 1000);
 | 
 | 370 |                         }
 | 
 | 371 |                     } else {
 | 
 | 372 |                         errorOverlay();
 | 
 | 373 |                     }
 | 
 | 374 |                 });
 | 
 | 375 |             });
 | 
 | 376 |         };
 | 
 | 377 | 
 | 
 | 378 |         target.checkSettings = function (ssid) {
 | 
 | 379 |             var status = getWpsState();
 | 
 | 380 |             if (status.wpsFlag == '1') {
 | 
 | 381 |                 showAlert('wps_on_info');
 | 
 | 382 |                 return true;
 | 
 | 383 |             }
 | 
 | 384 |             if (config.HAS_MULTI_SSID && baseInfo.multi_ssid_enable == "1") {
 | 
 | 385 |                 if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(baseInfo.m_MAX_Access_num) > baseInfo.MAX_Station_num)
 | 
 | 386 |                      || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(baseInfo.MAX_Access_num) > baseInfo.MAX_Station_num)) {
 | 
 | 387 |                     showAlert({
 | 
 | 388 |                         msg: 'multi_ssid_max_access_number_alert',
 | 
 | 389 |                         wifiParam: baseInfo.MAX_Station_num
 | 
 | 390 |                     });
 | 
 | 391 |                     return true;
 | 
 | 392 |                 }
 | 
 | 393 |             }
 | 
 | 394 | 
 | 
 | 395 |             return false;
 | 
 | 396 |         };
 | 
 | 397 | 
 | 
 | 398 |         target.setMultiSSIDSwitch = function () {
 | 
 | 399 |             if (target.checkSettings("switch")) {
 | 
 | 400 |                 return;
 | 
 | 401 |             }
 | 
 | 402 | 
 | 
 | 403 |             var setSwitch = function () {
 | 
 | 404 |                 showLoading('waiting');
 | 
 | 405 |                 var wifiParam = {};
 | 
 | 406 |                 wifiParam.m_ssid_enable = target.multi_ssid_enable();
 | 
 | 407 |                 if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 408 |                     wifiParam.wifiEnabled = target.wifi_enable();
 | 
 | 409 |                 }
 | 
 | 410 |                 service.setWifiBasicMultiSSIDSwitch(wifiParam, function (result) {
 | 
 | 411 |                     if (result.result == "success") {
 | 
 | 412 |                         if (viaWifi) {
 | 
 | 413 |                             setTimeout(hasApReloadVarWifi, 15000);
 | 
 | 414 |                         } else {
 | 
 | 415 |                             addInterval(hasApReload, 1000);
 | 
 | 416 |                         }
 | 
 | 417 |                     } else {
 | 
 | 418 |                         errorOverlay();
 | 
 | 419 |                     }
 | 
 | 420 |                 });
 | 
 | 421 |             };
 | 
 | 422 | 
 | 
 | 423 |             var baseInfo = service.getStatusInfo();
 | 
 | 424 |             if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
 | 
 | 425 |                 if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
 | 
 | 426 |                     if (!baseInfo.wifiStatus) {
 | 
 | 427 |                         showConfirm("multi_ssid_enable_confirm", function () {
 | 
 | 428 |                             setSwitch();
 | 
 | 429 |                         });
 | 
 | 430 |                     } else {
 | 
 | 431 |                         showConfirm("multi_ssid_enable_confirm2", function () {
 | 
 | 432 |                             setSwitch();
 | 
 | 433 |                         });
 | 
 | 434 |                     }
 | 
 | 435 |                 } else {
 | 
 | 436 |                     if (!baseInfo.wifiStatus) {
 | 
 | 437 |                         setSwitch();
 | 
 | 438 |                     } else {
 | 
 | 439 |                         showConfirm("wifi_disconnect_confirm2", function () {
 | 
 | 440 |                             setSwitch();
 | 
 | 441 |                         });
 | 
 | 442 |                     }
 | 
 | 443 |                 }
 | 
 | 444 |             } else {
 | 
 | 445 |                 setSwitch();
 | 
 | 446 |             }
 | 
 | 447 |             
 | 
 | 448 |             function hasApReloadVarWifi() {
 | 
 | 449 |                 successOverlay();
 | 
 | 450 |                 setTimeout(function () {
 | 
 | 451 |                     window.location.reload();
 | 
 | 452 |                 }, 1000);
 | 
 | 453 |                 clearTimer();
 | 
 | 454 |                 clearValidateMsg();
 | 
 | 455 |                 service.refreshAPStationStatus();
 | 
 | 456 |                 initialize();
 | 
 | 457 |             }
 | 
 | 458 |             function hasApReload() {
 | 
 | 459 |                 var baseInfo = service.getWifiBasic();
 | 
 | 460 |                 if (baseInfo.wifi_enable == target.wifi_enable()) {
 | 
 | 461 |                     successOverlay();
 | 
 | 462 |                     clearTimer();
 | 
 | 463 |                     clearValidateMsg();
 | 
 | 464 |                     service.refreshAPStationStatus();
 | 
 | 465 |                     initialize();
 | 
 | 466 |                 }
 | 
 | 467 |             }
 | 
 | 468 | 
 | 
 | 469 |         };
 | 
 | 470 | 
 | 
 | 471 |     }
 | 
 | 472 | 
 | 
 | 473 |     function checkAccessMode() {
 | 
 | 474 |         service.getParams({
 | 
 | 475 |             nv: 'user_ip_addr'
 | 
 | 476 |         }, function (dataIp) {
 | 
 | 477 |             service.getParams({
 | 
 | 478 |                 nv: 'station_list'
 | 
 | 479 |             }, function (dataList) {
 | 
 | 480 |                 viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
 | 
 | 481 |             });
 | 
 | 482 |         });
 | 
 | 483 |     }
 | 
 | 484 | 
 | 
 | 485 |     function advanceReloadVarWifi() {
 | 
 | 486 |         successOverlay();
 | 
 | 487 |         setTimeout(function () {
 | 
 | 488 |             window.location.reload();
 | 
 | 489 |         }, 1000);
 | 
 | 490 |     }
 | 
 | 491 | 
 | 
 | 492 |     function advanceReload() {
 | 
 | 493 |         var baseInfo = service.getWifiBasic();
 | 
 | 494 |         if (baseInfo.wifi_enable == "1") {
 | 
 | 495 |             successOverlay();
 | 
 | 496 |             clearTimer();
 | 
 | 497 |             clearValidateMsg();
 | 
 | 498 |             initialize();
 | 
 | 499 |         }
 | 
 | 500 |     }
 | 
 | 501 | 
 | 
 | 502 |     function initialize() {
 | 
 | 503 |         var container = $('#container');
 | 
 | 504 |         ko.cleanNode(container[0]);
 | 
 | 505 |         var vm = new WifiAdvanceViewModel();
 | 
 | 506 |         ko.applyBindings(vm, container[0]);
 | 
 | 507 |         addTimeout(function () {
 | 
 | 508 |             checkAccessMode();
 | 
 | 509 |         }, 600);
 | 
 | 510 | 
 | 
 | 511 |         if (config.WDS_SUPPORT) {
 | 
 | 512 |             checkWifiStatusUseWDS();
 | 
 | 513 |         } else if (config.AP_STATION_SUPPORT) {
 | 
 | 514 |             checkWifiStatus();
 | 
 | 515 |         }
 | 
 | 516 |         
 | 
 | 517 |         $('#wifi_advance_form').validate({
 | 
 | 518 |             submitHandler: function () {
 | 
 | 519 |                 vm.save();
 | 
 | 520 |             }
 | 
 | 521 |         });
 | 
 | 522 |         
 | 
 | 523 |         $('#frmWifiSwitch').validate({
 | 
 | 524 |             submitHandler: function () {
 | 
 | 525 |                 vm.setMultiSSIDSwitch();
 | 
 | 526 |             }
 | 
 | 527 |         });
 | 
 | 528 |     }
 | 
 | 529 | 
 | 
 | 530 |     function checkWifiStatusUseWDS() {
 | 
 | 531 |         var baseInfo = service.getWdsInfo();
 | 
 | 532 |         if (baseInfo.currentMode == "0") {
 | 
 | 533 |             $(':input', '#frmWifiSwitch,#wifi_advance_form').each(function () {
 | 
 | 534 |                 $(this).prop("disabled", false);
 | 
 | 535 |             });
 | 
 | 536 |         } else {
 | 
 | 537 |             $(':input', '#frmWifiSwitch,#wifi_advance_form').each(function () {
 | 
 | 538 |                 $(this).prop("disabled", true);
 | 
 | 539 |             });
 | 
 | 540 |         }
 | 
 | 541 |     }
 | 
 | 542 | 
 | 
 | 543 |     function checkWifiStatus() {
 | 
 | 544 |         var baseInfo = service.getAPStationBasic();
 | 
 | 545 |         if (baseInfo.ap_station_enable != "1") {
 | 
 | 546 |             $(':input', '#wifi_advance_form').each(function () {
 | 
 | 547 |                 $(this).prop("disabled", false);
 | 
 | 548 |             });
 | 
 | 549 |         } else {
 | 
 | 550 |             $(':input', '#wifi_advance_form').each(function () {
 | 
 | 551 |                 $(this).prop("disabled", true);
 | 
 | 552 |             });
 | 
 | 553 |         }
 | 
 | 554 |     }
 | 
 | 555 | 
 | 
 | 556 |     return {
 | 
 | 557 |         init: initialize
 | 
 | 558 |     };
 | 
 | 559 | });
 | 
 | 560 | 
 | 
 | 561 | define("wifi_ap_station","underscore jquery knockout set service".split(" "),
 | 
 | 562 |     function (_, $, ko, config, service) {
 | 
 | 563 |     var viaWifi = false;
 | 
 | 564 |     function checkAccessMode() {
 | 
 | 565 |         service.getParams({
 | 
 | 566 |             nv: 'user_ip_addr'
 | 
 | 567 |         }, function (dataIp) {
 | 
 | 568 |             service.getParams({
 | 
 | 569 |                 nv: 'station_list'
 | 
 | 570 |             }, function (dataList) {
 | 
 | 571 |                 viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
 | 
 | 572 |             });
 | 
 | 573 |         });
 | 
 | 574 |     }
 | 
 | 575 | 
 | 
 | 576 |     function apStationViewMode() {
 | 
 | 577 |         var target = this;
 | 
 | 578 |         var ssid_ex = "";
 | 
 | 579 |         target.hasMultiSSID = config.HAS_MULTI_SSID;
 | 
 | 580 |         target.hasAPStation = config.AP_STATION_SUPPORT;
 | 
 | 581 |         target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
 | 
 | 582 |         target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
 | 
 | 583 | 
 | 
 | 584 |         var securityModes = _.map(config.AUTH_MODES_ALL, function (item) {
 | 
 | 585 |             return new Option(item.name, item.value);
 | 
 | 586 |         });
 | 
 | 587 |         //当前页面标识  list列表页 add添加页面  edit编辑页面
 | 
 | 588 |         target.page = {
 | 
 | 589 |             list: 1,
 | 
 | 590 |             add: 2,
 | 
 | 591 |             edit: 3
 | 
 | 592 |         };
 | 
 | 593 |         //WiFi热点列表列的配置项
 | 
 | 594 |         var gridColumn = [{
 | 
 | 595 |                 columnType: "radio",
 | 
 | 596 |                 headerTextTrans: "option",
 | 
 | 597 |                 rowText: "profileName",
 | 
 | 598 |                 width: "10%"
 | 
 | 599 |             }, {
 | 
 | 600 |                 headerTextTrans: "ssid_title",
 | 
 | 601 |                 rowText: "ssid",
 | 
 | 602 |                 width: "30%"
 | 
 | 603 |             }, {
 | 
 | 604 |                 columnType: "image",
 | 
 | 605 |                 headerTextTrans: "signal",
 | 
 | 606 |                 rowText: "imgSignal",
 | 
 | 607 |                 width: "30%"
 | 
 | 608 |             }, {
 | 
 | 609 |                 headerTextTrans: "security_mode",
 | 
 | 610 |                 rowText: "authMode_show",
 | 
 | 611 |                 width: "30%"
 | 
 | 612 |             }
 | 
 | 613 |         ];
 | 
 | 614 |         //搜索到的WiFi热点列表列的配置项
 | 
 | 615 |         var searchGridColumn = [{
 | 
 | 616 |                 columnType: "radio",
 | 
 | 617 |                 rowText: "index",
 | 
 | 618 |                 width: "10%"
 | 
 | 619 |             }, {
 | 
 | 620 |                 headerTextTrans: "ssid_title",
 | 
 | 621 |                 rowText: "ssid",
 | 
 | 622 |                 width: "30%"
 | 
 | 623 |             }, {
 | 
 | 624 |                 columnType: "image",
 | 
 | 625 |                 headerTextTrans: "signal",
 | 
 | 626 |                 rowText: "imgSignal",
 | 
 | 627 |                 width: "30%"
 | 
 | 628 |             }, {
 | 
 | 629 |                 headerTextTrans: "security_mode",
 | 
 | 630 |                 rowText: "authMode_show",
 | 
 | 631 |                 width: "30%"
 | 
 | 632 |             }
 | 
 | 633 |         ];
 | 
 | 634 | 
 | 
 | 635 |         target.pageState = ko.observable(target.page.list);
 | 
 | 636 | 
 | 
 | 637 |         var info = service.getAPStationBasic();
 | 
 | 638 | 
 | 
 | 639 |         target.origin_ap_station_enable = info.ap_station_enable;
 | 
 | 640 |         target.ap_station_enable = ko.observable(info.ap_station_enable);
 | 
 | 641 |         target.apList = ko.observable([]);
 | 
 | 642 |         if (target.origin_ap_station_enable == "1") {
 | 
 | 643 |             var apList = service.getHotspotList();
 | 
 | 644 |             target.apList(fixHotspotList(apList.hotspotList));
 | 
 | 645 |         }
 | 
 | 646 | 
 | 
 | 647 |         target.apSearchList = ko.observable([]);
 | 
 | 648 | 
 | 
 | 649 |         target.connectButtonStatus = ko.observable("disable");
 | 
 | 650 |         target.hasSelectFromUser = ko.observable();
 | 
 | 651 |         target.showPassword = ko.observable(false);
 | 
 | 652 | 
 | 
 | 653 |         target.isCableMode = ko.observable();
 | 
 | 654 | 
 | 
 | 655 |         var infoBasic = service.getWifiBasic();
 | 
 | 656 |         target.wifi_enable = ko.observable(infoBasic.wifi_enable);
 | 
 | 657 | 
 | 
 | 658 |         target.isShowSSIDInfoDiv = ko.observable(false);
 | 
 | 659 |         if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 660 |             if (infoBasic.wifi_enable == "1") {
 | 
 | 661 |                 target.isShowSSIDInfoDiv(true);
 | 
 | 662 |             } else {
 | 
 | 663 |                 target.isShowSSIDInfoDiv(false);
 | 
 | 664 |             }
 | 
 | 665 |         } else {
 | 
 | 666 |             target.isShowSSIDInfoDiv(true);
 | 
 | 667 |         }
 | 
 | 668 |         target.multi_ssid_enable = ko.observable(infoBasic.multi_ssid_enable);
 | 
 | 669 | 
 | 
 | 670 |         //密码显示事件
 | 
 | 671 |         target.showPasswordHandler = function () {
 | 
 | 672 |             $("#codeWPAKey").parent().find(".error").hide();
 | 
 | 673 |             $("#pwdWepKey").parent().find(".error").hide();
 | 
 | 674 |             var checkbox = $("#showPassword:checked");
 | 
 | 675 |             if (checkbox && checkbox.length == 0) {
 | 
 | 676 |                 target.showPassword(true);
 | 
 | 677 |             } else {
 | 
 | 678 |                 target.showPassword(false);
 | 
 | 679 |             }
 | 
 | 680 |         };
 | 
 | 681 | 
 | 
 | 682 |         target.showWPAPasswordHandler = function () {
 | 
 | 683 |             $("#codeWPAKey").parent().find(".error").hide();
 | 
 | 684 |             $("#pwdWepKey").parent().find(".error").hide();
 | 
 | 685 |             if ($("#showWPAPassword").is(":checked")) {
 | 
 | 686 |                 target.showPassword(true);
 | 
 | 687 |             } else {
 | 
 | 688 |                 target.showPassword(false);
 | 
 | 689 |             }
 | 
 | 690 |         };
 | 
 | 691 | 
 | 
 | 692 |         //列表模板创建
 | 
 | 693 |         target.apGrid = new ko.simpleGrid.viewModel({
 | 
 | 694 |             idName: "profileName",
 | 
 | 695 |             data: target.apList(),
 | 
 | 696 |             tmplType: 'list',
 | 
 | 697 |             pageSize: 100,
 | 
 | 698 |             columns: gridColumn,
 | 
 | 699 |             primaryColumn: "fromProvider",
 | 
 | 700 |             radioClickHandler: function () {
 | 
 | 701 |                 computeButtonState();
 | 
 | 702 |             }
 | 
 | 703 |         });
 | 
 | 704 |         //热点搜索结果列表模板创建
 | 
 | 705 |         target.apSearchGrid = new ko.simpleGrid.viewModel({
 | 
 | 706 |             data: target.apSearchList(),
 | 
 | 707 |             idName: "index",
 | 
 | 708 |             tmplType: 'list',
 | 
 | 709 |             pageSize: 100,
 | 
 | 710 |             columns: searchGridColumn,
 | 
 | 711 |             radioClickHandler: function () {
 | 
 | 712 |                 var index = target.apSearchGrid.radioSelectValue();
 | 
 | 713 |                 var aplist = target.apSearchList();
 | 
 | 714 |                 for (var i = 0; i < aplist.length; i++) {
 | 
 | 715 |                     var list_item = aplist[i];
 | 
 | 716 |                     if (list_item.index == index) {
 | 
 | 717 |                         target.profileName("");
 | 
 | 718 |                         target.ssid(list_item.ssid);
 | 
 | 719 |                         ssid_ex = list_item.ssid;
 | 
 | 720 |                         target.signal(list_item.signal);
 | 
 | 721 |                         target.authMode(list_item.authMode);
 | 
 | 722 |                         target.password(list_item.password);
 | 
 | 723 |                         target.mac(list_item.mac);
 | 
 | 724 |                         if (list_item.authMode == "WPAPSKWPA2PSK" || list_item.authMode == "WPA2PSK" || list_item.authMode == "WPAPSK" || list_item.authMode == "WPA3Personal" || list_item.authMode == "WPA2WPA3") {
 | 
 | 725 |                             target.encryptType_WPA(list_item.encryptType);
 | 
 | 726 |                         } else {
 | 
 | 727 |                             target.encryptType(list_item.encryptType);
 | 
 | 728 |                         }
 | 
 | 729 |                         target.keyID(list_item.keyID);
 | 
 | 730 |                         renderCustomElement($("#cipherGroup"));
 | 
 | 731 |                         break;
 | 
 | 732 |                     }
 | 
 | 733 |                 }
 | 
 | 734 |             }
 | 
 | 735 |         });
 | 
 | 736 | 
 | 
 | 737 |         //计算并设置当前连接和按钮的状态
 | 
 | 738 |         target.computeConnectStatus = function () {
 | 
 | 739 |             computeButtonState();
 | 
 | 740 | 
 | 
 | 741 |             var networkStatus = target.connectStatus();
 | 
 | 742 |             if (networkStatus == "ppp_connected") {
 | 
 | 743 |                 target.current_status_trans("ap_station_wan_connected");
 | 
 | 744 |                 target.current_status_text($.i18n.prop("ap_station_wan_connected"));
 | 
 | 745 |                 return;
 | 
 | 746 |             }
 | 
 | 747 | 
 | 
 | 748 |             var ssid = target.connectWifiSSID();
 | 
 | 749 |             var wifiStatus = target.connectWifiStatus();
 | 
 | 750 |             if (ssid && wifiStatus == "connect") {
 | 
 | 751 |                 target.current_status_trans("ap_station_wlan_connected");
 | 
 | 752 |                 target.current_status_text($.i18n.prop("ap_station_wlan_connected"));
 | 
 | 753 |                 return;
 | 
 | 754 |             }
 | 
 | 755 | 
 | 
 | 756 |             target.current_status_trans("ap_station_no_connection");
 | 
 | 757 |             target.current_status_text($.i18n.prop("ap_station_no_connection"));
 | 
 | 758 |         };
 | 
 | 759 |         //计算并设置按钮的状态
 | 
 | 760 |         function computeButtonState() {
 | 
 | 761 |             var profileName = target.apGrid.radioSelectValue();
 | 
 | 762 |             if (!profileName) {
 | 
 | 763 |                 target.hasSelectFromUser(false);
 | 
 | 764 |                 target.connectButtonStatus("disable");
 | 
 | 765 |                 return;
 | 
 | 766 |             }
 | 
 | 767 | 
 | 
 | 768 |             var status = "";
 | 
 | 769 |             var fromProvider = "";
 | 
 | 770 |             for (var i = 0; i < target.apList().length; i++) {
 | 
 | 771 |                 var list_item = target.apList()[i];
 | 
 | 772 |                 if (list_item.profileName == profileName) {
 | 
 | 773 |                     status = list_item.connectStatus;
 | 
 | 774 |                     fromProvider = list_item.fromProvider;
 | 
 | 775 |                     break;
 | 
 | 776 |                 }
 | 
 | 777 |             }
 | 
 | 778 | 
 | 
 | 779 |             if (status == "1") {
 | 
 | 780 |                 target.connectButtonStatus("hide");
 | 
 | 781 |                 target.hasSelectFromUser(false);
 | 
 | 782 |             } else {
 | 
 | 783 |                 target.connectButtonStatus("show");
 | 
 | 784 |                 target.hasSelectFromUser(fromProvider == "0");
 | 
 | 785 |             }
 | 
 | 786 |         }
 | 
 | 787 |         var statusInfo = service.getStatusInfo();
 | 
 | 788 |         target.networkType = ko.observable(statusInfo.networkType);
 | 
 | 789 |         target.networkOperator = ko.observable(statusInfo.networkOperator);
 | 
 | 790 |         target.connectStatus = ko.observable(statusInfo.connectStatus);
 | 
 | 791 |         target.connectWifiStatus = ko.observable(statusInfo.connectWifiStatus);
 | 
 | 792 |         target.connectWifiProfile = ko.observable(statusInfo.connectWifiProfile);
 | 
 | 793 |         target.connectWifiSSID = ko.observable(statusInfo.connectWifiSSID);
 | 
 | 794 | 
 | 
 | 795 |         target.current_status_trans = ko.observable("");
 | 
 | 796 |         target.current_status_text = ko.observable("");
 | 
 | 797 |         target.current_status = ko.computed(function () {
 | 
 | 798 |             target.computeConnectStatus()
 | 
 | 799 |         });
 | 
 | 800 | 
 | 
 | 801 |         target.modes = securityModes;
 | 
 | 802 |         target.profileName = ko.observable("");
 | 
 | 803 |         target.ssid = ko.observable();
 | 
 | 804 |         target.signal = ko.observable("0");
 | 
 | 805 |         target.authMode = ko.observable();
 | 
 | 806 |         target.password = ko.observable();
 | 
 | 807 |         target.encryptType = ko.observable();
 | 
 | 808 |         target.encryptType_WPA = ko.observable("TKIPCCMP");
 | 
 | 809 |         target.keyID = ko.observable("0");
 | 
 | 810 |         target.mac = ko.observable();
 | 
 | 811 | 
 | 
 | 812 |         target.openAddPage = function () {
 | 
 | 813 |             if (wifiIsClosed()) {
 | 
 | 814 |                 return;
 | 
 | 815 |             }
 | 
 | 816 |             if (wpsIsOn()) {
 | 
 | 817 |                 return;
 | 
 | 818 |             }
 | 
 | 819 |             target.clear();
 | 
 | 820 |             getSearchHotspot();
 | 
 | 821 |         };
 | 
 | 822 | 
 | 
 | 823 |         //打开基本设置页面
 | 
 | 824 |         target.openListPage = function () {
 | 
 | 825 |             if (wifiIsClosed()) {
 | 
 | 826 |                 return;
 | 
 | 827 |             }
 | 
 | 828 |             if (wpsIsOn()) {
 | 
 | 829 |                 return;
 | 
 | 830 |             }
 | 
 | 831 |             target.clear();
 | 
 | 832 |             target.pageState(target.page.list);
 | 
 | 833 |             target.apGrid.data(target.apList());
 | 
 | 834 |             v.computeConnectStatus();
 | 
 | 835 |         };
 | 
 | 836 | 
 | 
 | 837 |         target.addHotspot = function () {
 | 
 | 838 |             if (wifiIsClosed()) {
 | 
 | 839 |                 return;
 | 
 | 840 |             }
 | 
 | 841 |             if (wpsIsOn()) {
 | 
 | 842 |                 return;
 | 
 | 843 |             }
 | 
 | 844 |             if (target.pageState() == target.page.add && target.apList().length >= config.AP_STATION_LIST_LENGTH) {
 | 
 | 845 |                 showAlert({
 | 
 | 846 |                     msg: "ap_station_exceed_list_max",
 | 
 | 847 |                     params: config.AP_STATION_LIST_LENGTH
 | 
 | 848 |                 });
 | 
 | 849 |                 return;
 | 
 | 850 |             }
 | 
 | 851 |             showLoading('waiting');
 | 
 | 852 |             var wifi_para = {};
 | 
 | 853 |             var profileName = target.apGrid.radioSelectValue();
 | 
 | 854 |             wifi_para.profileName = target.profileName();
 | 
 | 855 |             wifi_para.ssid = target.ssid();
 | 
 | 856 |             wifi_para.signal = target.signal();
 | 
 | 857 |             wifi_para.authMode = target.authMode();
 | 
 | 858 |             wifi_para.password = target.password();
 | 
 | 859 |             if (wifi_para.authMode == "SHARED") {
 | 
 | 860 |                 wifi_para.encryptType = "WEP";
 | 
 | 861 |             } else if (wifi_para.authMode == "WPAPSKWPA2PSK" || wifi_para.authMode == "WPA2PSK" || wifi_para.authMode == "WPAPSK" || wifi_para.authMode == "WPA3Personal" || wifi_para.authMode == "WPA2WPA3") {
 | 
 | 862 |                 wifi_para.encryptType = target.encryptType_WPA();
 | 
 | 863 |             } else {
 | 
 | 864 |                 wifi_para.encryptType = target.encryptType();
 | 
 | 865 |             }
 | 
 | 866 |             wifi_para.keyID = target.keyID();
 | 
 | 867 |             wifi_para.mac = (target.mac() == "" || target.ssid() != ssid_ex) ? "0F:00:00:00:00:00" : target.mac();
 | 
 | 868 |             wifi_para.apList = target.apList();
 | 
 | 869 |             service.saveHotspot(wifi_para, function (data) {
 | 
 | 870 |                 target.callback(data, true);
 | 
 | 871 |             });
 | 
 | 872 |         };
 | 
 | 873 | 
 | 
 | 874 |         target.deleteHotspot = function () {
 | 
 | 875 |             if (wifiIsClosed()) {
 | 
 | 876 |                 return;
 | 
 | 877 |             }
 | 
 | 878 |             if (wpsIsOn()) {
 | 
 | 879 |                 return;
 | 
 | 880 |             }
 | 
 | 881 |             showConfirm("confirm_data_delete", function () {
 | 
 | 882 |                 var wifi_para = {};
 | 
 | 883 |                 wifi_para.profileName = target.apGrid.radioSelectValue();
 | 
 | 884 |                 wifi_para.apList = target.apList();
 | 
 | 885 |                 showLoading('waiting');
 | 
 | 886 |                 service.deleteHotspot(wifi_para, function (data) {
 | 
 | 887 |                     target.callback(data, true);
 | 
 | 888 |                 });
 | 
 | 889 |             });
 | 
 | 890 |         };
 | 
 | 891 | 
 | 
 | 892 |         target.openEditPage = function () {
 | 
 | 893 |             if (wifiIsClosed()) {
 | 
 | 894 |                 return;
 | 
 | 895 |             }
 | 
 | 896 |             if (wpsIsOn()) {
 | 
 | 897 |                 return;
 | 
 | 898 |             }
 | 
 | 899 |             var profileName = target.apGrid.radioSelectValue();
 | 
 | 900 |             var aplist = target.apList();
 | 
 | 901 |             for (var i = 0; i < aplist.length; i++) {
 | 
 | 902 |                 var list_item = aplist[i];
 | 
 | 903 |                 if (list_item.profileName == profileName) {
 | 
 | 904 |                     target.profileName(profileName);
 | 
 | 905 |                     target.ssid(list_item.ssid);
 | 
 | 906 |                     target.signal(list_item.signal);
 | 
 | 907 |                     target.authMode(list_item.authMode);
 | 
 | 908 |                     target.password(list_item.password);
 | 
 | 909 |                     target.mac(list_item.mac);
 | 
 | 910 |                     if (list_item.authMode == "WPAPSKWPA2PSK" || list_item.authMode == "WPA2PSK" || list_item.authMode == "WPAPSK" || list_item.authMode == "WPA3Personal" || list_item.authMode == "WPA2WPA3") {
 | 
 | 911 |                         target.encryptType_WPA(list_item.encryptType);
 | 
 | 912 |                     } else {
 | 
 | 913 |                         target.encryptType(list_item.encryptType);
 | 
 | 914 |                     }
 | 
 | 915 |                     target.keyID(list_item.keyID);
 | 
 | 916 |                 }
 | 
 | 917 |             }
 | 
 | 918 |             target.pageState(target.page.edit);
 | 
 | 919 |         };
 | 
 | 920 | 
 | 
 | 921 |         target.connectHotspot = function () {
 | 
 | 922 |             if (wifiIsClosed()) {
 | 
 | 923 |                 return;
 | 
 | 924 |             }
 | 
 | 925 |             if (wpsIsOn()) {
 | 
 | 926 |                 return;
 | 
 | 927 |             }
 | 
 | 928 |             var profileName = target.apGrid.radioSelectValue();
 | 
 | 929 |             var apList = target.apList();
 | 
 | 930 | 
 | 
 | 931 |             function connect() {
 | 
 | 932 |                 showLoading("connecting");
 | 
 | 933 |                 var wifi_para = {};
 | 
 | 934 |                 var connectIndex = -1;
 | 
 | 935 |                 var ssid = "";
 | 
 | 936 |                 for (var i = 0; i < apList.length; i++) {
 | 
 | 937 |                     if (apList[i].profileName == profileName) {
 | 
 | 938 | 
 | 
 | 939 |                         wifi_para.EX_SSID1 = apList[i].ssid;
 | 
 | 940 |                         wifi_para.EX_AuthMode = apList[i].authMode;
 | 
 | 941 |                         wifi_para.EX_EncrypType = apList[i].encryptType;
 | 
 | 942 |                         wifi_para.EX_DefaultKeyID = apList[i].keyID;
 | 
 | 943 |                         wifi_para.EX_WEPKEY = apList[i].password;
 | 
 | 944 |                         wifi_para.EX_WPAPSK1 = apList[i].password;
 | 
 | 945 |                         wifi_para.EX_wifi_profile = apList[i].profileName;
 | 
 | 946 |                         wifi_para.EX_mac = apList[i].mac;
 | 
 | 947 |                         connectIndex = i;
 | 
 | 948 |                         ssid = apList[i].ssid;
 | 
 | 949 |                         break;
 | 
 | 950 |                     }
 | 
 | 951 |                 }
 | 
 | 952 | 
 | 
 | 953 |                 target.connectWifiSSID(ssid);
 | 
 | 954 |                 target.connectWifiStatus("connecting");
 | 
 | 955 |                 target.apGrid.setRadioSelect(profileName);
 | 
 | 956 |                 target.connectButtonStatus("disable");
 | 
 | 957 | 
 | 
 | 958 |                 service.connectHotspot(wifi_para, function (data) {
 | 
 | 959 |                     if (data && data.result == "success") {
 | 
 | 960 |                         target.connectButtonStatus("disable");
 | 
 | 961 |                         //延迟检测 确保取得的状态是最新的
 | 
 | 962 |                         addTimeout(checkWifiStatus, 3000);
 | 
 | 963 |                     } else if (data && data.result == "processing") {
 | 
 | 964 |                         showAlert("ap_station_processing");
 | 
 | 965 |                     } else {
 | 
 | 966 |                         var apList = target.apList(); // cov_2
 | 
 | 967 |                         apList[connectIndex].connectStatus = "0";
 | 
 | 968 |                         target.connectWifiStatus("disconnect");
 | 
 | 969 |                         target.connectButtonStatus("show");
 | 
 | 970 |                         hideLoading();
 | 
 | 971 |                         errorOverlay();
 | 
 | 972 |                     }
 | 
 | 973 |                     var apList = service.getHotspotList();
 | 
 | 974 |                     target.apList(fixHotspotList(apList.hotspotList));
 | 
 | 975 |                     target.connectWifiProfile(profileName);
 | 
 | 976 |                     target.connectWifiSSID(ssid);
 | 
 | 977 |                     target.apGrid.data([]);
 | 
 | 978 |                     target.apGrid.data(target.apList());
 | 
 | 979 |                     target.apGrid.setRadioSelect(profileName);
 | 
 | 980 |                 });
 | 
 | 981 |             }
 | 
 | 982 | 
 | 
 | 983 |             //将用户选中的profile排在运营商定制profile后的第一位
 | 
 | 984 |             function refreshApList(profile, aplist) {
 | 
 | 985 |                 var apListLeft = [];
 | 
 | 986 |                 var apListPre = [];
 | 
 | 987 |                 for (var i = 0; i < aplist.length; i++) {
 | 
 | 988 |                     if (aplist[i].fromProvider != "1") {
 | 
 | 989 |                         if (aplist[i].profileName == profile) {
 | 
 | 990 |                             apListPre.push(apList[i]);
 | 
 | 991 |                         } else {
 | 
 | 992 |                             apListLeft.push(apList[i]);
 | 
 | 993 |                         }
 | 
 | 994 |                     } else {
 | 
 | 995 |                         apListPre.push(apList[i]);
 | 
 | 996 |                     }
 | 
 | 997 |                 }
 | 
 | 998 |                 var apListNew = apListPre.concat(apListLeft);
 | 
 | 999 |                 service.saveHotspot({
 | 
 | 1000 |                     apList: apListNew
 | 
 | 1001 |                 }, function (data) {
 | 
 | 1002 |                     if (data && data.result == "success") {
 | 
 | 1003 |                         apList = apListNew;
 | 
 | 1004 |                         target.apList(fixHotspotList(apList));
 | 
 | 1005 |                     }
 | 
 | 1006 |                 });
 | 
 | 1007 |             }
 | 
 | 1008 | 
 | 
 | 1009 |             var check_count = 0;
 | 
 | 1010 |             var connectStatus = false;
 | 
 | 1011 | 
 | 
 | 1012 |             var status = service.getStatusInfo();
 | 
 | 1013 |             if (status.connectStatus == "ppp_connected" || status.connectStatus == "ppp_connecting") {
 | 
 | 1014 |                 showConfirm("ap_station_connect_change_alert", function () {
 | 
 | 1015 |                     showLoading();
 | 
 | 1016 |                     connect();
 | 
 | 1017 |                 });
 | 
 | 1018 |             } else {
 | 
 | 1019 |                 connect();
 | 
 | 1020 |             }
 | 
 | 1021 | 
 | 
 | 1022 |             function checkWifiStatus() {
 | 
 | 1023 |                 check_count = check_count + 1;
 | 
 | 1024 |                 if (check_count > 60) {
 | 
 | 1025 |                     hideLoading();
 | 
 | 1026 |                     errorOverlay();
 | 
 | 1027 |                     return;
 | 
 | 1028 |                 }
 | 
 | 1029 |                 if (!connectStatus) {
 | 
 | 1030 |                     var status = service.getStatusInfo();
 | 
 | 1031 |                     if (status.connectWifiStatus != "connect") {
 | 
 | 1032 |                         addTimeout(checkWifiStatus, 1000);
 | 
 | 1033 |                     } else {
 | 
 | 1034 |                         connectStatus = true;
 | 
 | 1035 |                     }
 | 
 | 1036 |                 }
 | 
 | 1037 |                 if (connectStatus) {
 | 
 | 1038 |                     //继续判断profile中连接状态是否为1
 | 
 | 1039 |                     service.getHotspotList({}, function (data) {
 | 
 | 1040 |                         for (var i = 0, len = data.hotspotList.length; i < len; i++) {
 | 
 | 1041 |                             var list_item = data.hotspotList[i];
 | 
 | 1042 |                             if (list_item.profileName == profileName) {
 | 
 | 1043 |                                 if (list_item.connectStatus == "1") {
 | 
 | 1044 |                                     hideLoading();
 | 
 | 1045 |                                     return;
 | 
 | 1046 |                                 } else {
 | 
 | 1047 |                                     var errorMsg = {
 | 
 | 1048 |                                         msg: 'ap_connect_error',
 | 
 | 1049 |                                         params: [list_item.ssid]
 | 
 | 1050 |                                     };
 | 
 | 1051 |                                     showAlert(errorMsg);
 | 
 | 1052 |                                     return;
 | 
 | 1053 |                                 }
 | 
 | 1054 |                                 break;
 | 
 | 1055 |                             }
 | 
 | 1056 |                         }
 | 
 | 1057 |                         addTimeout(checkWifiStatus, 1000);
 | 
 | 1058 |                     });
 | 
 | 1059 |                 }
 | 
 | 1060 |             }
 | 
 | 1061 | 
 | 
 | 1062 |         };
 | 
 | 1063 | 
 | 
 | 1064 |         target.disconnectHotspot = function () {
 | 
 | 1065 |             if (wpsIsOn()) {
 | 
 | 1066 |                 return;
 | 
 | 1067 |             }
 | 
 | 1068 |             showLoading('disconnecting');
 | 
 | 1069 |             service.disconnectHotspot({}, function (data) {
 | 
 | 1070 |                 target.callback(data, true);
 | 
 | 1071 |             })
 | 
 | 1072 |         };
 | 
 | 1073 | 
 | 
 | 1074 |         function getSearchHotspot() {
 | 
 | 1075 |             var check_count = 0;
 | 
 | 1076 | 
 | 
 | 1077 |             function search() {
 | 
 | 1078 |                 var result = service.getSearchHotspotList();
 | 
 | 1079 |                 if (result.scan_finish == "0") {
 | 
 | 1080 |                     if (check_count <= 60) {
 | 
 | 1081 |                         check_count = check_count + 1;
 | 
 | 1082 |                         addTimeout(search, 1000);
 | 
 | 1083 |                     } else {
 | 
 | 1084 |                         hideLoading();
 | 
 | 1085 |                         showAlert("ap_station_search_hotspot_fail");
 | 
 | 1086 |                     }
 | 
 | 1087 |                 } else {
 | 
 | 1088 |                     if ("2" == result.scan_finish) {
 | 
 | 1089 |                         hideLoading();
 | 
 | 1090 |                         showAlert("ap_station_processing");
 | 
 | 1091 |                     } else {
 | 
 | 1092 |                         target.apSearchList(fixHotspotList(result.hotspotList));
 | 
 | 1093 |                         target.apSearchGrid.data(target.apSearchList());
 | 
 | 1094 |                         hideLoading();
 | 
 | 1095 |                     }
 | 
 | 1096 |                 }
 | 
 | 1097 |             }
 | 
 | 1098 | 
 | 
 | 1099 |             showLoading('scanning');
 | 
 | 1100 |             service.searchHotspot({}, function (data) {
 | 
 | 1101 |                 if (data && data.result == "processing") {
 | 
 | 1102 |                     hideLoading();
 | 
 | 1103 |                     showAlert("ap_station_processing");
 | 
 | 1104 |                 } else if (data && data.result == "success") {
 | 
 | 1105 |                     if (target.pageState() != target.page.add) {
 | 
 | 1106 |                         target.pageState(target.page.add);
 | 
 | 1107 |                     }
 | 
 | 1108 |                     search();
 | 
 | 1109 |                 } else {
 | 
 | 1110 |                     if (target.pageState() != target.page.add) {
 | 
 | 1111 |                         target.pageState(target.page.add);
 | 
 | 1112 |                     }
 | 
 | 1113 |                     hideLoading();
 | 
 | 1114 |                     showAlert("ap_station_search_hotspot_fail");
 | 
 | 1115 |                 }
 | 
 | 1116 |             });
 | 
 | 1117 |         }
 | 
 | 1118 | 
 | 
 | 1119 |         //清除编辑页面的信息
 | 
 | 1120 |         target.clear = function () {
 | 
 | 1121 |             target.apSearchGrid.clearRadioSelect();
 | 
 | 1122 |             target.profileName("");
 | 
 | 1123 |             target.ssid("");
 | 
 | 1124 |             target.signal("0");
 | 
 | 1125 |             target.authMode("OPEN");
 | 
 | 1126 |             target.password("");
 | 
 | 1127 |             target.encryptType("NONE");
 | 
 | 1128 |             target.encryptType_WPA("TKIPCCMP");
 | 
 | 1129 |             target.keyID("0");
 | 
 | 1130 |             target.mac("");
 | 
 | 1131 |         };
 | 
 | 1132 | 
 | 
 | 1133 |         target.apply = function () {
 | 
 | 1134 |             if (wifiIsClosed()) {
 | 
 | 1135 |                 return;
 | 
 | 1136 |             }
 | 
 | 1137 |             if (wpsIsOn()) {
 | 
 | 1138 |                 return;
 | 
 | 1139 |             }
 | 
 | 1140 | 
 | 
 | 1141 |             function setBasic() {
 | 
 | 1142 |                 showLoading('waiting');
 | 
 | 1143 |                 var wifi_para = {};
 | 
 | 1144 |                 wifi_para.ap_station_enable = target.ap_station_enable();
 | 
 | 1145 |                 service.setAPStationBasic(wifi_para, function (data) {
 | 
 | 1146 |                     if (target.origin_ap_station_enable == target.ap_station_enable()) {
 | 
 | 1147 |                         target.callback(data, true);
 | 
 | 1148 |                     } else {
 | 
 | 1149 |                         target.callback2(data, true);
 | 
 | 1150 |                     }
 | 
 | 1151 |                 });
 | 
 | 1152 |                 service.refreshAPStationStatus();
 | 
 | 1153 |             }
 | 
 | 1154 |             if (!config.HAS_MULTI_SSID) {
 | 
 | 1155 |                 setBasic();
 | 
 | 1156 |             } else {
 | 
 | 1157 |                 var infoBasic = service.getWifiBasic();
 | 
 | 1158 |                 if (target.ap_station_enable() == "1" && infoBasic.multi_ssid_enable == "1") {
 | 
 | 1159 |                     showConfirm("ap_station_enable_confirm", setBasic);
 | 
 | 1160 |                 } else {
 | 
 | 1161 |                     setBasic();
 | 
 | 1162 |                 }
 | 
 | 1163 |             }
 | 
 | 1164 |         };
 | 
 | 1165 |         //刷新搜到的热点列表
 | 
 | 1166 |         target.searchHotspot = function () {
 | 
 | 1167 |             if (wifiIsClosed()) {
 | 
 | 1168 |                 return;
 | 
 | 1169 |             }
 | 
 | 1170 |             if (wpsIsOn()) {
 | 
 | 1171 |                 return;
 | 
 | 1172 |             }
 | 
 | 1173 |             getSearchHotspot();
 | 
 | 1174 |         };
 | 
 | 1175 |         //和webserver交互时的回调,wifi不重启的情况
 | 
 | 1176 |         target.callback = function (data, isInitPage) {
 | 
 | 1177 |             if (data) {
 | 
 | 1178 |                 if (isInitPage) {
 | 
 | 1179 |                     initialize();
 | 
 | 1180 |                     $("#apList").translate();
 | 
 | 1181 |                 }
 | 
 | 1182 |                 if (data.result == "processing") {
 | 
 | 1183 |                     showAlert("ap_station_processing");
 | 
 | 1184 |                 } else if (data.result == "spot_connected" || data.result == "spot_connecting") {
 | 
 | 1185 |                     showAlert("ap_station_update_fail");
 | 
 | 1186 |                 } else if (data.result == "success") {
 | 
 | 1187 |                     successOverlay();
 | 
 | 1188 |                 } else if (data.result == "exist") {
 | 
 | 1189 |                     showAlert("ap_station_exist");
 | 
 | 1190 |                 } else {
 | 
 | 1191 |                     errorOverlay();
 | 
 | 1192 |                 }
 | 
 | 1193 |             } else {
 | 
 | 1194 |                 errorOverlay();
 | 
 | 1195 |             }
 | 
 | 1196 |         }
 | 
 | 1197 | 
 | 
 | 1198 |         //和webserver交互时的回调,wifi会重启的情况
 | 
 | 1199 |         target.callback2 = function (data, isInitPage) {
 | 
 | 1200 |             if (data) {
 | 
 | 1201 |                 if (!viaWifi) { //通过wifi登录webui
 | 
 | 1202 |                     addInterval(function () {
 | 
 | 1203 |                         var info = service.getWifiBasic();
 | 
 | 1204 |                         if (info.wifi_enable == "1") {
 | 
 | 1205 |                             clearTimer();
 | 
 | 1206 |                             clearValidateMsg();
 | 
 | 1207 |                             initialize();
 | 
 | 1208 |                             $("#apList").translate();
 | 
 | 1209 |                             if (data.result == "spot_connected" || data.result == "spot_connecting") {
 | 
 | 1210 |                                 showAlert("ap_station_update_fail");
 | 
 | 1211 |                             } else if (data.result == "success") {
 | 
 | 1212 |                                 successOverlay();
 | 
 | 1213 |                             } else {
 | 
 | 1214 |                                 errorOverlay();
 | 
 | 1215 |                             }
 | 
 | 1216 |                         }
 | 
 | 1217 |                     }, 1000);
 | 
 | 1218 |                 } else {
 | 
 | 1219 |                     setTimeout(function () {
 | 
 | 1220 |                         if (data.result == "processing") {
 | 
 | 1221 |                             showAlert("ap_station_processing");
 | 
 | 1222 |                         } else if (data.result == "spot_connecting" || data.result == "spot_connected") {
 | 
 | 1223 |                             showAlert("ap_station_update_fail");
 | 
 | 1224 |                         } else if (data.result == "success") {
 | 
 | 1225 |                             successOverlay();
 | 
 | 1226 |                             setTimeout(function () {
 | 
 | 1227 |                                 window.location.reload();
 | 
 | 1228 |                             }, 1000);
 | 
 | 1229 |                             clearTimer();
 | 
 | 1230 |                             clearValidateMsg();
 | 
 | 1231 |                             initialize();
 | 
 | 1232 |                         } else {
 | 
 | 1233 |                             errorOverlay();
 | 
 | 1234 |                         }
 | 
 | 1235 |                     }, 15000);
 | 
 | 1236 |                 }
 | 
 | 1237 |             } else {
 | 
 | 1238 |                 errorOverlay();
 | 
 | 1239 |             }
 | 
 | 1240 |         };
 | 
 | 1241 | 
 | 
 | 1242 |         target.checkSettings = function (ssid) {
 | 
 | 1243 |             var status = service.getWpsInfo();
 | 
 | 1244 |             if (status.wpsFlag == '1') {
 | 
 | 1245 |                 showAlert('wps_on_info');
 | 
 | 1246 |                 return true;
 | 
 | 1247 |             }
 | 
 | 1248 |             if (config.HAS_MULTI_SSID && info.multi_ssid_enable == "1") {
 | 
 | 1249 |                 if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)
 | 
 | 1250 |                      || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)) {
 | 
 | 1251 |                     showAlert({
 | 
 | 1252 |                         msg: 'multi_ssid_max_access_number_alert',
 | 
 | 1253 |                         params: info.MAX_Station_num
 | 
 | 1254 |                     });
 | 
 | 1255 |                     return true;
 | 
 | 1256 |                 }
 | 
 | 1257 |             }
 | 
 | 1258 | 
 | 
 | 1259 |             return false;
 | 
 | 1260 |         };
 | 
 | 1261 | 
 | 
 | 1262 |         target.setMultiSSIDSwitch = function () {
 | 
 | 1263 |             if (target.checkSettings("switch")) {
 | 
 | 1264 |                 return;
 | 
 | 1265 |             }
 | 
 | 1266 | 
 | 
 | 1267 |             var setSwitch = function () {
 | 
 | 1268 |                 showLoading('waiting');
 | 
 | 1269 |                 var params = {};
 | 
 | 1270 |                 params.m_ssid_enable = target.multi_ssid_enable();
 | 
 | 1271 |                 if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 1272 |                     params.wifiEnabled = target.wifi_enable();
 | 
 | 1273 |                 }
 | 
 | 1274 |                 service.setWifiBasicMultiSSIDSwitch(params, function (result) {
 | 
 | 1275 |                     if (result.result == "success") {
 | 
 | 1276 |                         if (!viaWifi) {
 | 
 | 1277 |                             addInterval(function () {
 | 
 | 1278 |                                 var info = service.getWifiBasic();
 | 
 | 1279 |                                 if (info.wifi_enable == target.wifi_enable()) {
 | 
 | 1280 |                                     successOverlay();
 | 
 | 1281 |                                     clearTimer();
 | 
 | 1282 |                                     clearValidateMsg();
 | 
 | 1283 |                                     service.refreshAPStationStatus();
 | 
 | 1284 |                                     initialize();
 | 
 | 1285 |                                 }
 | 
 | 1286 |                             }, 1000);
 | 
 | 1287 |                         } else {
 | 
 | 1288 |                             setTimeout(function () {
 | 
 | 1289 |                                 successOverlay();
 | 
 | 1290 |                                 setTimeout(function () {
 | 
 | 1291 |                                     window.location.reload();
 | 
 | 1292 |                                 }, 1000);
 | 
 | 1293 |                                 clearTimer();
 | 
 | 1294 |                                 clearValidateMsg();
 | 
 | 1295 |                                 service.refreshAPStationStatus();
 | 
 | 1296 |                                 initialize();
 | 
 | 1297 |                             }, 15000);
 | 
 | 1298 |                         }
 | 
 | 1299 |                     } else {
 | 
 | 1300 |                         errorOverlay();
 | 
 | 1301 |                     }
 | 
 | 1302 |                 });
 | 
 | 1303 |             };
 | 
 | 1304 | 
 | 
 | 1305 |             var info = service.getStatusInfo();
 | 
 | 1306 |             if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
 | 
 | 1307 |                 if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
 | 
 | 1308 |                     if (!info.wifiStatus) {
 | 
 | 1309 |                         showConfirm("multi_ssid_enable_confirm", function () {
 | 
 | 1310 |                             setSwitch();
 | 
 | 1311 |                         });
 | 
 | 1312 |                     } else {
 | 
 | 1313 |                         showConfirm("multi_ssid_enable_confirm2", function () {
 | 
 | 1314 |                             setSwitch();
 | 
 | 1315 |                         });
 | 
 | 1316 |                     }
 | 
 | 1317 |                 } else {
 | 
 | 1318 |                     if (!info.wifiStatus) {
 | 
 | 1319 |                         setSwitch();
 | 
 | 1320 |                     } else {
 | 
 | 1321 |                         showConfirm("wifi_disconnect_confirm2", function () {
 | 
 | 1322 |                             setSwitch();
 | 
 | 1323 |                         });
 | 
 | 1324 |                     }
 | 
 | 1325 |                 }
 | 
 | 1326 |             } else {
 | 
 | 1327 |                 setSwitch();
 | 
 | 1328 |             }
 | 
 | 1329 |         };
 | 
 | 1330 | 
 | 
 | 1331 |     }
 | 
 | 1332 | 
 | 
 | 1333 |     function wpsIsOn() {
 | 
 | 1334 |         var wifi_info = service.getWpsInfo();
 | 
 | 1335 |         if (wifi_info.wpsFlag == '1') {
 | 
 | 1336 |             showAlert('wps_on_info');
 | 
 | 1337 |             return true;
 | 
 | 1338 |         }
 | 
 | 1339 |     }
 | 
 | 1340 | 
 | 
 | 1341 |     //处理热点列表内容,以便在表格显示
 | 
 | 1342 |     function fixHotspotList(list) {
 | 
 | 1343 |         var fixedList = [];
 | 
 | 1344 |         for (var ii = 0; ii < list.length; ii++) {
 | 
 | 1345 |             list[ii].index = ii;
 | 
 | 1346 |             var url_image = "";
 | 
 | 1347 |             if (list[ii].connectStatus != "1") {
 | 
 | 1348 |                 if (list[ii].encryptType.toLowerCase() == "none" && list[ii].authMode.toLowerCase() == "open") {
 | 
 | 1349 |                     url_image = "pic/wlan_signal_" + list[ii].signal + ".png";
 | 
 | 1350 |                 } else {
 | 
 | 1351 |                     url_image = "pic/wlan_lock_signal_" + list[ii].signal + ".png";
 | 
 | 1352 |                 }
 | 
 | 1353 |             } else {
 | 
 | 1354 |                 if (list[ii].encryptType.toLowerCase() == "none" && list[ii].authMode.toLowerCase() == "open") {
 | 
 | 1355 |                     url_image = "pic/wlan_connected.png";
 | 
 | 1356 |                 } else {
 | 
 | 1357 |                     url_image = "pic/wlan_lock_connected.png";
 | 
 | 1358 |                 }
 | 
 | 1359 |             }
 | 
 | 1360 |             list[ii].imgSignal = url_image;
 | 
 | 1361 |             list[ii].authMode_show = $.i18n.prop("ap_station_security_mode_" + list[ii].authMode);
 | 
 | 1362 |         }
 | 
 | 1363 |         return list;
 | 
 | 1364 |     }
 | 
 | 1365 | 
 | 
 | 1366 |     function wifiIsClosed() {
 | 
 | 1367 |         var wifi_info = service.getWpsInfo();
 | 
 | 1368 |         if (wifi_info.radioFlag == "0") {
 | 
 | 1369 |             showAlert('wps_wifi_off');
 | 
 | 1370 |             return true;
 | 
 | 1371 |         }
 | 
 | 1372 |     }
 | 
 | 1373 | 
 | 
 | 1374 |     function event_bind(aps_vm) {
 | 
 | 1375 |         $("#showWPAPassword").change(function () {
 | 
 | 1376 |             aps_vm.showWPAPasswordHandler();
 | 
 | 1377 |         });
 | 
 | 1378 |         $("#showPassword").change(function () {
 | 
 | 1379 |             aps_vm.showPasswordHandler();
 | 
 | 1380 |         });
 | 
 | 1381 |     }
 | 
 | 1382 | 
 | 
 | 1383 |     function initialize() {
 | 
 | 1384 |         var aps_vm = new apStationViewMode();
 | 
 | 1385 |         var container = $('#container')[0];
 | 
 | 1386 |         ko.cleanNode(container);
 | 
 | 1387 |         ko.applyBindings(aps_vm, container);
 | 
 | 1388 |         event_bind(aps_vm);
 | 
 | 1389 | 
 | 
 | 1390 |         aps_refresh(true);
 | 
 | 1391 |         clearTimer();
 | 
 | 1392 |         addInterval(function () {
 | 
 | 1393 |             aps_refresh(false);
 | 
 | 1394 |             checkAccessMode();
 | 
 | 1395 |         }, 1000);
 | 
 | 1396 | 
 | 
 | 1397 |         $('#frmWifiSwitch').validate({
 | 
 | 1398 |             submitHandler: function () {
 | 
 | 1399 |                 aps_vm.setMultiSSIDSwitch();
 | 
 | 1400 |             }
 | 
 | 1401 |         });
 | 
 | 1402 | 
 | 
 | 1403 |         $("#frmAPStation").validate({
 | 
 | 1404 |             submitHandler: function () {
 | 
 | 1405 |                 aps_vm.addHotspot();
 | 
 | 1406 |             },
 | 
 | 1407 |             rules: {
 | 
 | 1408 |                 txtSSID: "ssid_ap"
 | 
 | 1409 |             },
 | 
 | 1410 |             errorPlacement: function (error, element) {
 | 
 | 1411 |                 var id = element.attr("id");
 | 
 | 1412 |                 if (id == "txtWPAKey" || id == "codeWPAKey") {
 | 
 | 1413 |                     error.insertAfter("#lblshowWPAPassword");
 | 
 | 1414 |                 } else if (id == "txtWepKey" || id == "pwdWepKey") {
 | 
 | 1415 |                     error.insertAfter("#lblShowPassword");
 | 
 | 1416 |                 } else {
 | 
 | 1417 |                     error.insertAfter(element);
 | 
 | 1418 |                 }
 | 
 | 1419 |             }
 | 
 | 1420 |         });
 | 
 | 1421 | 
 | 
 | 1422 |         function aps_refresh(initPage) {
 | 
 | 1423 |             var info = service.getStatusInfo();
 | 
 | 1424 |             if (info.multi_ssid_enable != "1") {
 | 
 | 1425 |                 aps_vm.isCableMode(checkCableMode(info.blc_wan_mode));
 | 
 | 1426 |                 aps_vm.connectWifiProfile(info.connectWifiProfile);
 | 
 | 1427 |                 aps_vm.connectWifiSSID(info.connectWifiSSID);
 | 
 | 1428 |                 aps_vm.connectWifiStatus(info.connectWifiStatus);
 | 
 | 1429 |                 aps_vm.networkType(info.networkType);
 | 
 | 1430 |                 aps_vm.connectStatus(info.connectStatus);
 | 
 | 1431 |                 aps_vm.computeConnectStatus();
 | 
 | 1432 | 
 | 
 | 1433 |                 service.getHotspotList({}, function (data) {
 | 
 | 1434 |                     var list = fixHotspotList(data.hotspotList);
 | 
 | 1435 |                     aps_vm.apList(list);
 | 
 | 1436 |                     var gripList = aps_vm.apGrid.data();
 | 
 | 1437 |                     if (list.length > 0 && list[0].profileName != gripList[0].profileName && list[0].connectStatus == "1") {
 | 
 | 1438 |                         aps_vm.apGrid.data([]);
 | 
 | 1439 |                         aps_vm.apGrid.data(aps_vm.apList());
 | 
 | 1440 |                         aps_vm.apGrid.setRadioSelect(list[0].profileName);
 | 
 | 1441 |                     }
 | 
 | 1442 |                     renderCustomElement($("#apList"));
 | 
 | 1443 |                     var radios = $("input[type='radio']", "#apList").each(function () {
 | 
 | 1444 |                         for (var i = 0, len = list.length; i < len; i++) {
 | 
 | 1445 |                             if (list[i].profileName == $(this).val()) {
 | 
 | 1446 |                                 var img = $(this).parent().parent().find("img")[0];
 | 
 | 1447 |                                 img.src = list[i].imgSignal;
 | 
 | 1448 |                                 if (initPage) {
 | 
 | 1449 |                                     if (list[i].connectStatus == "1") {
 | 
 | 1450 |                                         aps_vm.hasSelectFromUser(false);
 | 
 | 1451 |                                         aps_vm.connectButtonStatus("disable");
 | 
 | 1452 |                                     }
 | 
 | 1453 |                                 }
 | 
 | 1454 |                             }
 | 
 | 1455 |                         }
 | 
 | 1456 |                     });
 | 
 | 1457 |                 });
 | 
 | 1458 |             } else {
 | 
 | 1459 |                 //to do
 | 
 | 1460 |             }
 | 
 | 1461 |         }
 | 
 | 1462 | 
 | 
 | 1463 |     }
 | 
 | 1464 | 
 | 
 | 1465 |     return {
 | 
 | 1466 |         init: initialize
 | 
 | 1467 |     }
 | 
 | 1468 | });
 | 
 | 1469 | 
 | 
 | 1470 | define("wifi_guest","underscore jquery knockout set service CryptoJS".split(" "),
 | 
 | 1471 | 
 | 
 | 1472 |     function (_, $, ko, config, service, CryptoJS) {
 | 
 | 1473 | 
 | 
 | 1474 |     var viaWifi = false;
 | 
 | 1475 |     function checkAccessMode() {
 | 
 | 1476 |         service.getParams({
 | 
 | 1477 |             nv: 'user_ip_addr'
 | 
 | 1478 |         }, function (dataIp) {
 | 
 | 1479 |             service.getParams({
 | 
 | 1480 |                 nv: 'station_list'
 | 
 | 1481 |             }, function (dataList) {
 | 
 | 1482 |                 viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
 | 
 | 1483 |             });
 | 
 | 1484 |         });
 | 
 | 1485 |     }
 | 
 | 1486 | 
 | 
 | 1487 |     var securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
 | 
 | 1488 |         return new Option(item.name, item.value);
 | 
 | 1489 |     });
 | 
 | 1490 | 
 | 
 | 1491 |     function maxStationAccess(max) {
 | 
 | 1492 |         var showOption = [];
 | 
 | 1493 |         for (var i = 1; i <= max; i++) {
 | 
 | 1494 |             showOption.push(new Option(i, i));
 | 
 | 1495 |         }
 | 
 | 1496 |         return showOption;
 | 
 | 1497 |     }
 | 
 | 1498 | 
 | 
 | 1499 |     function wifiGuestVM() {
 | 
 | 1500 |         var target = this;
 | 
 | 1501 |         var info = service.getWifiBasic();
 | 
 | 1502 | 
 | 
 | 1503 |         target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
 | 
 | 1504 |         target.hasMultiSSID = config.HAS_MULTI_SSID;
 | 
 | 1505 |         target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;
 | 
 | 1506 |         target.hasAPStation = config.AP_STATION_SUPPORT;
 | 
 | 1507 |         target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
 | 
 | 1508 |         target.hasWifiWep = config.WIFI_WEP_SUPPORT;
 | 
 | 1509 |         target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
 | 
 | 1510 |         target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
 | 
 | 1511 | 
 | 
 | 1512 |         var advanceInfo = service.getWifiAdvance();
 | 
 | 1513 |         target.adBand = ko.observable(advanceInfo.wifiBand);
 | 
 | 1514 |         target.adMode = ko.observable(advanceInfo.mode);
 | 
 | 1515 | 
 | 
 | 1516 |         target.showQRSwitch = config.WIFI_SUPPORT_QR_CODE && config.WIFI_SUPPORT_QR_SWITCH;
 | 
 | 1517 |         target.showQR = ko.observable(info.m_show_qrcode_flag);
 | 
 | 1518 |         if (config.WIFI_SUPPORT_QR_SWITCH) {
 | 
 | 1519 |             target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE && target.showQR());
 | 
 | 1520 |         } else {
 | 
 | 1521 |             target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE);
 | 
 | 1522 |         }
 | 
 | 1523 |         if(config.WIFI_SUPPORT_QR_CODE){
 | 
 | 1524 |             target.qrcodeSrc = './pic/qrcode_multi_ssid_wifikey.png?_=' + $.now();
 | 
 | 1525 |         } else {
 | 
 | 1526 |             target.qrcodeSrc = './pic/res_blacktrans.png';
 | 
 | 1527 |         }
 | 
 | 1528 |         target.origin_ap_station_enable = info.ap_station_enable;
 | 
 | 1529 |         target.wifi_enable = ko.observable(info.wifi_enable);
 | 
 | 1530 |         target.isShowSSIDInfoDiv = ko.observable(false);
 | 
 | 1531 |         if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 1532 |             if (info.wifi_enable == "1") {
 | 
 | 1533 |                 target.isShowSSIDInfoDiv(true);
 | 
 | 1534 |             } else {
 | 
 | 1535 |                 target.isShowSSIDInfoDiv(false);
 | 
 | 1536 |             }
 | 
 | 1537 |         } else {
 | 
 | 1538 |             target.isShowSSIDInfoDiv(true);
 | 
 | 1539 |         }
 | 
 | 1540 | 
 | 
 | 1541 |         target.multi_ssid_enable = ko.observable(info.multi_ssid_enable);
 | 
 | 1542 |         target.origin_multi_ssid_enable = info.multi_ssid_enable;
 | 
 | 1543 | 
 | 
 | 1544 |         target.maxStationNumber = ko.computed(function () {
 | 
 | 1545 |             return config.MAX_STATION_NUMBER;
 | 
 | 1546 |         });
 | 
 | 1547 | 
 | 
 | 1548 |         target.modes = ko.observableArray(securityModes);
 | 
 | 1549 |         target.selectedMode = ko.observable(info.AuthMode);
 | 
 | 1550 |         target.passPhrase = ko.observable(info.passPhrase);
 | 
 | 1551 |         target.showPassword = ko.observable(false);
 | 
 | 1552 |         target.ssid = ko.observable(info.SSID);
 | 
 | 1553 |         target.broadcast = ko.observable(info.broadcast == '1' ? '1' : '0');
 | 
 | 1554 |         target.apIsolation = ko.observable(info.apIsolation == '1' ? '1' : '0');
 | 
 | 1555 |         target.cipher = info.cipher;
 | 
 | 1556 |         target.selectedStation = ko.observable(info.MAX_Access_num);
 | 
 | 1557 |         target.maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));
 | 
 | 1558 | 
 | 
 | 1559 |         target.m_modes = ko.observableArray(securityModes);
 | 
 | 1560 |         target.m_selectedMode = ko.observable(info.m_AuthMode);
 | 
 | 1561 |         target.m_passPhrase = ko.observable(info.m_passPhrase);
 | 
 | 1562 |         target.m_showPassword = ko.observable(false);
 | 
 | 1563 |         target.m_ssid = ko.observable(info.m_SSID);
 | 
 | 1564 |         target.m_broadcast = ko.observable(info.m_broadcast == '1' ? '1' : '0');
 | 
 | 1565 |         target.m_apIsolation = ko.observable(info.m_apIsolation == '1' ? '1' : '0');
 | 
 | 1566 |         target.m_cipher = info.m_cipher;
 | 
 | 1567 |         target.m_selectedStation = ko.observable(info.m_MAX_Access_num);
 | 
 | 1568 |         target.m_maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));
 | 
 | 1569 |         target.m_encryptType = ko.observable(info.m_encryptType);
 | 
 | 1570 |         target.m_keyID = ko.observable(info.m_keyID);
 | 
 | 1571 |         target.m_wepPassword = ko.observable("");
 | 
 | 1572 | 
 | 
 | 1573 |         //刷新界面状态值显示
 | 
 | 1574 |         target.clear = function (option) {
 | 
 | 1575 |             if (option == "switch") {
 | 
 | 1576 |                 target.multi_ssid_enable(info.multi_ssid_enable);
 | 
 | 1577 |                 target.wifi_enable(info.wifi_enable);
 | 
 | 1578 |             } else if (option == "ssid1") {
 | 
 | 1579 |                 target.selectedMode(info.AuthMode);
 | 
 | 1580 |                 target.passPhrase(info.passPhrase);
 | 
 | 1581 |                 target.ssid(info.SSID);
 | 
 | 1582 |                 target.broadcast(info.broadcast == '1' ? '1' : '0');
 | 
 | 1583 |                 target.cipher = info.cipher;
 | 
 | 1584 |                 target.selectedStation(info.MAX_Access_num);
 | 
 | 1585 |                 target.apIsolation(info.apIsolation == '1' ? '1' : '0');
 | 
 | 1586 |             } else if (option == "ssid2") {
 | 
 | 1587 |                 target.m_selectedMode(info.m_AuthMode);
 | 
 | 1588 |                 target.m_passPhrase(info.m_passPhrase);
 | 
 | 1589 |                 target.m_ssid(info.m_SSID);
 | 
 | 1590 |                 target.m_broadcast(info.m_broadcast == '1' ? '1' : '0');
 | 
 | 1591 |                 target.m_cipher = info.m_cipher;
 | 
 | 1592 |                 target.m_selectedStation(info.m_MAX_Access_num);
 | 
 | 1593 |                 target.m_apIsolation(info.m_apIsolation == '1' ? '1' : '0');
 | 
 | 1594 |                 if (config.WIFI_WEP_SUPPORT) {
 | 
 | 1595 |                     target.m_encryptType(info.m_encryptType);
 | 
 | 1596 |                     target.m_keyID(info.m_keyID);
 | 
 | 1597 |                     target.m_wepPassword(target.getWepPassword());
 | 
 | 1598 |                 }
 | 
 | 1599 |             } else {
 | 
 | 1600 |                 clearTimer();
 | 
 | 1601 |                 clearValidateMsg();
 | 
 | 1602 |                 initialize();
 | 
 | 1603 |                 service.refreshAPStationStatus();
 | 
 | 1604 |             }
 | 
 | 1605 |         };
 | 
 | 1606 | 
 | 
 | 1607 |         target.getWepPassword = function () {
 | 
 | 1608 |             return target.m_keyID() == '3' ? info.m_Key4Str1 : (target.m_keyID() == '2' ? info.m_Key3Str1 : target.m_keyID() == '1' ? info.m_Key2Str1 : info.m_Key1Str1);
 | 
 | 1609 |         }
 | 
 | 1610 |         target.m_wepPassword(target.getWepPassword());
 | 
 | 1611 |         //WEP加密模式下网络秘钥切换事件
 | 
 | 1612 |         target.profileChangeHandler = function (data, event) {
 | 
 | 1613 |             $("#pwdWepKey").parent().find("label[class='error']").hide();
 | 
 | 1614 |             target.m_wepPassword(target.getWepPassword());
 | 
 | 1615 |             return true;
 | 
 | 1616 |         };
 | 
 | 1617 | 
 | 
 | 1618 |         target.saveSSID1 = function () {
 | 
 | 1619 |             if (target.checkSettings("ssid1")) {
 | 
 | 1620 |                 return;
 | 
 | 1621 |             }
 | 
 | 1622 |             showConfirm('wifi_disconnect_confirm', function () {
 | 
 | 1623 |                 target.saveSSID1Action();
 | 
 | 1624 |             });
 | 
 | 1625 |         };
 | 
 | 1626 |         target.saveSSID1Action = function () {
 | 
 | 1627 |             showLoading('waiting');
 | 
 | 1628 |             target.broadcast($("#broadcastCheckbox:checked").length > 0 ? '0' : '1');
 | 
 | 1629 |             target.apIsolation($("#apisolatedCheckbox:checked").length);
 | 
 | 1630 |             var params = {};
 | 
 | 1631 |             params.AuthMode = target.selectedMode();
 | 
 | 1632 |             params.passPhrase = target.passPhrase();
 | 
 | 1633 |             params.SSID = target.ssid();
 | 
 | 1634 |             params.broadcast = target.broadcast();
 | 
 | 1635 |             params.station = target.selectedStation();
 | 
 | 1636 |             params.cipher = target.selectedMode() == "WPA2PSK" ? 1 : 2;
 | 
 | 1637 |             if (params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {
 | 
 | 1638 |                 params.cipher = 1;
 | 
 | 1639 |             }
 | 
 | 1640 |             params.NoForwarding = target.apIsolation();
 | 
 | 1641 |             params.show_qrcode_flag = target.showQR() == true ? 1 : 0;
 | 
 | 1642 |             service.setWifiBasic(params, function (result) {
 | 
 | 1643 |                 if (result.result == "success") {
 | 
 | 1644 |                     if (viaWifi) {
 | 
 | 1645 |                         setTimeout(guestReloadVarWifi, 15000);
 | 
 | 1646 |                     } else {
 | 
 | 1647 |                         addInterval(guestReload, 1000);
 | 
 | 1648 |                     }
 | 
 | 1649 |                 } else {
 | 
 | 1650 |                     errorOverlay();
 | 
 | 1651 |                 }
 | 
 | 1652 |             });
 | 
 | 1653 |         };
 | 
 | 1654 | 
 | 
 | 1655 |         target.saveSSID2 = function () {
 | 
 | 1656 |             if (target.checkSettings("ssid2")) {
 | 
 | 1657 |                 return;
 | 
 | 1658 |             }
 | 
 | 1659 |             if (!config.PASSWORD_ENCODE) {
 | 
 | 1660 |                 var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
 | 
 | 1661 |                 if (!pwdRegex.test(target.m_passPhrase())) {
 | 
 | 1662 |                         showConfirm("password_note_too_low", function () {
 | 
 | 1663 |                             showConfirm('wifi_disconnect_confirm', function () {
 | 
 | 1664 |                             target.saveSSID2Action();
 | 
 | 1665 |                             return;
 | 
 | 1666 |                         });
 | 
 | 1667 |                         return;
 | 
 | 1668 |                     });
 | 
 | 1669 |                     return;
 | 
 | 1670 |                 }
 | 
 | 1671 |             }
 | 
 | 1672 |             showConfirm('wifi_disconnect_confirm', function () {
 | 
 | 1673 |                 target.saveSSID2Action();
 | 
 | 1674 |             });
 | 
 | 1675 |         };
 | 
 | 1676 |         target.saveSSID2Action = function () {
 | 
 | 1677 |             showLoading('waiting');
 | 
 | 1678 |             target.m_broadcast($("#mBroadcastCheckbox:checked").length > 0 ? '0' : '1');
 | 
 | 1679 |             target.m_apIsolation($("#mApIsolatedCheckbox:checked").length);
 | 
 | 1680 |             var ciphertext = "";
 | 
 | 1681 |             if (config.PASSWORD_ENCODE) {
 | 
 | 1682 | 	        ciphertext = target.m_passPhrase();
 | 
 | 1683 | 	    } else {
 | 
 | 1684 |                 var kparam = service.getDeviceInfoLow();
 | 
 | 1685 |                 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
 | 
 | 1686 | 		var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
 | 
 | 1687 |                 ciphertext = CryptoJS.AES.encrypt(target.m_passPhrase(), tkey, {
 | 
 | 1688 |                     iv: tiv,
 | 
 | 1689 |                     mode: CryptoJS.mode.CBC,
 | 
 | 1690 |                     padding: CryptoJS.pad.ZeroPadding
 | 
 | 1691 |                     }).toString();
 | 
 | 1692 | 	    }
 | 
 | 1693 |             var params = {};
 | 
 | 1694 |             params.m_AuthMode = target.m_selectedMode();
 | 
 | 1695 |             params.m_passPhrase = ciphertext;
 | 
 | 1696 |             params.m_SSID = target.m_ssid();
 | 
 | 1697 |             params.m_broadcast = target.m_broadcast();
 | 
 | 1698 |             params.m_station = target.m_selectedStation();
 | 
 | 1699 |             params.m_cipher = target.m_selectedMode() == "WPA2PSK" ? 1 : 2;
 | 
 | 1700 |             if (params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {
 | 
 | 1701 |                 params.m_cipher = 1;
 | 
 | 1702 |             }
 | 
 | 1703 |             params.m_NoForwarding = target.m_apIsolation();
 | 
 | 1704 |             params.m_show_qrcode_flag = target.showQR() == true ? 1 : 0;
 | 
 | 1705 | 
 | 
 | 1706 |             if (config.WIFI_WEP_SUPPORT) {
 | 
 | 1707 |                 if (params.m_AuthMode == "SHARED") {
 | 
 | 1708 |                     params.m_encryptType = "WEP";
 | 
 | 1709 |                 } else if (params.m_AuthMode == "WPAPSKWPA2PSK" || params.m_AuthMode == "WPA2PSK" || params.m_AuthMode == "WPAPSK" || params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {
 | 
 | 1710 |                     //params.m_encryptType = target.m_encryptType_WPA();
 | 
 | 1711 |                 } else {
 | 
 | 1712 |                     params.m_encryptType = target.m_encryptType();
 | 
 | 1713 |                 }
 | 
 | 1714 |                 params.m_wep_default_key = target.m_keyID();
 | 
 | 1715 |                 params.m_wep_key_4 = info.m_Key4Str1;
 | 
 | 1716 |                 params.m_wep_key_3 = info.m_Key3Str1;
 | 
 | 1717 |                 params.m_wep_key_2 = info.m_Key2Str1;
 | 
 | 1718 |                 params.m_wep_key_1 = info.m_Key1Str1;
 | 
 | 1719 |                 var mWEPSelect = '0';
 | 
 | 1720 |                 if (target.m_wepPassword().length == '13' || target.m_wepPassword().length == '5') {
 | 
 | 1721 |                     mWEPSelect = '1';
 | 
 | 1722 |                 } else {
 | 
 | 1723 |                     mWEPSelect = '0';
 | 
 | 1724 |                 }
 | 
 | 1725 |                 if (target.m_keyID() == '3') {
 | 
 | 1726 |                     params.m_wep_key_4 = target.m_wepPassword();
 | 
 | 1727 |                     params.m_WEP4Select = mWEPSelect;
 | 
 | 1728 |                 } else if (target.m_keyID() == '2') {
 | 
 | 1729 |                     params.m_wep_key_3 = target.m_wepPassword();
 | 
 | 1730 |                     params.m_WEP3Select = mWEPSelect;
 | 
 | 1731 |                 } else if (target.m_keyID() == '1') {
 | 
 | 1732 |                     params.m_wep_key_2 = target.m_wepPassword();
 | 
 | 1733 |                     params.m_WEP2Select = mWEPSelect;
 | 
 | 1734 |                 } else {
 | 
 | 1735 |                     params.m_wep_key_1 = target.m_wepPassword();
 | 
 | 1736 |                     params.m_WEP1Select = mWEPSelect;
 | 
 | 1737 |                 }
 | 
 | 1738 |             }
 | 
 | 1739 | 
 | 
 | 1740 |             service.setWifiBasic4SSID2(params, function (result) {
 | 
 | 1741 |                 if (result.result == "success") {
 | 
 | 1742 |                     if (viaWifi) {
 | 
 | 1743 |                         setTimeout(ssid2ReloadVarWifi, 15000);
 | 
 | 1744 |                     } else {
 | 
 | 1745 |                         addInterval(ssid2Reload, 1000);
 | 
 | 1746 |                     }
 | 
 | 1747 |                 } else {
 | 
 | 1748 |                     errorOverlay();
 | 
 | 1749 |                 }
 | 
 | 1750 |             });
 | 
 | 1751 |         };
 | 
 | 1752 | 
 | 
 | 1753 |         function guestReloadVarWifi() {
 | 
 | 1754 |             successOverlay();
 | 
 | 1755 |             setTimeout(function () {
 | 
 | 1756 |                 window.location.reload();
 | 
 | 1757 |             }, 1000);
 | 
 | 1758 |             target.clear();
 | 
 | 1759 |         }
 | 
 | 1760 |         function guestReload() {
 | 
 | 1761 |             var info = getWifiMain();
 | 
 | 1762 |             if (info.wifi_enable == "1") {
 | 
 | 1763 |                 successOverlay();
 | 
 | 1764 |                 target.clear();
 | 
 | 1765 |             }
 | 
 | 1766 |         }
 | 
 | 1767 |         function ssid2ReloadVarWifi() {
 | 
 | 1768 |             successOverlay();
 | 
 | 1769 |             setTimeout(function () {
 | 
 | 1770 |                 window.location.reload();
 | 
 | 1771 |             }, 1000);
 | 
 | 1772 |             target.clear();
 | 
 | 1773 |         }
 | 
 | 1774 |         function ssid2Reload() {
 | 
 | 1775 |             var info = getWifiMain();
 | 
 | 1776 |             if (info.wifi_enable == "1") {
 | 
 | 1777 |                 successOverlay();
 | 
 | 1778 |                 target.clear();
 | 
 | 1779 |             }
 | 
 | 1780 |         }
 | 
 | 1781 | 
 | 
 | 1782 |         target.checkSettings = function (ssid) {
 | 
 | 1783 |             var status = getWpsState();
 | 
 | 1784 | 
 | 
 | 1785 |             if (config.HAS_MULTI_SSID) {
 | 
 | 1786 |                 if (ssid == "ssid1" || ssid == "ssid2") {
 | 
 | 1787 |                     if (ssid == "ssid2") {
 | 
 | 1788 |                         var accessDevice = service.getStatusInfo().ssid2AttachedNum;
 | 
 | 1789 |                         if (parseInt(target.m_selectedStation()) < accessDevice) {
 | 
 | 1790 |                             showAlert('Extend_accessDevice');
 | 
 | 1791 |                             return true;
 | 
 | 1792 |                         }
 | 
 | 1793 |                     } else {
 | 
 | 1794 |                         var accessDevice = service.getStatusInfo().ssid1AttachedNum;
 | 
 | 1795 |                         if (parseInt(target.selectedStation()) < accessDevice) {
 | 
 | 1796 |                             showAlert('Extend_accessDevice');
 | 
 | 1797 |                             return true;
 | 
 | 1798 |                         }
 | 
 | 1799 |                     }
 | 
 | 1800 |                 }
 | 
 | 1801 |             }
 | 
 | 1802 | 
 | 
 | 1803 |             if (status.wpsFlag == '1') {
 | 
 | 1804 |                 showAlert('wps_on_info');
 | 
 | 1805 |                 return true;
 | 
 | 1806 |             }
 | 
 | 1807 |             if (config.HAS_MULTI_SSID && info.multi_ssid_enable == "1") {
 | 
 | 1808 |                 if ((ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)
 | 
 | 1809 |                      || (ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)) {
 | 
 | 1810 |                     showAlert({
 | 
 | 1811 |                         msg: 'multi_ssid_max_access_number_alert',
 | 
 | 1812 |                         params: info.MAX_Station_num
 | 
 | 1813 |                     });
 | 
 | 1814 |                     return true;
 | 
 | 1815 |                 }
 | 
 | 1816 |             }
 | 
 | 1817 | 
 | 
 | 1818 |             return false;
 | 
 | 1819 |         };
 | 
 | 1820 | 
 | 
 | 1821 |         target.setMultiSSIDSwitch = function () {
 | 
 | 1822 |             if (target.checkSettings("switch")) {
 | 
 | 1823 |                 return;
 | 
 | 1824 |             }
 | 
 | 1825 | 
 | 
 | 1826 |             var setSwitch = function () {
 | 
 | 1827 |                 showLoading('waiting');
 | 
 | 1828 |                 var params = {};
 | 
 | 1829 |                 params.m_ssid_enable = target.multi_ssid_enable();
 | 
 | 1830 |                 if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 1831 |                     params.wifiEnabled = target.wifi_enable();
 | 
 | 1832 |                 }
 | 
 | 1833 |                 service.setWifiBasicMultiSSIDSwitch(params, function (result) {
 | 
 | 1834 |                     if (result.result == "success") {
 | 
 | 1835 |                         if (viaWifi) {
 | 
 | 1836 |                             setTimeout(multiReloadViaWifi, 15000);
 | 
 | 1837 |                         } else {
 | 
 | 1838 |                             addInterval(multiReload, 1000);
 | 
 | 1839 |                         }
 | 
 | 1840 |                     } else {
 | 
 | 1841 |                         errorOverlay();
 | 
 | 1842 |                     }
 | 
 | 1843 |                 });
 | 
 | 1844 |             };
 | 
 | 1845 |             function multiReloadViaWifi() {
 | 
 | 1846 |                 successOverlay();
 | 
 | 1847 |                 setTimeout(function () {
 | 
 | 1848 |                     window.location.reload();
 | 
 | 1849 |                 }, 1000);
 | 
 | 1850 |                 target.clear();
 | 
 | 1851 |             }
 | 
 | 1852 |             function multiReload() {
 | 
 | 1853 |                 var info = getWifiMain();
 | 
 | 1854 |                 if (info.wifi_enable == target.wifi_enable()) {
 | 
 | 1855 |                     successOverlay();
 | 
 | 1856 |                     target.clear();
 | 
 | 1857 |                 }
 | 
 | 1858 |             }
 | 
 | 1859 |             var info = service.getStatusInfo();
 | 
 | 1860 |             if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
 | 
 | 1861 |                 if (config.AP_STATION_SUPPORT && target.multi_ssid_enable() == "1" && target.origin_ap_station_enable == "1") {
 | 
 | 1862 |                     if (!info.wifiStatus) {
 | 
 | 1863 |                         showConfirm("multi_ssid_enable_confirm", function () {
 | 
 | 1864 |                             setSwitch();
 | 
 | 1865 |                         });
 | 
 | 1866 |                     } else {
 | 
 | 1867 |                         showConfirm("multi_ssid_enable_confirm2", function () {
 | 
 | 1868 |                             setSwitch();
 | 
 | 1869 |                         });
 | 
 | 1870 |                     }
 | 
 | 1871 |                 } else {
 | 
 | 1872 |                     if (!info.wifiStatus) {
 | 
 | 1873 |                         setSwitch();
 | 
 | 1874 |                     } else {
 | 
 | 1875 |                         showConfirm("wifi_disconnect_confirm2", function () {
 | 
 | 1876 |                             setSwitch();
 | 
 | 1877 |                         });
 | 
 | 1878 |                     }
 | 
 | 1879 |                 }
 | 
 | 1880 |             } else {
 | 
 | 1881 |                 setSwitch();
 | 
 | 1882 |             }
 | 
 | 1883 |         };
 | 
 | 1884 |         target.showQRHandler = function () {
 | 
 | 1885 |             var checkbox = $("#showQR:checked");
 | 
 | 1886 |             if (checkbox && checkbox.length == 0) {
 | 
 | 1887 |                 target.showQR(true);
 | 
 | 1888 |             } else {
 | 
 | 1889 |                 target.showQR(false);
 | 
 | 1890 |             }
 | 
 | 1891 |             target.showQRCode(config.WIFI_SUPPORT_QR_CODE && target.showQR());
 | 
 | 1892 |         };
 | 
 | 1893 | 
 | 
 | 1894 |         target.showPasswordHandler = guestShowPassword;
 | 
 | 1895 | 
 | 
 | 1896 |         target.m_showPasswordHandler = m_guestShowPassword;
 | 
 | 1897 | 
 | 
 | 1898 |         function guestShowPassword() {
 | 
 | 1899 |             $("#passShow").parent().find(".error").hide();
 | 
 | 1900 |             var checkbox = $("#showPassword:checked");
 | 
 | 1901 |             if (checkbox && checkbox.length == 0) {
 | 
 | 1902 |                 target.showPassword(true);
 | 
 | 1903 |             } else {
 | 
 | 1904 |                 target.showPassword(false);
 | 
 | 1905 |             }
 | 
 | 1906 |         }
 | 
 | 1907 |         function m_guestShowPassword() {
 | 
 | 1908 |             $("#m_passShow").parent().find(".error").hide();
 | 
 | 1909 |             $("#m_pwdWepKey").parent().find(".error").hide();
 | 
 | 1910 |             var checkbox = $("#m_showPassword:checked");
 | 
 | 1911 |             if (checkbox && checkbox.length == 0) {
 | 
 | 1912 |                 target.m_showPassword(true);
 | 
 | 1913 |             } else {
 | 
 | 1914 |                 target.m_showPassword(false);
 | 
 | 1915 |             }
 | 
 | 1916 |         }
 | 
 | 1917 | 
 | 
 | 1918 |     }
 | 
 | 1919 | 
 | 
 | 1920 |     function getWifiMain() {
 | 
 | 1921 |         return service.getWifiBasic();
 | 
 | 1922 |     }
 | 
 | 1923 | 
 | 
 | 1924 |     function initialize() {
 | 
 | 1925 |         var container = $('#container');
 | 
 | 1926 |         ko.cleanNode(container[0]);
 | 
 | 1927 |         var vm = new wifiGuestVM();
 | 
 | 1928 |         ko.applyBindings(vm, container[0]);
 | 
 | 1929 |         addTimeout(function () {
 | 
 | 1930 |             checkAccessMode();
 | 
 | 1931 |         }, 600);
 | 
 | 1932 | 
 | 
 | 1933 |         function checkWifiStatus() {
 | 
 | 1934 |             var info = service.getAPStationBasic();
 | 
 | 1935 |             if (info.ap_station_enable != "1") {
 | 
 | 1936 |                 $('#frmMultiSSID :input').each(function () {
 | 
 | 1937 |                     $(this).attr("disabled", false);
 | 
 | 1938 |                 });
 | 
 | 1939 |             } else {
 | 
 | 1940 |                 $('#frmMultiSSID :input').each(function () {
 | 
 | 1941 |                     $(this).attr("disabled", true);
 | 
 | 1942 |                 });
 | 
 | 1943 |             }
 | 
 | 1944 |         }
 | 
 | 1945 | 
 | 
 | 1946 |         function checkWifiStatusAccordingToWDS() {
 | 
 | 1947 |             var info = service.getWdsInfo();
 | 
 | 1948 |             if (info.currentMode == "0") {
 | 
 | 1949 |                 $('#frmWifiSwitch :input').each(function () {
 | 
 | 1950 |                     $(this).attr("disabled", false);
 | 
 | 1951 |                 });
 | 
 | 1952 |                 $('#frmSSID2 :input').each(function () {
 | 
 | 1953 |                     $(this).attr("disabled", false);
 | 
 | 1954 |                 });
 | 
 | 1955 |                 $('#frmSSID1 :input').each(function () {
 | 
 | 1956 |                     $(this).attr("disabled", false);
 | 
 | 1957 |                 });
 | 
 | 1958 |             } else {
 | 
 | 1959 |                 $('#frmWifiSwitch :input').each(function () {
 | 
 | 1960 |                     $(this).attr("disabled", true);
 | 
 | 1961 |                 });
 | 
 | 1962 |                 $('#frmSSID2 :input').each(function () {
 | 
 | 1963 |                     $(this).attr("disabled", true);
 | 
 | 1964 |                 });
 | 
 | 1965 |                 $('#frmSSID1 :input').each(function () {
 | 
 | 1966 |                     $(this).attr("disabled", true);
 | 
 | 1967 |                 });
 | 
 | 1968 |             }
 | 
 | 1969 |         }
 | 
 | 1970 | 
 | 
 | 1971 |         if (config.WDS_SUPPORT) {
 | 
 | 1972 |             checkWifiStatusAccordingToWDS();
 | 
 | 1973 |         } else if (config.AP_STATION_SUPPORT) {
 | 
 | 1974 |             checkWifiStatus();
 | 
 | 1975 |         }
 | 
 | 1976 | 
 | 
 | 1977 |         $('#frmMultiSSID').validate({
 | 
 | 1978 |             submitHandler: function () {
 | 
 | 1979 |                 vm.setMultiSSIDSwitch();
 | 
 | 1980 |             }
 | 
 | 1981 |         });
 | 
 | 1982 |         $('#frmWifiSwitch').validate({
 | 
 | 1983 |             submitHandler: function () {
 | 
 | 1984 |                 vm.setMultiSSIDSwitch();
 | 
 | 1985 |             }
 | 
 | 1986 |         });
 | 
 | 1987 |         $('#frmSSID2').validate({
 | 
 | 1988 |             submitHandler: function () {
 | 
 | 1989 |                 vm.saveSSID2();
 | 
 | 1990 |             },
 | 
 | 1991 |             rules: {
 | 
 | 1992 |                 m_ssid: 'ssid',
 | 
 | 1993 |                 m_pwdWepKey: {
 | 
 | 1994 |                     wifi_wep_password_check: true,
 | 
 | 1995 |                     wifi_password_check: true
 | 
 | 1996 |                 },
 | 
 | 1997 |                 m_txtWepKey: {
 | 
 | 1998 |                     wifi_wep_password_check: true,
 | 
 | 1999 |                     wifi_password_check: true
 | 
 | 2000 |                 },
 | 
 | 2001 |                 m_pass: 'wifi_password_check',
 | 
 | 2002 |                 m_passShow: 'wifi_password_check'
 | 
 | 2003 |             },
 | 
 | 2004 |             errorPlacement: function (error, element) {
 | 
 | 2005 |                 var id = element.attr("id");
 | 
 | 2006 |                 if (id == "m_passShow" || id == "m_pass") {
 | 
 | 2007 |                     error.insertAfter("#m_lblShowPassword");
 | 
 | 2008 |                 } else if (id == "m_txtWepKey" || id == "m_pwdWepKey") {
 | 
 | 2009 |                     error.insertAfter("#m_lblShowWepPassword");
 | 
 | 2010 |                 } else {
 | 
 | 2011 |                     error.insertAfter(element);
 | 
 | 2012 |                 }
 | 
 | 2013 |             }
 | 
 | 2014 |         });
 | 
 | 2015 |         $('#frmSSID1').validate({
 | 
 | 2016 |             submitHandler: function () {
 | 
 | 2017 |                 vm.saveSSID1();
 | 
 | 2018 |             },
 | 
 | 2019 |             rules: {
 | 
 | 2020 |                 pass: 'wifi_password_check',
 | 
 | 2021 |                 ssid: 'ssid',
 | 
 | 2022 |                 passShow: 'wifi_password_check'
 | 
 | 2023 |             },
 | 
 | 2024 |             errorPlacement: function (error, element) {
 | 
 | 2025 |                 var id = element.attr("id");
 | 
 | 2026 |                 if (id == "passShow" || id == "pass") {
 | 
 | 2027 |                     error.insertAfter("#lblShowPassword");
 | 
 | 2028 |                 } else {
 | 
 | 2029 |                     error.insertAfter(element);
 | 
 | 2030 |                 }
 | 
 | 2031 |             }
 | 
 | 2032 |         });
 | 
 | 2033 | 
 | 
 | 2034 |     }
 | 
 | 2035 | 
 | 
 | 2036 |     function getWpsState() {
 | 
 | 2037 |         return service.getWpsInfo();
 | 
 | 2038 |     }
 | 
 | 2039 | 
 | 
 | 2040 |     return {
 | 
 | 2041 |         init: initialize
 | 
 | 2042 |     };
 | 
 | 2043 | });
 | 
 | 2044 | 
 | 
 | 2045 | define("wifi_mac_filter","underscore jquery knockout set service".split(" "),
 | 
 | 2046 |     function (_, $, ko, config, service) {
 | 
 | 2047 | 
 | 
 | 2048 |     var viaWifi = false;
 | 
 | 2049 |     function checkAccessMode() {
 | 
 | 2050 |         service.getParams({
 | 
 | 2051 |             nv: 'user_ip_addr'
 | 
 | 2052 |         }, function (dataIp) {
 | 
 | 2053 |             service.getParams({
 | 
 | 2054 |                 nv: 'station_list'
 | 
 | 2055 |             }, function (dataList) {
 | 
 | 2056 |                 viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
 | 
 | 2057 |             });
 | 
 | 2058 |         });
 | 
 | 2059 |     }
 | 
 | 2060 | 
 | 
 | 2061 |     function macFilterViewModel() {
 | 
 | 2062 |         var target = this;
 | 
 | 2063 |         target.hasAPStation = config.AP_STATION_SUPPORT;
 | 
 | 2064 |         target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
 | 
 | 2065 |         target.hasMultiSSID = config.HAS_MULTI_SSID;
 | 
 | 2066 |         target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;
 | 
 | 2067 | 
 | 
 | 2068 |         var info = service.getMacFilterInfo();
 | 
 | 2069 |         var wifiBaseInfo = service.getWifiBasic();
 | 
 | 2070 |         target.multi_ssid_enable = ko.observable(wifiBaseInfo.multi_ssid_enable);
 | 
 | 2071 |         target.origin_ap_station_enable = wifiBaseInfo.ap_station_enable;
 | 
 | 2072 |         target.wifi_enable = ko.observable(wifiBaseInfo.wifi_enable);
 | 
 | 2073 | 
 | 
 | 2074 |         target.isShowSSIDInfoDiv = ko.observable(false);
 | 
 | 2075 |         if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 2076 |             if (wifiBaseInfo.wifi_enable == "1") {
 | 
 | 2077 |                 target.isShowSSIDInfoDiv(true);
 | 
 | 2078 |             } else {
 | 
 | 2079 |                 target.isShowSSIDInfoDiv(false);
 | 
 | 2080 |             }
 | 
 | 2081 |         } else {
 | 
 | 2082 |             target.isShowSSIDInfoDiv(true);
 | 
 | 2083 |         }
 | 
 | 2084 | 
 | 
 | 2085 |         target.selectedAction = ko.observable(info.ACL_mode);
 | 
 | 2086 |         target.mac1 = ko.observable("");
 | 
 | 2087 |         target.mac2 = ko.observable("");
 | 
 | 2088 |         target.mac3 = ko.observable("");
 | 
 | 2089 |         target.mac4 = ko.observable("");
 | 
 | 2090 |         target.mac5 = ko.observable("");
 | 
 | 2091 |         target.mac6 = ko.observable("");
 | 
 | 2092 |         target.mac7 = ko.observable("");
 | 
 | 2093 |         target.mac8 = ko.observable("");
 | 
 | 2094 |         target.mac9 = ko.observable("");
 | 
 | 2095 |         target.mac10 = ko.observable("");
 | 
 | 2096 |         if (info.ACL_mode == "1") {
 | 
 | 2097 |             macInfoWhite = info.wifi_mac_white_list.split(";");
 | 
 | 2098 |             target.mac1 = ko.observable(macInfoWhite[0]);
 | 
 | 2099 |             target.mac2 = ko.observable(macInfoWhite[1]);
 | 
 | 2100 |             target.mac3 = ko.observable(macInfoWhite[2]);
 | 
 | 2101 |             target.mac4 = ko.observable(macInfoWhite[3]);
 | 
 | 2102 |             target.mac5 = ko.observable(macInfoWhite[4]);
 | 
 | 2103 |             target.mac6 = ko.observable(macInfoWhite[5]);
 | 
 | 2104 |             target.mac7 = ko.observable(macInfoWhite[6]);
 | 
 | 2105 |             target.mac8 = ko.observable(macInfoWhite[7]);
 | 
 | 2106 |             target.mac9 = ko.observable(macInfoWhite[8]);
 | 
 | 2107 |             target.mac10 = ko.observable(macInfoWhite[9]);
 | 
 | 2108 |         } else if (info.ACL_mode == "2") {
 | 
 | 2109 |             macInfoBlack = info.wifi_mac_black_list.split(";");
 | 
 | 2110 |             target.mac1 = ko.observable(macInfoBlack[0]);
 | 
 | 2111 |             target.mac2 = ko.observable(macInfoBlack[1]);
 | 
 | 2112 |             target.mac3 = ko.observable(macInfoBlack[2]);
 | 
 | 2113 |             target.mac4 = ko.observable(macInfoBlack[3]);
 | 
 | 2114 |             target.mac5 = ko.observable(macInfoBlack[4]);
 | 
 | 2115 |             target.mac6 = ko.observable(macInfoBlack[5]);
 | 
 | 2116 |             target.mac7 = ko.observable(macInfoBlack[6]);
 | 
 | 2117 |             target.mac8 = ko.observable(macInfoBlack[7]);
 | 
 | 2118 |             target.mac9 = ko.observable(macInfoBlack[8]);
 | 
 | 2119 |             target.mac10 = ko.observable(macInfoBlack[9]);
 | 
 | 2120 |         }
 | 
 | 2121 | 
 | 
 | 2122 |         target.save = filter_save;
 | 
 | 2123 |         //切换MAC过滤规则事件
 | 
 | 2124 |         target.ChangeHandler = function () {
 | 
 | 2125 |             $("#mac_filter_form").find(".error").hide();
 | 
 | 2126 |             $("#mac_filter_form").find("input[type=text]").show();
 | 
 | 2127 |             var info = service.getMacFilterInfo();
 | 
 | 2128 |             if (target.selectedAction() == "1") {
 | 
 | 2129 |                 macInfoWhite = info.wifi_mac_white_list.split(";");
 | 
 | 2130 |                 target.mac1(macInfoWhite[0]);
 | 
 | 2131 |                 target.mac2(macInfoWhite[1]);
 | 
 | 2132 |                 target.mac3(macInfoWhite[2]);
 | 
 | 2133 |                 target.mac4(macInfoWhite[3]);
 | 
 | 2134 |                 target.mac5(macInfoWhite[4]);
 | 
 | 2135 |                 target.mac6(macInfoWhite[5]);
 | 
 | 2136 |                 target.mac7(macInfoWhite[6]);
 | 
 | 2137 |                 target.mac8(macInfoWhite[7]);
 | 
 | 2138 |                 target.mac9(macInfoWhite[8]);
 | 
 | 2139 |                 target.mac10(macInfoWhite[9]);
 | 
 | 2140 |             } else if (target.selectedAction() == "2") {
 | 
 | 2141 |                 macInfoBlack = info.wifi_mac_black_list.split(";");
 | 
 | 2142 |                 target.mac1(macInfoBlack[0]);
 | 
 | 2143 |                 target.mac2(macInfoBlack[1]);
 | 
 | 2144 |                 target.mac3(macInfoBlack[2]);
 | 
 | 2145 |                 target.mac4(macInfoBlack[3]);
 | 
 | 2146 |                 target.mac5(macInfoBlack[4]);
 | 
 | 2147 |                 target.mac6(macInfoBlack[5]);
 | 
 | 2148 |                 target.mac7(macInfoBlack[6]);
 | 
 | 2149 |                 target.mac8(macInfoBlack[7]);
 | 
 | 2150 |                 target.mac9(macInfoBlack[8]);
 | 
 | 2151 |                 target.mac10(macInfoBlack[9]);
 | 
 | 2152 |             } else {
 | 
 | 2153 |                 target.mac1("");
 | 
 | 2154 |                 target.mac2("");
 | 
 | 2155 |                 target.mac3("");
 | 
 | 2156 |                 target.mac4("");
 | 
 | 2157 |                 target.mac5("");
 | 
 | 2158 |                 target.mac6("");
 | 
 | 2159 |                 target.mac7("");
 | 
 | 2160 |                 target.mac8("");
 | 
 | 2161 |                 target.mac9("");
 | 
 | 2162 |                 target.mac10("");
 | 
 | 2163 |             }
 | 
 | 2164 |         }
 | 
 | 2165 |         //检查WPS状态
 | 
 | 2166 |         target.checkSettings = function (ssid) {
 | 
 | 2167 |             var wifi_status = service.getWpsInfo();
 | 
 | 2168 |             if (wifi_status.wpsFlag == '1') {
 | 
 | 2169 |                 showAlert('wps_on_info');
 | 
 | 2170 |                 return true;
 | 
 | 2171 |             }
 | 
 | 2172 |             return false;
 | 
 | 2173 |         };
 | 
 | 2174 | 
 | 
 | 2175 |         //设置多SSID开关
 | 
 | 2176 |         target.setMultiSSIDSwitch = function () {
 | 
 | 2177 |             if (target.checkSettings("switch")) {
 | 
 | 2178 |                 return;
 | 
 | 2179 |             }
 | 
 | 2180 | 
 | 
 | 2181 |             var setSwitch = setFilterSwitch;
 | 
 | 2182 | 
 | 
 | 2183 |             var info = service.getStatusInfo();
 | 
 | 2184 |             if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
 | 
 | 2185 |                 if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
 | 
 | 2186 |                     if (!info.wifiStatus) {
 | 
 | 2187 |                         showConfirm("multi_ssid_enable_confirm", function () {
 | 
 | 2188 |                             setSwitch();
 | 
 | 2189 |                         });
 | 
 | 2190 |                     } else {
 | 
 | 2191 |                         showConfirm("multi_ssid_enable_confirm2", function () {
 | 
 | 2192 |                             setSwitch();
 | 
 | 2193 |                         });
 | 
 | 2194 |                     }
 | 
 | 2195 |                 } else {
 | 
 | 2196 |                     if (!info.wifiStatus) {
 | 
 | 2197 |                         setSwitch();
 | 
 | 2198 |                     } else {
 | 
 | 2199 |                         showConfirm("wifi_disconnect_confirm2", function () {
 | 
 | 2200 |                             setSwitch();
 | 
 | 2201 |                         });
 | 
 | 2202 |                     }
 | 
 | 2203 |                 }
 | 
 | 2204 |             } else {
 | 
 | 2205 |                 setSwitch();
 | 
 | 2206 |             }
 | 
 | 2207 | 			
 | 
 | 2208 | 			function setFilterSwitch() {
 | 
 | 2209 |                 showLoading('waiting');
 | 
 | 2210 |                 var filter_param = {};
 | 
 | 2211 |                 filter_param.m_ssid_enable = target.multi_ssid_enable();
 | 
 | 2212 |                 if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 2213 |                     filter_param.wifiEnabled = target.wifi_enable();
 | 
 | 2214 |                 }
 | 
 | 2215 |                 service.setWifiBasicMultiSSIDSwitch(filter_param, function (result) {
 | 
 | 2216 |                     if (result.result == "success") {
 | 
 | 2217 |                         if (!viaWifi) {
 | 
 | 2218 |                             addInterval(function () {
 | 
 | 2219 |                                 var info = service.getWifiBasic();
 | 
 | 2220 |                                 service.refreshAPStationStatus();
 | 
 | 2221 |                                 if (info.wifi_enable == target.wifi_enable()) {
 | 
 | 2222 |                                     successOverlay();
 | 
 | 2223 |                                     clearTimer();
 | 
 | 2224 |                                     clearValidateMsg();
 | 
 | 2225 |                                     service.refreshAPStationStatus();
 | 
 | 2226 |                                     initialize();
 | 
 | 2227 |                                 }
 | 
 | 2228 |                             }, 1000);
 | 
 | 2229 |                         } else {
 | 
 | 2230 |                             setTimeout(function () {
 | 
 | 2231 |                                 successOverlay();
 | 
 | 2232 |                                 setTimeout(function () {
 | 
 | 2233 |                                     window.location.reload();
 | 
 | 2234 |                                 }, 1000);
 | 
 | 2235 |                                 clearTimer();
 | 
 | 2236 |                                 clearValidateMsg();
 | 
 | 2237 |                                 service.refreshAPStationStatus();
 | 
 | 2238 |                                 initialize();
 | 
 | 2239 |                             }, 15000);
 | 
 | 2240 |                         }
 | 
 | 2241 |                     } else {
 | 
 | 2242 |                         errorOverlay();
 | 
 | 2243 |                     }
 | 
 | 2244 |                 });
 | 
 | 2245 |             }
 | 
 | 2246 |         };
 | 
 | 2247 | 
 | 
 | 2248 | 		function filter_save() {
 | 
 | 2249 |             var wifi_status = service.getWpsInfo();
 | 
 | 2250 |             if (wifi_status.wpsFlag == '1') {
 | 
 | 2251 |                 showAlert('wps_on_info');
 | 
 | 2252 |                 return true;
 | 
 | 2253 |             }
 | 
 | 2254 | 
 | 
 | 2255 |             if (target.mac1() == undefined || target.mac1().indexOf(" ") >= 0) {
 | 
 | 2256 |                 target.mac1("")
 | 
 | 2257 |             }
 | 
 | 2258 |             if (target.mac2() == undefined || target.mac2().indexOf(" ") >= 0) {
 | 
 | 2259 |                 target.mac2("")
 | 
 | 2260 |             }
 | 
 | 2261 |             if (target.mac3() == undefined || target.mac3().indexOf(" ") >= 0) {
 | 
 | 2262 |                 target.mac3("")
 | 
 | 2263 |             }
 | 
 | 2264 |             if (target.mac4() == undefined || target.mac4().indexOf(" ") >= 0) {
 | 
 | 2265 |                 target.mac4("")
 | 
 | 2266 |             }
 | 
 | 2267 |             if (target.mac5() == undefined || target.mac5().indexOf(" ") >= 0) {
 | 
 | 2268 |                 target.mac5("")
 | 
 | 2269 |             }
 | 
 | 2270 |             if (target.mac6() == undefined || target.mac6().indexOf(" ") >= 0) {
 | 
 | 2271 |                 target.mac6("")
 | 
 | 2272 |             }
 | 
 | 2273 |             if (target.mac7() == undefined || target.mac7().indexOf(" ") >= 0) {
 | 
 | 2274 |                 target.mac7("")
 | 
 | 2275 |             }
 | 
 | 2276 |             if (target.mac8() == undefined || target.mac8().indexOf(" ") >= 0) {
 | 
 | 2277 |                 target.mac8("")
 | 
 | 2278 |             }
 | 
 | 2279 |             if (target.mac9() == undefined || target.mac9().indexOf(" ") >= 0) {
 | 
 | 2280 |                 target.mac9("")
 | 
 | 2281 |             }
 | 
 | 2282 |             if (target.mac10() == undefined || target.mac10().indexOf(" ") >= 0) {
 | 
 | 2283 |                 target.mac10("")
 | 
 | 2284 |             }
 | 
 | 2285 | 
 | 
 | 2286 |             var mac_list = new Array(target.mac1(), target.mac2(), target.mac3(), target.mac4(), target.mac5(),
 | 
 | 2287 |                     target.mac6(), target.mac7(), target.mac8(), target.mac9(), target.mac10());
 | 
 | 2288 |             if (target.selectedAction() == "2" && info.client_mac_address != "" && $.inArray(info.client_mac_address, mac_list) != -1) {
 | 
 | 2289 |                 showAlert('black_yourself_tip');
 | 
 | 2290 |                 return false;
 | 
 | 2291 |             }
 | 
 | 2292 |             var list_sort = mac_list.sort(); //排序
 | 
 | 2293 |             for (var i = 0; i < list_sort.length - 1; i++) {
 | 
 | 2294 |                 if (list_sort[i] != "" && list_sort[i] == list_sort[i + 1]) {
 | 
 | 2295 |                     showAlert('mac_repeat_tip');
 | 
 | 2296 |                     return false;
 | 
 | 2297 |                 }
 | 
 | 2298 |             }
 | 
 | 2299 |             var string_maclist = "";
 | 
 | 2300 |             for (var i = 0; i < 10; i++) {
 | 
 | 2301 |                 if (string_maclist == "") {
 | 
 | 2302 |                     string_maclist = mac_list[i];
 | 
 | 2303 |                 } else {
 | 
 | 2304 |                     if (mac_list[i]) {
 | 
 | 2305 |                         string_maclist = string_maclist + ";" + mac_list[i];
 | 
 | 2306 |                     }
 | 
 | 2307 |                 }
 | 
 | 2308 |             }
 | 
 | 2309 |             var filter_param = {};
 | 
 | 2310 |             filter_param.ACL_mode = target.selectedAction();
 | 
 | 2311 |             if (target.selectedAction() == "2") {
 | 
 | 2312 |                 filter_param.wifi_mac_black_list = string_maclist;
 | 
 | 2313 |             } else if (target.selectedAction() == "1") {
 | 
 | 2314 |                 filter_param.wifi_mac_white_list = string_maclist;
 | 
 | 2315 |             }
 | 
 | 2316 |             showLoading('waiting');
 | 
 | 2317 |             service.setMacFilter(filter_param, function (result) {
 | 
 | 2318 |                 if (result.result == "success") {
 | 
 | 2319 |                     successOverlay();
 | 
 | 2320 |                 } else {
 | 
 | 2321 |                     errorOverlay();
 | 
 | 2322 |                 }
 | 
 | 2323 |             });
 | 
 | 2324 |         }
 | 
 | 2325 |     }
 | 
 | 2326 | 
 | 
 | 2327 |     function bindContainer(filter_vm) {
 | 
 | 2328 |         var container = $('#container');
 | 
 | 2329 |         ko.cleanNode(container[0]);
 | 
 | 2330 |         ko.applyBindings(filter_vm, container[0]);
 | 
 | 2331 | 
 | 
 | 2332 |         $('#frmWifiSwitch').validate({
 | 
 | 2333 |             submitHandler: function () {
 | 
 | 2334 |                 filter_vm.setMultiSSIDSwitch();
 | 
 | 2335 |             }
 | 
 | 2336 |         });
 | 
 | 2337 |         $('#mac_filter_form').validate({
 | 
 | 2338 |             submitHandler: function () {
 | 
 | 2339 |                 filter_vm.save();
 | 
 | 2340 |             },
 | 
 | 2341 |             rules: {
 | 
 | 2342 |                 mac_1: 'mac_check',
 | 
 | 2343 |                 mac_2: 'mac_check',
 | 
 | 2344 |                 mac_3: 'mac_check',
 | 
 | 2345 |                 mac_4: 'mac_check',
 | 
 | 2346 |                 mac_5: 'mac_check',
 | 
 | 2347 |                 mac_6: 'mac_check',
 | 
 | 2348 |                 mac_7: 'mac_check',
 | 
 | 2349 |                 mac_8: 'mac_check',
 | 
 | 2350 |                 mac_9: 'mac_check',
 | 
 | 2351 |                 mac_10: 'mac_check'
 | 
 | 2352 |             }
 | 
 | 2353 |         });
 | 
 | 2354 |     }
 | 
 | 2355 |     function initialize() {
 | 
 | 2356 |         var filter_vm = new macFilterViewModel();
 | 
 | 2357 |         bindContainer(filter_vm);
 | 
 | 2358 | 
 | 
 | 2359 |         addTimeout(function () {
 | 
 | 2360 |             checkAccessMode();
 | 
 | 2361 |         }, 600);
 | 
 | 2362 |     }
 | 
 | 2363 | 
 | 
 | 2364 |     return {
 | 
 | 2365 |         init: initialize
 | 
 | 2366 |     };
 | 
 | 2367 | });
 | 
 | 2368 | 
 | 
 | 2369 | define("wifi_main","underscore jquery knockout set service CryptoJS".split(" "),
 | 
 | 2370 |     function (_, $, ko, config, service, CryptoJS) {
 | 
 | 2371 | 
 | 
 | 2372 |     var securityModes = _.map(config.WIFI_WEP_SUPPORT ? config.AUTH_MODES_WEP : config.AUTH_MODES, function (item) {
 | 
 | 2373 |         return new Option(item.name, item.value);
 | 
 | 2374 |     });
 | 
 | 2375 | 
 | 
 | 2376 |     function maxStationAccess(max) {
 | 
 | 2377 |         var showOption = [];
 | 
 | 2378 |         for (var i = 1; i <= max; i++) {
 | 
 | 2379 |             showOption.push(new Option(i, i));
 | 
 | 2380 |         }
 | 
 | 2381 |         return showOption;
 | 
 | 2382 |     }
 | 
 | 2383 |     //是否通过wifi接入
 | 
 | 2384 |     var viaWifi = false;
 | 
 | 2385 |     function checkAccessMode() {
 | 
 | 2386 |         service.getParams({
 | 
 | 2387 |             nv: 'user_ip_addr'
 | 
 | 2388 |         }, function (dataIp) {
 | 
 | 2389 |             service.getParams({
 | 
 | 2390 |                 nv: 'station_list'
 | 
 | 2391 |             }, function (dataList) {
 | 
 | 2392 |                 viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
 | 
 | 2393 |             });
 | 
 | 2394 |         });
 | 
 | 2395 |     }
 | 
 | 2396 | 
 | 
 | 2397 |     function WifiMainVM() {
 | 
 | 2398 |         var target = this;
 | 
 | 2399 |         var info = getWifiMain();
 | 
 | 2400 | 
 | 
 | 2401 |         target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
 | 
 | 2402 |         target.hasMultiSSID = config.HAS_MULTI_SSID;
 | 
 | 2403 |         target.showIsolated = config.SHOW_WIFI_AP_ISOLATED;
 | 
 | 2404 |         target.hasAPStation = config.AP_STATION_SUPPORT;
 | 
 | 2405 |         target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
 | 
 | 2406 |         target.hasWifiWep = config.WIFI_WEP_SUPPORT;
 | 
 | 2407 |         target.hasWifiWpa3 = config.WIFI_WAP3_SUPPORT;
 | 
 | 2408 |         target.hasWifiWpa23 = config.WIFI_WPA2_WAP3_SUPPORT;
 | 
 | 2409 | 
 | 
 | 2410 |         var advanceInfo = service.getWifiAdvance();
 | 
 | 2411 |         target.adBand = ko.observable(advanceInfo.wifiBand);
 | 
 | 2412 |         target.adMode = ko.observable(advanceInfo.mode);
 | 
 | 2413 |         target.showQRSwitch = config.WIFI_SUPPORT_QR_CODE && config.WIFI_SUPPORT_QR_SWITCH;
 | 
 | 2414 |         target.showQR = ko.observable(info.show_qrcode_flag);
 | 
 | 2415 |         if (config.WIFI_SUPPORT_QR_SWITCH) {
 | 
 | 2416 |             target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE && target.showQR());
 | 
 | 2417 |         } else {
 | 
 | 2418 |             target.showQRCode = ko.observable(config.WIFI_SUPPORT_QR_CODE);
 | 
 | 2419 |         }
 | 
 | 2420 |         if(config.WIFI_SUPPORT_QR_CODE){
 | 
 | 2421 |             target.qrcodeSrc = './pic/qrcode_ssid_wifikey.png?_=' + $.now();
 | 
 | 2422 |         } else {
 | 
 | 2423 |             target.qrcodeSrc = './pic/res_blacktrans.png';
 | 
 | 2424 |         }
 | 
 | 2425 |         target.origin_ap_station_enable = info.ap_station_enable;
 | 
 | 2426 |         target.wifi_enable = ko.observable(info.wifi_enable);
 | 
 | 2427 | 
 | 
 | 2428 |         target.isShowSSIDInfoDiv = ko.observable(false);
 | 
 | 2429 |         if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 2430 |             if (info.wifi_enable == "1") {
 | 
 | 2431 |                 target.isShowSSIDInfoDiv(true);
 | 
 | 2432 |             } else {
 | 
 | 2433 |                 target.isShowSSIDInfoDiv(false);
 | 
 | 2434 |             }
 | 
 | 2435 |         } else {
 | 
 | 2436 |             target.isShowSSIDInfoDiv(true);
 | 
 | 2437 |         }
 | 
 | 2438 | 
 | 
 | 2439 |         target.multi_ssid_enable = ko.observable(info.multi_ssid_enable);
 | 
 | 2440 |         target.origin_multi_ssid_enable = info.multi_ssid_enable;
 | 
 | 2441 | 
 | 
 | 2442 |         target.maxStationNumber = ko.computed(function () {
 | 
 | 2443 |             return config.MAX_STATION_NUMBER;
 | 
 | 2444 |         });
 | 
 | 2445 | 
 | 
 | 2446 |         target.modes = ko.observableArray(securityModes);
 | 
 | 2447 |         target.selectedMode = ko.observable(info.AuthMode);
 | 
 | 2448 |         target.passPhrase = ko.observable(info.passPhrase);
 | 
 | 2449 |         target.showPassword = ko.observable(false);
 | 
 | 2450 |         target.ssid = ko.observable(info.SSID);
 | 
 | 2451 |         target.broadcast = ko.observable(info.broadcast == '1' ? '1' : '0');
 | 
 | 2452 |         target.apIsolation = ko.observable(info.apIsolation == '1' ? '1' : '0');
 | 
 | 2453 |         target.cipher = info.cipher;
 | 
 | 2454 |         target.selectedStation = ko.observable(info.MAX_Access_num);
 | 
 | 2455 |         target.maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));
 | 
 | 2456 |         target.encryptType = ko.observable(info.encryptType);
 | 
 | 2457 |         target.keyID = ko.observable(info.keyID);
 | 
 | 2458 |         target.wepPassword = ko.observable("");
 | 
 | 2459 | 
 | 
 | 2460 |         target.m_modes = ko.observableArray(securityModes);
 | 
 | 2461 |         target.m_selectedMode = ko.observable(info.m_AuthMode);
 | 
 | 2462 |         target.m_passPhrase = ko.observable(info.m_passPhrase);
 | 
 | 2463 |         target.m_showPassword = ko.observable(false);
 | 
 | 2464 |         target.m_ssid = ko.observable(info.m_SSID);
 | 
 | 2465 |         target.m_broadcast = ko.observable(info.m_broadcast == '1' ? '1' : '0');
 | 
 | 2466 |         target.m_apIsolation = ko.observable(info.m_apIsolation == '1' ? '1' : '0');
 | 
 | 2467 |         target.m_cipher = info.m_cipher;
 | 
 | 2468 |         target.m_selectedStation = ko.observable(info.m_MAX_Access_num);
 | 
 | 2469 |         target.m_maxStations = ko.observableArray(maxStationAccess(info.MAX_Station_num));
 | 
 | 2470 | 
 | 
 | 2471 |         target.getWepPassword = function () {
 | 
 | 2472 |             return target.keyID() == '3' ? info.Key4Str1 : (target.keyID() == '2' ? info.Key3Str1 : target.keyID() == '1' ? info.Key2Str1 : info.Key1Str1);
 | 
 | 2473 |         }
 | 
 | 2474 |         target.wepPassword(target.getWepPassword());
 | 
 | 2475 |         target.profileChangeHandler = function (data, event) {
 | 
 | 2476 |             $("#pwdWepKey").parent().find("label[class='error']").hide();
 | 
 | 2477 |             target.wepPassword(target.getWepPassword());
 | 
 | 2478 |             return true;
 | 
 | 2479 |         };
 | 
 | 2480 | 
 | 
 | 2481 |         target.clear = function (option) {
 | 
 | 2482 |             if (option == "switch") {
 | 
 | 2483 |                 target.multi_ssid_enable(info.multi_ssid_enable);
 | 
 | 2484 |                 target.wifi_enable(info.wifi_enable);
 | 
 | 2485 |             } else if (option == "ssid2") {
 | 
 | 2486 |                 target.m_selectedMode(info.m_AuthMode);
 | 
 | 2487 |                 target.m_passPhrase(info.m_passPhrase);
 | 
 | 2488 |                 target.m_ssid(info.m_SSID);
 | 
 | 2489 |                 target.m_broadcast(info.m_broadcast == '1' ? '1' : '0');
 | 
 | 2490 |                 target.m_cipher = info.m_cipher;
 | 
 | 2491 |                 target.m_selectedStation(info.m_MAX_Access_num);
 | 
 | 2492 |                 target.m_apIsolation(info.m_apIsolation == '1' ? '1' : '0');
 | 
 | 2493 |             } else if (option == "ssid1") {
 | 
 | 2494 |                 target.selectedMode(info.AuthMode);
 | 
 | 2495 |                 target.passPhrase(info.passPhrase);
 | 
 | 2496 |                 target.ssid(info.SSID);
 | 
 | 2497 |                 target.broadcast(info.broadcast == '1' ? '1' : '0');
 | 
 | 2498 |                 target.cipher = info.cipher;
 | 
 | 2499 |                 target.selectedStation(info.MAX_Access_num);
 | 
 | 2500 |                 target.apIsolation(info.apIsolation == '1' ? '1' : '0');
 | 
 | 2501 |                 if (config.WIFI_WEP_SUPPORT) {
 | 
 | 2502 |                     target.encryptType(info.encryptType);
 | 
 | 2503 |                     target.keyID(info.keyID);
 | 
 | 2504 |                     target.wepPassword(target.getWepPassword());
 | 
 | 2505 |                 }
 | 
 | 2506 |             } else {
 | 
 | 2507 |                 clearTimer();
 | 
 | 2508 |                 clearValidateMsg();
 | 
 | 2509 |                 initialize();
 | 
 | 2510 |             }
 | 
 | 2511 |         };
 | 
 | 2512 | 
 | 
 | 2513 |         target.saveSSID1 = function () {
 | 
 | 2514 |             if (target.checkSettings("ssid1")) {
 | 
 | 2515 |                 return;
 | 
 | 2516 |             }
 | 
 | 2517 |             if (!config.PASSWORD_ENCODE) {
 | 
 | 2518 |                 var pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,32}');
 | 
 | 2519 |                 if (!pwdRegex.test(target.passPhrase())) {
 | 
 | 2520 |                         showConfirm("password_note_too_low", function () {
 | 
 | 2521 |                             showConfirm('wifi_disconnect_confirm', function () {
 | 
 | 2522 |                             target.saveSSID1Action();
 | 
 | 2523 |                             return;
 | 
 | 2524 |                         });
 | 
 | 2525 |                         return;
 | 
 | 2526 |                     });
 | 
 | 2527 |                     return;
 | 
 | 2528 |                 }
 | 
 | 2529 |             }
 | 
 | 2530 |             showConfirm('wifi_disconnect_confirm', function () {
 | 
 | 2531 |                 target.saveSSID1Action();
 | 
 | 2532 |             });
 | 
 | 2533 |         };
 | 
 | 2534 | 
 | 
 | 2535 |         target.saveSSID1Action = getSSID1Action;
 | 
 | 2536 | 
 | 
 | 2537 |         target.saveSSID2 = function () {
 | 
 | 2538 |             if (target.checkSettings("ssid2")) {
 | 
 | 2539 |                 return;
 | 
 | 2540 |             }
 | 
 | 2541 |             showConfirm('wifi_disconnect_confirm', function () {
 | 
 | 2542 |                 target.saveSSID2Action();
 | 
 | 2543 |             });
 | 
 | 2544 |         };
 | 
 | 2545 | 
 | 
 | 2546 |         target.saveSSID2Action = getSSID2Action;
 | 
 | 2547 | 
 | 
 | 2548 |         //检测wps\最大接入数
 | 
 | 2549 |         target.checkSettings = function (ssid) {
 | 
 | 2550 |             var status = getWpsState();
 | 
 | 2551 |             if (ssid == "ssid1" || ssid == "ssid2") {
 | 
 | 2552 |                 if (ssid == "ssid2") {
 | 
 | 2553 |                     var accessDevice = service.getStatusInfo().ssid2AttachedNum;
 | 
 | 2554 |                     if (parseInt(target.m_selectedStation()) < accessDevice) {
 | 
 | 2555 |                         showAlert('Extend_accessDevice');
 | 
 | 2556 |                         return true;
 | 
 | 2557 |                     }
 | 
 | 2558 |                 } else {
 | 
 | 2559 |                     var accessDevice = service.getStatusInfo().ssid1AttachedNum;
 | 
 | 2560 |                     if (parseInt(target.selectedStation()) < accessDevice) {
 | 
 | 2561 |                         showAlert('Extend_accessDevice');
 | 
 | 2562 |                         return true;
 | 
 | 2563 |                     }
 | 
 | 2564 |                 }
 | 
 | 2565 |             }
 | 
 | 2566 | 
 | 
 | 2567 |             if (status.wpsFlag == '1') {
 | 
 | 2568 |                 showAlert('wps_on_info');
 | 
 | 2569 |                 return true;
 | 
 | 2570 |             }
 | 
 | 2571 | 
 | 
 | 2572 |             if (info.multi_ssid_enable == "1" && config.HAS_MULTI_SSID) {
 | 
 | 2573 |                 if ((ssid == "ssid2" && parseInt(target.m_selectedStation()) + parseInt(info.MAX_Access_num) > info.MAX_Station_num)
 | 
 | 2574 |                      || (ssid == "ssid1" && parseInt(target.selectedStation()) + parseInt(info.m_MAX_Access_num) > info.MAX_Station_num)) {
 | 
 | 2575 |                     showAlert({
 | 
 | 2576 |                         msg: 'multi_ssid_max_access_number_alert',
 | 
 | 2577 |                         params: info.MAX_Station_num
 | 
 | 2578 |                     });
 | 
 | 2579 |                     return true;
 | 
 | 2580 |                 }
 | 
 | 2581 |             }
 | 
 | 2582 | 
 | 
 | 2583 |             return false;
 | 
 | 2584 |         };
 | 
 | 2585 | 
 | 
 | 2586 |         target.setMultiSSIDSwitch = function () {
 | 
 | 2587 |             if (target.checkSettings("switch")) {
 | 
 | 2588 |                 return;
 | 
 | 2589 |             }
 | 
 | 2590 | 
 | 
 | 2591 |             var setSwitch = function () {
 | 
 | 2592 |                 showLoading('waiting');
 | 
 | 2593 |                 var params = {};
 | 
 | 2594 |                 params.m_ssid_enable = target.multi_ssid_enable();
 | 
 | 2595 |                 if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 2596 |                     params.wifiEnabled = target.wifi_enable();
 | 
 | 2597 |                 }
 | 
 | 2598 |                 service.setWifiBasicMultiSSIDSwitch(params, function (result) {
 | 
 | 2599 |                     if (result.result == "success") {
 | 
 | 2600 |                         if (viaWifi) {
 | 
 | 2601 |                             setTimeout(hasApReloadVarWifi, 15000);
 | 
 | 2602 |                         } else {
 | 
 | 2603 |                             addInterval(hasApReload, 1000);
 | 
 | 2604 |                         }
 | 
 | 2605 |                     } else {
 | 
 | 2606 |                         errorOverlay();
 | 
 | 2607 |                     }
 | 
 | 2608 |                 });
 | 
 | 2609 |             };
 | 
 | 2610 | 
 | 
 | 2611 |             function hasApReloadVarWifi() {
 | 
 | 2612 |                 successOverlay();
 | 
 | 2613 |                 setTimeout(function () {
 | 
 | 2614 |                     window.location.reload();
 | 
 | 2615 |                 }, 1000);
 | 
 | 2616 |                 service.refreshAPStationStatus();
 | 
 | 2617 |                 target.clear();
 | 
 | 2618 |             }
 | 
 | 2619 |             function hasApReload() {
 | 
 | 2620 |                 var info = getWifiMain();
 | 
 | 2621 |                 service.refreshAPStationStatus();
 | 
 | 2622 |                 if (info.wifi_enable == target.wifi_enable()) {
 | 
 | 2623 |                     successOverlay();
 | 
 | 2624 |                     target.clear();
 | 
 | 2625 |                 }
 | 
 | 2626 |             }
 | 
 | 2627 | 
 | 
 | 2628 |             var info = service.getStatusInfo();
 | 
 | 2629 |             if (config.HAS_MULTI_SSID && target.wifi_enable() == "1") {
 | 
 | 2630 |                 if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
 | 
 | 2631 |                     if (!info.wifiStatus) {
 | 
 | 2632 |                         showConfirm("multi_ssid_enable_confirm", function () {
 | 
 | 2633 |                             setSwitch();
 | 
 | 2634 |                         });
 | 
 | 2635 |                     } else {
 | 
 | 2636 |                         showConfirm("multi_ssid_enable_confirm2", function () {
 | 
 | 2637 |                             setSwitch();
 | 
 | 2638 |                         });
 | 
 | 2639 |                     }
 | 
 | 2640 |                 } else {
 | 
 | 2641 |                     if (!info.wifiStatus) {
 | 
 | 2642 |                         setSwitch();
 | 
 | 2643 |                     } else {
 | 
 | 2644 |                         showConfirm("wifi_disconnect_confirm2", function () {
 | 
 | 2645 |                             setSwitch();
 | 
 | 2646 |                         });
 | 
 | 2647 |                     }
 | 
 | 2648 |                 }
 | 
 | 2649 |             } else {
 | 
 | 2650 |                 setSwitch();
 | 
 | 2651 |             }
 | 
 | 2652 |         };
 | 
 | 2653 | 
 | 
 | 2654 |         //二维码显示事件
 | 
 | 2655 |         target.showQRHandler = function () {
 | 
 | 2656 |             var checkbox = $("#showQR:checked");
 | 
 | 2657 |             if (checkbox && checkbox.length == 0) {
 | 
 | 2658 |                 target.showQR(true);
 | 
 | 2659 |             } else {
 | 
 | 2660 |                 target.showQR(false);
 | 
 | 2661 |             }
 | 
 | 2662 |             target.showQRCode(config.WIFI_SUPPORT_QR_CODE && target.showQR());
 | 
 | 2663 |         };
 | 
 | 2664 | 
 | 
 | 2665 |         //SSID2
 | 
 | 2666 |         target.m_showPasswordHandler = function () {
 | 
 | 2667 |             $("#m_passShow").parent().find(".error").hide();
 | 
 | 2668 |             var checkbox = $("#m_showPassword:checked");
 | 
 | 2669 |             if (checkbox && checkbox.length == 0) {
 | 
 | 2670 |                 target.m_showPassword(true);
 | 
 | 2671 |             } else {
 | 
 | 2672 |                 target.m_showPassword(false);
 | 
 | 2673 |             }
 | 
 | 2674 |         };
 | 
 | 2675 |         target.showPasswordHandler = function () {
 | 
 | 2676 |             $("#codeWPAKey").parent().find(".error").hide();
 | 
 | 2677 |             $("#pwdWepKey").parent().find(".error").hide();
 | 
 | 2678 |             var checkbox = $("#showPassword:checked");
 | 
 | 2679 |             if (checkbox && checkbox.length == 0) {
 | 
 | 2680 |                 target.showPassword(true);
 | 
 | 2681 |             } else {
 | 
 | 2682 |                 target.showPassword(false);
 | 
 | 2683 |             }
 | 
 | 2684 |         };
 | 
 | 2685 | 
 | 
 | 2686 |         function getSSID2Action() {
 | 
 | 2687 |             showLoading('waiting');
 | 
 | 2688 |             var params = {};
 | 
 | 2689 |             params.m_AuthMode = target.m_selectedMode();
 | 
 | 2690 |             params.m_passPhrase = target.m_passPhrase();
 | 
 | 2691 |             params.m_SSID = target.m_ssid();
 | 
 | 2692 |             params.m_broadcast = target.m_broadcast();
 | 
 | 2693 |             params.m_station = target.m_selectedStation();
 | 
 | 2694 |             params.m_cipher = target.m_selectedMode() == "WPA2PSK" ? 1 : 2;
 | 
 | 2695 |             if (params.m_AuthMode == "WPA3Personal" || params.m_AuthMode == "WPA2WPA3") {
 | 
 | 2696 |                 params.m_cipher = 1;
 | 
 | 2697 |             }
 | 
 | 2698 |             params.m_NoForwarding = target.m_apIsolation();
 | 
 | 2699 |             params.m_show_qrcode_flag = target.showQR() == true ? 1 : 0;
 | 
 | 2700 |             service.setWifiBasic4SSID2(params, function (result) {
 | 
 | 2701 |                 if (result.result == "success") {
 | 
 | 2702 |                     if (viaWifi) {
 | 
 | 2703 |                         setTimeout(ssid2ReloadVarWifi, 15000);
 | 
 | 2704 |                     } else {
 | 
 | 2705 |                         addInterval(ssid2Reload, 1000);
 | 
 | 2706 |                     }
 | 
 | 2707 |                 } else {
 | 
 | 2708 |                     errorOverlay();
 | 
 | 2709 |                 }
 | 
 | 2710 |             });
 | 
 | 2711 |         }
 | 
 | 2712 |         function ssid2ReloadVarWifi() {
 | 
 | 2713 |             successOverlay();
 | 
 | 2714 |             setTimeout(function () {
 | 
 | 2715 |                 window.location.reload();
 | 
 | 2716 |             }, 1000);
 | 
 | 2717 |             target.clear();
 | 
 | 2718 |         }
 | 
 | 2719 |         function ssid2Reload() {
 | 
 | 2720 |             var info = getWifiMain();
 | 
 | 2721 |             if (info.wifi_enable == "1") {
 | 
 | 2722 |                 successOverlay();
 | 
 | 2723 |                 target.clear();
 | 
 | 2724 |             }
 | 
 | 2725 |         }
 | 
 | 2726 | 
 | 
 | 2727 |         function getSSID1Action() {
 | 
 | 2728 | 
 | 
 | 2729 |             showLoading('waiting');
 | 
 | 2730 |             target.broadcast($("#broadcastCheckbox:checked").length > 0 ? '0' : '1');
 | 
 | 2731 |             target.apIsolation($("#apisolatedCheckbox:checked").length);
 | 
 | 2732 |             var ciphertext = "";
 | 
 | 2733 |             if (config.PASSWORD_ENCODE) {
 | 
 | 2734 | 	        ciphertext = target.passPhrase();
 | 
 | 2735 | 	    } else {
 | 
 | 2736 |                 var kparam = service.getDeviceInfoLow();
 | 
 | 2737 |                 var tkey = CryptoJS.enc.Latin1.parse(kparam.skey);
 | 
 | 2738 | 		var tiv = CryptoJS.enc.Latin1.parse(kparam.siv);
 | 
 | 2739 |                 ciphertext = CryptoJS.AES.encrypt(target.passPhrase(), tkey, {
 | 
 | 2740 |                     iv: tiv,
 | 
 | 2741 |                     mode: CryptoJS.mode.CBC,
 | 
 | 2742 |                     padding: CryptoJS.pad.ZeroPadding
 | 
 | 2743 |                     }).toString();
 | 
 | 2744 | 	    }
 | 
 | 2745 |             var params = {};
 | 
 | 2746 |             params.AuthMode = target.selectedMode();
 | 
 | 2747 |             params.passPhrase = ciphertext;
 | 
 | 2748 |             params.SSID = target.ssid();
 | 
 | 2749 |             params.broadcast = target.broadcast();
 | 
 | 2750 |             params.station = target.selectedStation();
 | 
 | 2751 |             params.cipher = target.selectedMode() == "WPA2PSK" ? 1 : 2;
 | 
 | 2752 |             if (params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {
 | 
 | 2753 |                 params.cipher = 1;
 | 
 | 2754 |             }
 | 
 | 2755 |             params.NoForwarding = target.apIsolation();
 | 
 | 2756 |             params.show_qrcode_flag = target.showQR() == true ? 1 : 0;
 | 
 | 2757 |             if (config.WIFI_WEP_SUPPORT) {
 | 
 | 2758 |                 if (params.AuthMode == "WPAPSK" || params.AuthMode == "WPA2PSK" || params.AuthMode == "WPAPSKWPA2PSK" || params.AuthMode == "WPA3Personal" || params.AuthMode == "WPA2WPA3") {}
 | 
 | 2759 |                 else if (params.AuthMode == "SHARED") {
 | 
 | 2760 |                     params.encryptType = "WEP";
 | 
 | 2761 |                 } else {
 | 
 | 2762 |                     params.encryptType = target.encryptType();
 | 
 | 2763 |                 }
 | 
 | 2764 |                 params.wep_default_key = target.keyID();
 | 
 | 2765 |                 params.wep_key_1 = info.Key1Str1;
 | 
 | 2766 |                 params.wep_key_2 = info.Key2Str1;
 | 
 | 2767 |                 params.wep_key_3 = info.Key3Str1;
 | 
 | 2768 |                 params.wep_key_4 = info.Key4Str1;
 | 
 | 2769 |                 var WEPSelect = '0';
 | 
 | 2770 |                 if (target.wepPassword().length == '5' || target.wepPassword().length == '13') {
 | 
 | 2771 |                     WEPSelect = '1';
 | 
 | 2772 |                 } else {
 | 
 | 2773 |                     WEPSelect = '0';
 | 
 | 2774 |                 }
 | 
 | 2775 |                 if (target.keyID() == '3') {
 | 
 | 2776 |                     params.wep_key_4 = target.wepPassword();
 | 
 | 2777 |                     params.WEP4Select = WEPSelect;
 | 
 | 2778 |                 } else if (target.keyID() == '2') {
 | 
 | 2779 |                     params.wep_key_3 = target.wepPassword();
 | 
 | 2780 |                     params.WEP3Select = WEPSelect;
 | 
 | 2781 |                 } else if (target.keyID() == '1') {
 | 
 | 2782 |                     params.wep_key_2 = target.wepPassword();
 | 
 | 2783 |                     params.WEP2Select = WEPSelect;
 | 
 | 2784 |                 } else {
 | 
 | 2785 |                     params.wep_key_1 = target.wepPassword();
 | 
 | 2786 |                     params.WEP1Select = WEPSelect;
 | 
 | 2787 |                 }
 | 
 | 2788 |             }
 | 
 | 2789 | 
 | 
 | 2790 |             service.setWifiBasic(params, function (result) {
 | 
 | 2791 |                 if (result.result == "success") {
 | 
 | 2792 |                     if (viaWifi) {
 | 
 | 2793 |                         setTimeout(ssid1ReloadVarWifi, 15000);
 | 
 | 2794 |                     } else {
 | 
 | 2795 |                         addInterval(ssid1Reload, 1000);
 | 
 | 2796 |                     }
 | 
 | 2797 |                 } else {
 | 
 | 2798 |                     errorOverlay();
 | 
 | 2799 |                 }
 | 
 | 2800 |             });
 | 
 | 2801 |         }
 | 
 | 2802 |         function ssid1ReloadVarWifi() {
 | 
 | 2803 |             successOverlay();
 | 
 | 2804 |             setTimeout(function () {
 | 
 | 2805 |                 window.location.reload();
 | 
 | 2806 |             }, 1000);
 | 
 | 2807 |             target.clear();
 | 
 | 2808 |         }
 | 
 | 2809 |         function ssid1Reload() {
 | 
 | 2810 |             var info = getWifiMain();
 | 
 | 2811 |             if (info.wifi_enable == "1") {
 | 
 | 2812 |                 successOverlay();
 | 
 | 2813 |                 target.clear();
 | 
 | 2814 |             }
 | 
 | 2815 |         }
 | 
 | 2816 | 
 | 
 | 2817 |     }
 | 
 | 2818 | 
 | 
 | 2819 |     function getWpsState() {
 | 
 | 2820 |         return service.getWpsInfo();
 | 
 | 2821 |     }
 | 
 | 2822 | 
 | 
 | 2823 |     function getWifiMain() {
 | 
 | 2824 |         return service.getWifiBasic();
 | 
 | 2825 |     }
 | 
 | 2826 | 
 | 
 | 2827 |     function initialize() {
 | 
 | 2828 |         var container = $('#container');
 | 
 | 2829 |         ko.cleanNode(container[0]);
 | 
 | 2830 |         var vm = new WifiMainVM();
 | 
 | 2831 |         ko.applyBindings(vm, container[0]);
 | 
 | 2832 |         addTimeout(function () {
 | 
 | 2833 |             checkAccessMode();
 | 
 | 2834 |         }, 600);
 | 
 | 2835 | 
 | 
 | 2836 |         if (config.WDS_SUPPORT) {
 | 
 | 2837 |             checkWifiStatusAccordingToWDS();
 | 
 | 2838 |         } else if (config.AP_STATION_SUPPORT) {
 | 
 | 2839 |             checkWifiStatus();
 | 
 | 2840 |         }
 | 
 | 2841 | 
 | 
 | 2842 |         $('#frmSSID1').validate({
 | 
 | 2843 |             submitHandler: function () {
 | 
 | 2844 |                 vm.saveSSID1();
 | 
 | 2845 |             },
 | 
 | 2846 |             rules: {
 | 
 | 2847 |                 ssid: 'ssid',
 | 
 | 2848 |                 pwdWepKey: {
 | 
 | 2849 |                     wifi_wep_password_check: true,
 | 
 | 2850 |                     wifi_password_check: true
 | 
 | 2851 |                 },
 | 
 | 2852 |                 txtWepKey: {
 | 
 | 2853 |                     wifi_wep_password_check: true,
 | 
 | 2854 |                     wifi_password_check: true
 | 
 | 2855 |                 },
 | 
 | 2856 |                 codeWPAKey: 'wifi_password_check',
 | 
 | 2857 |                 txtWPAKey: 'wifi_password_check'
 | 
 | 2858 |             },
 | 
 | 2859 |             errorPlacement: function (error, element) {
 | 
 | 2860 |                 var id = element.attr("id");
 | 
 | 2861 |                 if (id == "codeWPAKey" || id == "txtWPAKey") {
 | 
 | 2862 |                     error.insertAfter("#lblshowWPAPassword");
 | 
 | 2863 |                 } else if (id == "pwdWepKey" || id == "txtWepKey") {
 | 
 | 2864 |                     error.insertAfter("#lblShowWepPassword");
 | 
 | 2865 |                 } else {
 | 
 | 2866 |                     error.insertAfter(element);
 | 
 | 2867 |                 }
 | 
 | 2868 |             }
 | 
 | 2869 |         });
 | 
 | 2870 |         $('#frmSSID2').validate({
 | 
 | 2871 |             submitHandler: function () {
 | 
 | 2872 |                 vm.saveSSID2();
 | 
 | 2873 |             },
 | 
 | 2874 |             rules: {
 | 
 | 2875 |                 m_ssid: 'ssid',
 | 
 | 2876 |                 m_pass: 'wifi_password_check',
 | 
 | 2877 |                 m_passShow: 'wifi_password_check'
 | 
 | 2878 |             },
 | 
 | 2879 |             errorPlacement: function (error, element) {
 | 
 | 2880 |                 var id = element.attr("id");
 | 
 | 2881 |                 if (id == "m_pass" || id == "m_passShow") {
 | 
 | 2882 |                     error.insertAfter("#m_lblShowPassword");
 | 
 | 2883 |                 } else if (id == "pass" || id == "passShow") {
 | 
 | 2884 |                     error.insertAfter("#lblShowPassword");
 | 
 | 2885 |                 } else {
 | 
 | 2886 |                     error.insertAfter(element);
 | 
 | 2887 |                 }
 | 
 | 2888 |             }
 | 
 | 2889 |         });
 | 
 | 2890 |         //表单提交函数、校验规则配置
 | 
 | 2891 |         $('#frmWifiSwitch').validate({
 | 
 | 2892 |             submitHandler: function () {
 | 
 | 2893 |                 vm.setMultiSSIDSwitch();
 | 
 | 2894 |             }
 | 
 | 2895 |         });
 | 
 | 2896 | 
 | 
 | 2897 |         $('#frmMultiSSID').validate({
 | 
 | 2898 |             submitHandler: function () {
 | 
 | 2899 |                 vm.setMultiSSIDSwitch();
 | 
 | 2900 |             }
 | 
 | 2901 |         });
 | 
 | 2902 | 
 | 
 | 2903 |     }
 | 
 | 2904 | 
 | 
 | 2905 |     function checkWifiStatusAccordingToWDS() {
 | 
 | 2906 |         var info = service.getWdsInfo();
 | 
 | 2907 |         if (info.currentMode == "0") {
 | 
 | 2908 |             $('#frmWifiSwitch :input').each(function () {
 | 
 | 2909 |                 $(this).prop("disabled", false);
 | 
 | 2910 |             });
 | 
 | 2911 |             $('#frmSSID1 :input').each(function () {
 | 
 | 2912 |                 $(this).prop("disabled", false);
 | 
 | 2913 |             });
 | 
 | 2914 |             $('#frmSSID2 :input').each(function () {
 | 
 | 2915 |                 $(this).prop("disabled", false);
 | 
 | 2916 |             });
 | 
 | 2917 |         } else {
 | 
 | 2918 |             $('#frmWifiSwitch :input').each(function () {
 | 
 | 2919 |                 $(this).prop("disabled", true);
 | 
 | 2920 |             });
 | 
 | 2921 |             $('#frmSSID1 :input').each(function () {
 | 
 | 2922 |                 $(this).prop("disabled", true);
 | 
 | 2923 |             });
 | 
 | 2924 |             $('#frmSSID2 :input').each(function () {
 | 
 | 2925 |                 $(this).prop("disabled", true);
 | 
 | 2926 |             });
 | 
 | 2927 |         }
 | 
 | 2928 |     }
 | 
 | 2929 |     function checkWifiStatus() {
 | 
 | 2930 |         var info = service.getAPStationBasic();
 | 
 | 2931 |         if (info.ap_station_enable == "1") {
 | 
 | 2932 |             $('#frmMultiSSID :input').each(function () {
 | 
 | 2933 |                 $(this).prop("disabled", true);
 | 
 | 2934 |             });
 | 
 | 2935 |         } else {
 | 
 | 2936 |             $('#frmMultiSSID :input').each(function () {
 | 
 | 2937 |                 $(this).prop("disabled", false);
 | 
 | 2938 |             });
 | 
 | 2939 |         }
 | 
 | 2940 |     }
 | 
 | 2941 | 
 | 
 | 2942 |     return {
 | 
 | 2943 |         init: initialize
 | 
 | 2944 |     };
 | 
 | 2945 | });
 | 
 | 2946 | 
 | 
 | 2947 | define("wifi_sleep_mode","underscore jquery knockout set service".split(" "),
 | 
 | 2948 |     function (_, $, ko, config, service) {
 | 
 | 2949 | 
 | 
 | 2950 |     //休眠方式
 | 
 | 2951 |     function getSleepMode() {
 | 
 | 2952 |         return service.getSleepMode();
 | 
 | 2953 |     }
 | 
 | 2954 | 
 | 
 | 2955 |     //覆盖范围
 | 
 | 2956 |     function getWifiRange() {
 | 
 | 2957 |         return service.getWifiRange();
 | 
 | 2958 |     }
 | 
 | 2959 | 
 | 
 | 2960 |     var sleepTime = _.map(config.SLEEP_MODES, function (item) {
 | 
 | 2961 |         return new Option(item.name, item.value);
 | 
 | 2962 |     });
 | 
 | 2963 | 
 | 
 | 2964 |     function SleepModeViewMode() {
 | 
 | 2965 |         var target = this;
 | 
 | 2966 | 
 | 
 | 2967 |         target.isCPE = config.PRODUCT_TYPE == 'CPE';
 | 
 | 2968 |         target.showTSWDiv = config.TSW_SUPPORT;
 | 
 | 2969 |         target.showSleepDiv = config.WIFI_SLEEP_SUPPORT;
 | 
 | 2970 |         target.hasUssd = config.HAS_USSD;
 | 
 | 2971 |         target.hasUpdateCheck = config.HAS_UPDATE_CHECK;
 | 
 | 2972 |         target.hasDdns = config.DDNS_SUPPORT;
 | 
 | 2973 | 
 | 
 | 2974 |         target.modes = ko.observableArray(sleepTime);
 | 
 | 2975 | 
 | 
 | 2976 |         var smInfo = getSleepMode();
 | 
 | 2977 |         target.selectedMode = ko.observable(smInfo.sleepMode);
 | 
 | 2978 | 
 | 
 | 2979 |         var wifiRangeInfo = getWifiRange();
 | 
 | 2980 |         target.wifiRangeMode = ko.observable(wifiRangeInfo.wifiRangeMode);
 | 
 | 2981 | 
 | 
 | 2982 |         target.setWifiRange = smSetWifiRange;
 | 
 | 2983 | 
 | 
 | 2984 |         target.setWifiRangeAct = smSetWifiRangeAct;
 | 
 | 2985 | 
 | 
 | 2986 |         target.setSleepMode = smSetSleepMode;
 | 
 | 2987 | 
 | 
 | 2988 |         target.setSleepModeAct = smSetSleepModeAct;
 | 
 | 2989 | 
 | 
 | 2990 |         var tsw = service.getTsw();
 | 
 | 2991 |         target.openEnable = ko.observable(tsw.openEnable == "" ? '0' : tsw.openEnable);
 | 
 | 2992 |         target.openH = ko.observable(tsw.openH);
 | 
 | 2993 |         target.openM = ko.observable(tsw.openM);
 | 
 | 2994 |         target.closeH = ko.observable(tsw.closeH);
 | 
 | 2995 |         target.closeM = ko.observable(tsw.closeM);
 | 
 | 2996 |         //定时休眠唤醒
 | 
 | 2997 |         target.saveTsw = smSaveTsw;
 | 
 | 2998 | 
 | 
 | 2999 |         function smSetWifiRange() {
 | 
 | 3000 |             service.getWpsInfo({}, function (smInfo) {
 | 
 | 3001 |                 if (smInfo.wpsFlag == '1') {
 | 
 | 3002 |                     showAlert('wps_on_info');
 | 
 | 3003 |                 } else if (smInfo.radioFlag == '0') {
 | 
 | 3004 |                     showAlert('wps_wifi_off');
 | 
 | 3005 |                 } else {
 | 
 | 3006 |                     showConfirm('wifi_sleep_confirm', function () {
 | 
 | 3007 |                         showLoading('waiting');
 | 
 | 3008 |                         target.setWifiRangeAct();
 | 
 | 3009 |                     });
 | 
 | 3010 | 
 | 
 | 3011 |                 }
 | 
 | 3012 |             });
 | 
 | 3013 |         }
 | 
 | 3014 |         function smSetSleepModeAct() {
 | 
 | 3015 |             var params = {};
 | 
 | 3016 |             params.sleepMode = target.selectedMode();
 | 
 | 3017 |             service.setSleepMode(params, function (result) {
 | 
 | 3018 |                 if (result.result != "success") {
 | 
 | 3019 |                     errorOverlay();
 | 
 | 3020 |                 } else {
 | 
 | 3021 |                     successOverlay();
 | 
 | 3022 |                 }
 | 
 | 3023 |             });
 | 
 | 3024 |         }
 | 
 | 3025 | 
 | 
 | 3026 |         function smSetWifiRangeAct() {
 | 
 | 3027 |             var params = {};
 | 
 | 3028 |             params.wifiRangeMode = target.wifiRangeMode();
 | 
 | 3029 |             service.setWifiRange(params, function (result) {
 | 
 | 3030 |                 if (result.result != "success") {
 | 
 | 3031 |                     errorOverlay();
 | 
 | 3032 |                 } else {
 | 
 | 3033 |                     successOverlay();
 | 
 | 3034 |                 }
 | 
 | 3035 |             });
 | 
 | 3036 |         }
 | 
 | 3037 | 
 | 
 | 3038 |         function smSetSleepMode() {
 | 
 | 3039 |             showLoading('waiting');
 | 
 | 3040 |             service.getWpsInfo({}, function (info) {
 | 
 | 3041 |                 if (info.wpsFlag == '1') {
 | 
 | 3042 |                     showAlert('wps_on_info');
 | 
 | 3043 |                 } else if (info.radioFlag == '0') {
 | 
 | 3044 |                     showAlert('wps_wifi_off');
 | 
 | 3045 |                 } else {
 | 
 | 3046 |                     target.setSleepModeAct();
 | 
 | 3047 |                 }
 | 
 | 3048 |             });
 | 
 | 3049 |         }
 | 
 | 3050 |         function smSaveTsw() {
 | 
 | 3051 |             if (target.openEnable() == '1') {
 | 
 | 3052 |                 if (Math.abs((target.openH() * 60 + parseInt(target.openM(), 10)) - (target.closeH() * 60 + parseInt(target.closeM(), 10))) < 10) {
 | 
 | 3053 |                     showAlert('tsw_time_interval_alert');
 | 
 | 3054 |                     return false;
 | 
 | 3055 |                 }
 | 
 | 3056 |                 showLoading('waiting');
 | 
 | 3057 |                 service.saveTsw({
 | 
 | 3058 |                     openEnable: target.openEnable(),
 | 
 | 3059 |                     closeEnable: target.openEnable(),
 | 
 | 3060 |                     openTime: leftInsert(target.openH(), 2, '0') + ':' + leftInsert(target.openM(), 2, '0'),
 | 
 | 3061 |                     closeTime: leftInsert(target.closeH(), 2, '0') + ':' + leftInsert(target.closeM(), 2, '0')
 | 
 | 3062 |                 }, smShowRes, $.noop);
 | 
 | 3063 |             } else {
 | 
 | 3064 |                 showLoading('waiting');
 | 
 | 3065 |                 service.saveTsw({
 | 
 | 3066 |                     openEnable: target.openEnable(),
 | 
 | 3067 |                     closeEnable: target.openEnable()
 | 
 | 3068 |                 }, smShowRes, $.noop);
 | 
 | 3069 |             }
 | 
 | 3070 | 
 | 
 | 3071 |         }
 | 
 | 3072 | 
 | 
 | 3073 |     }
 | 
 | 3074 |     function bindContainer(smVm) {
 | 
 | 3075 |         var container = $('#container');
 | 
 | 3076 |         ko.cleanNode(container[0]);
 | 
 | 3077 |         ko.applyBindings(smVm, container[0]);
 | 
 | 3078 | 
 | 
 | 3079 |         $('#frmTsw').validate({
 | 
 | 3080 |             submitHandler: function () {
 | 
 | 3081 |                 smVm.saveTsw();
 | 
 | 3082 |             },
 | 
 | 3083 |             errorPlacement: function (error, element) {
 | 
 | 3084 |                 if (element.attr("name") == "closeM" || element.attr("name") == "closeH") {
 | 
 | 3085 |                     $("#closeErrorDiv").html(error);
 | 
 | 3086 |                 } else if (element.attr("name") == "openM" || element.attr("name") == "openH") {
 | 
 | 3087 |                     $("#openErrorDiv").html(error);
 | 
 | 3088 |                 } else {
 | 
 | 3089 |                     error.insertAfter(element);
 | 
 | 3090 |                 }
 | 
 | 3091 |             }
 | 
 | 3092 |         });
 | 
 | 3093 | 
 | 
 | 3094 |         $('#sleepModeForm').validate({
 | 
 | 3095 |             submitHandler: function () {
 | 
 | 3096 |                 smVm.setSleepMode();
 | 
 | 3097 |             }
 | 
 | 3098 |         });
 | 
 | 3099 | 
 | 
 | 3100 |         $('#wifiRangeForm').validate({
 | 
 | 3101 |             submitHandler: function () {
 | 
 | 3102 |                 smVm.setWifiRange();
 | 
 | 3103 |             }
 | 
 | 3104 |         });
 | 
 | 3105 | 
 | 
 | 3106 |     }
 | 
 | 3107 |     function initialize() {
 | 
 | 3108 |         var smVm = new SleepModeViewMode();
 | 
 | 3109 |         bindContainer(smVm);
 | 
 | 3110 |     }
 | 
 | 3111 |     function smShowRes(data) {
 | 
 | 3112 |         if (data && data.result == "success") {
 | 
 | 3113 |             successOverlay();
 | 
 | 3114 |         } else {
 | 
 | 3115 |             errorOverlay();
 | 
 | 3116 |         }
 | 
 | 3117 |     }
 | 
 | 3118 | 
 | 
 | 3119 |     return {
 | 
 | 3120 |         init: initialize
 | 
 | 3121 |     };
 | 
 | 3122 | });
 | 
 | 3123 | 
 | 
 | 3124 | define("wifi_station_info","underscore jquery knockout set service menu".split(" "),
 | 
 | 3125 |     function (_, $, ko, config, service, menu) {
 | 
 | 3126 | 
 | 
 | 3127 |     var stationUtil = {
 | 
 | 3128 |         dealElement: function (showEdit, idx) {
 | 
 | 3129 |             if (idx != "all") {
 | 
 | 3130 |                 if (!showEdit) {
 | 
 | 3131 |                     $("#edit_btn_" + idx + ",#hostname_txt_" + idx).show();
 | 
 | 3132 |                     $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).hide();
 | 
 | 3133 |                 } else {
 | 
 | 3134 |                     $("#edit_btn_" + idx + ",#hostname_txt_" + idx).hide();
 | 
 | 3135 |                     $("#save_btn_" + idx + ",#cancel_btn_" + idx + ",#hostname_input_" + idx).show();
 | 
 | 3136 |                 }
 | 
 | 3137 |             } else {
 | 
 | 3138 |                 $("input[id^='hostname_txt_'],a[id^='edit_btn_']").show();
 | 
 | 3139 |                 $("input[id^='hostname_input_'],a[id^='cancel_btn_'],a[id^='save_btn_']").hide();
 | 
 | 3140 |             }
 | 
 | 3141 |         },
 | 
 | 3142 |         //根据MAC匹配主机名
 | 
 | 3143 |         getHostName: function (hostName, mac, hostNameList) {
 | 
 | 3144 |             var element_data = _.find(hostNameList, function (element_data) {
 | 
 | 3145 |                 return element_data.mac == mac;
 | 
 | 3146 |             });
 | 
 | 3147 |             return element_data ? element_data.hostname : hostName;
 | 
 | 3148 |         },
 | 
 | 3149 |         //匹配黑名单列表和主机名
 | 
 | 3150 |         parseBlackString: function (macStr, hostnameStr) {
 | 
 | 3151 |             if (macStr == "") {
 | 
 | 3152 |                 return [];
 | 
 | 3153 |             }
 | 
 | 3154 |             var tempMac = macStr.split(';');
 | 
 | 3155 |             var tempHostName = hostnameStr.split(';');
 | 
 | 3156 |             var result = [];
 | 
 | 3157 |             for (var i = 0; i < tempMac.length; i++) {
 | 
 | 3158 |                 //var obj = {};
 | 
 | 3159 |                 //obj.hostName = tempHostName[i];
 | 
 | 3160 |                 //obj.macAddress = tempMac[i];
 | 
 | 3161 |                 result.push({
 | 
 | 3162 |                     hostName: tempHostName[i],
 | 
 | 3163 |                     macAddress: tempMac[i]
 | 
 | 3164 |                 });
 | 
 | 3165 |             }
 | 
 | 3166 |             return result;
 | 
 | 3167 |         }
 | 
 | 3168 |     };
 | 
 | 3169 | 
 | 
 | 3170 |     function staInfoViewMode() {
 | 
 | 3171 |         var target = this;
 | 
 | 3172 |         var originalData = {
 | 
 | 3173 |             user_ip: '',
 | 
 | 3174 |             macList: '',
 | 
 | 3175 |             ACL_mode: 2, //黑白名单
 | 
 | 3176 |             hostnameList: ''
 | 
 | 3177 |         };
 | 
 | 3178 |         target.showCableDiv = config.PRODUCT_TYPE == 'CPE' && config.RJ45_SUPPORT;
 | 
 | 3179 |         target.supportBlock = config.STATION_BLOCK_SUPPORT;
 | 
 | 3180 |         var pcMenu = menu.findMenu('#parental_control');
 | 
 | 3181 |         target.showPCLink = pcMenu && pcMenu.length > 0 && config.HAS_PARENTAL_CONTROL;
 | 
 | 3182 | 
 | 
 | 3183 |         target.deviceInfo = ko.observableArray([]);
 | 
 | 3184 |         target.cableDeviceInfo = ko.observableArray([]);
 | 
 | 3185 |         target.blackDevices = ko.observableArray([]);
 | 
 | 3186 |         target.blackDevicesMac = ko.computed(function () {
 | 
 | 3187 |             return _.map(target.blackDevices(), function (element_data) {
 | 
 | 3188 |                 return element_data.macAddress;
 | 
 | 3189 |             });
 | 
 | 3190 |         });
 | 
 | 3191 |         target.showBlackDiv = ko.observable(config.HAS_BLACK_AND_WHITE_FILTER ? (originalData.ACL_mode == '2' ? true : false) : config.STATION_BLOCK_SUPPORT);
 | 
 | 3192 | 
 | 
 | 3193 |         ko.computed(function () {
 | 
 | 3194 |             target.deviceInfo();
 | 
 | 3195 |             target.cableDeviceInfo();
 | 
 | 3196 |             target.blackDevices();
 | 
 | 3197 |             $("#station_info_div").translate();
 | 
 | 3198 |         }).extend({
 | 
 | 3199 |             notify: 'always',
 | 
 | 3200 |             throttle: 300
 | 
 | 3201 |         });
 | 
 | 3202 | 
 | 
 | 3203 |         var hostNameList = service.getHostNameList({}).devices;
 | 
 | 3204 |         //获取WiFi已连接设备
 | 
 | 3205 |         target.fetchAttachedDevices = function (cb) {
 | 
 | 3206 |             service.getCurrentlyAttachedDevicesInfo({}, function (data) {
 | 
 | 3207 |                 if (editingHostname) {
 | 
 | 3208 |                     return false;
 | 
 | 3209 |                 }
 | 
 | 3210 |                 target.deviceInfo(_.map(data.attachedDevices, function (element_data, idx) {
 | 
 | 3211 |                         element_data.idx = _.uniqueId('wireless_');
 | 
 | 3212 |                         element_data.type = 1;
 | 
 | 3213 |                         element_data.inBlackGroup = config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2' ? false : _.contains(target.blackDevicesMac(), element_data.macAddress);
 | 
 | 3214 |                         element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);
 | 
 | 3215 |                         element_data.disableFlag = (config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2') || element_data.inBlackGroup || editingHostname;
 | 
 | 3216 |                         return element_data;
 | 
 | 3217 |                     }));
 | 
 | 3218 |                 if (_.isFunction(cb)) {
 | 
 | 3219 |                     cb.apply(this);
 | 
 | 3220 |                 }
 | 
 | 3221 |             });
 | 
 | 3222 |         };
 | 
 | 3223 |         //获取RJ45已连接设备
 | 
 | 3224 |         target.fetchAttachedCableDevices = function (cb) {
 | 
 | 3225 |             service.getAttachedCableDevices({}, function (data) {
 | 
 | 3226 |                 if (editingHostname) {
 | 
 | 3227 |                     return false;
 | 
 | 3228 |                 }
 | 
 | 3229 |                 target.cableDeviceInfo(_.map(data.attachedDevices, function (element_data, idx) {
 | 
 | 3230 |                         element_data.idx = _.uniqueId('cable_');
 | 
 | 3231 |                         element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);
 | 
 | 3232 |                         element_data.type = 2;
 | 
 | 3233 |                         return element_data;
 | 
 | 3234 |                     }));
 | 
 | 3235 |                 if (_.isFunction(cb)) {
 | 
 | 3236 |                     cb.apply(this);
 | 
 | 3237 |                 }
 | 
 | 3238 |             });
 | 
 | 3239 |         };
 | 
 | 3240 | 
 | 
 | 3241 |         target.fetchBlacklist = function (cb) {
 | 
 | 3242 |             service.getMacFilterInfo({}, function (data) {
 | 
 | 3243 |                 originalData.ACL_mode = data.ACL_mode;
 | 
 | 3244 |                 originalData.user_ip = data.user_ip_addr;
 | 
 | 3245 |                 originalData.hostnameList = data.wifi_hostname_black_list;
 | 
 | 3246 |                 originalData.macList = data.wifi_mac_black_list;
 | 
 | 3247 |                 target.showBlackDiv(config.HAS_BLACK_AND_WHITE_FILTER ? (originalData.ACL_mode == '2' ? true : false) : config.STATION_BLOCK_SUPPORT);
 | 
 | 3248 |                 var blackDevices = stationUtil.parseBlackString(data.wifi_mac_black_list, data.wifi_hostname_black_list);
 | 
 | 3249 |                 target.blackDevices(_.map(blackDevices, function (element_data, idx) {
 | 
 | 3250 |                         element_data.idx = _.uniqueId('black_');
 | 
 | 3251 |                         element_data.type = 3;
 | 
 | 3252 |                         element_data.hostName = stationUtil.getHostName(element_data.hostName, element_data.macAddress, hostNameList);
 | 
 | 3253 |                         return element_data;
 | 
 | 3254 |                     }));
 | 
 | 3255 |                 if (_.isFunction(cb)) {
 | 
 | 3256 |                     cb.apply(this);
 | 
 | 3257 |                 }
 | 
 | 3258 |             }, $.noop);
 | 
 | 3259 |         };
 | 
 | 3260 |         target.fetchBlacklist();
 | 
 | 3261 |         target.fetchAttachedDevices();
 | 
 | 3262 |         if (target.showCableDiv) {
 | 
 | 3263 |             target.fetchAttachedCableDevices();
 | 
 | 3264 |         }
 | 
 | 3265 | 
 | 
 | 3266 |         var editingHostname = 0;
 | 
 | 3267 |         addInterval(function () {
 | 
 | 3268 |             if (editingHostname == 0) {
 | 
 | 3269 |                 target.fetchAttachedDevices();
 | 
 | 3270 |             }
 | 
 | 3271 |         }, 3000);
 | 
 | 3272 | 
 | 
 | 3273 |         if (target.showCableDiv) {
 | 
 | 3274 |             addInterval(function () {
 | 
 | 3275 |                 if (editingHostname == 0) {
 | 
 | 3276 |                     target.fetchAttachedCableDevices();
 | 
 | 3277 |                 }
 | 
 | 3278 |             }, 5000);
 | 
 | 3279 |         }
 | 
 | 3280 |         //WiFi已连接设备列表中屏蔽按钮事件 入黑名单
 | 
 | 3281 |         target.wirelessBlockHandler = stationBlockEvent;
 | 
 | 3282 |         //保存主机名事件
 | 
 | 3283 |         target.saveHostNameHandler = saveHostNameEvent;
 | 
 | 3284 |         //主机名修改按钮点击事件
 | 
 | 3285 |         target.editHostNameHandler = function (element_data) {
 | 
 | 3286 |             editingHostname++;
 | 
 | 3287 |             $("#hostname_input_" + element_data.idx).val(element_data.hostName);
 | 
 | 3288 |             stationUtil.dealElement(true, element_data.idx);
 | 
 | 3289 |             return false;
 | 
 | 3290 |         };
 | 
 | 3291 |         //取消编辑主机名事件
 | 
 | 3292 |         target.cancelEditHostNameHandler = function (element_data) {
 | 
 | 3293 |             stationUtil.dealElement(false, element_data.idx);
 | 
 | 3294 |             editingHostname--;
 | 
 | 3295 |         };
 | 
 | 3296 |         target.cancelAllEditHostNameHandler = function () {
 | 
 | 3297 |             stationUtil.dealElement(false, "all");
 | 
 | 3298 |             editingHostname = 0;
 | 
 | 3299 |         };
 | 
 | 3300 |         //从黑名单列表中移除
 | 
 | 3301 |         target.blacklistRemoveHandler = function (element_data) {
 | 
 | 3302 |             if (originalData.macList.indexOf(element_data.macAddress) == -1) {
 | 
 | 3303 |                 return false;
 | 
 | 3304 |             }
 | 
 | 3305 |             if (editingHostname) {
 | 
 | 3306 |                 target.cancelAllEditHostNameHandler();
 | 
 | 3307 |             }
 | 
 | 3308 |             showLoading('waiting');
 | 
 | 3309 |             var macArr = [];
 | 
 | 3310 |             var hostnameArr = [];
 | 
 | 3311 |             $.each(target.blackDevices(), function (i, n) {
 | 
 | 3312 |                 if (n.macAddress != element_data.macAddress) {
 | 
 | 3313 |                     macArr.push(n.macAddress);
 | 
 | 3314 |                     hostnameArr.push(n.hostName);
 | 
 | 3315 |                 }
 | 
 | 3316 |             });
 | 
 | 3317 |             var params = {
 | 
 | 3318 |                 ACL_mode: '2', //originalData.ACL_mode
 | 
 | 3319 |                 macFilteringMode: '2', //originalData.ACL_mode
 | 
 | 3320 |                 wifi_hostname_black_list: hostnameArr.join(';'),
 | 
 | 3321 |                 wifi_mac_black_list: macArr.join(';')
 | 
 | 3322 |             };
 | 
 | 3323 |             target.updateMacFilterList(params);
 | 
 | 3324 |         };
 | 
 | 3325 |         target.updateMacFilterList = function (params) {
 | 
 | 3326 |             service.setMacFilter(params, function (data) {
 | 
 | 3327 |                 if (data.result == "success") {
 | 
 | 3328 |                     target.blackDevices([]);
 | 
 | 3329 |                     target.fetchBlacklist(function () {
 | 
 | 3330 |                         target.fetchAttachedDevices(function () {
 | 
 | 3331 |                             successOverlay();
 | 
 | 3332 |                         });
 | 
 | 3333 |                     });
 | 
 | 3334 |                 }
 | 
 | 3335 |             }, function () {
 | 
 | 3336 |                 errorOverlay();
 | 
 | 3337 |             });
 | 
 | 3338 |         };
 | 
 | 3339 | 
 | 
 | 3340 |         function saveHostNameEvent(element_data) {
 | 
 | 3341 |             var $input = $("#hostname_input_" + element_data.idx);
 | 
 | 3342 |             var newHostname = $input.val();
 | 
 | 3343 |             if (newHostname.indexOf(" ") == 0 || newHostname.lastIndexOf(" ") == (newHostname.length - 1) || /[\*\$\[&:,;<>'"\\`\]¥]{1,32}/.test(newHostname)) {
 | 
 | 3344 |                 showAlert('device_rename');
 | 
 | 3345 |                 return false;
 | 
 | 3346 |             } else if (newHostname == '') {
 | 
 | 3347 |                 $(".promptErrorLabel", "#confirm-message-container").text($.i18n.prop("required"));
 | 
 | 3348 |                 var $closestTD = $input.closest('td').addClass('has-error');
 | 
 | 3349 |                 addTimeout(function () {
 | 
 | 3350 |                     $closestTD.removeClass('has-error');
 | 
 | 3351 |                 }, 5000);
 | 
 | 3352 |                 showAlert('required');
 | 
 | 3353 |                 return false;
 | 
 | 3354 |             }
 | 
 | 3355 |             showLoading('waiting');
 | 
 | 3356 |             element_data.hostName = newHostname;
 | 
 | 3357 |             service.editHostName({
 | 
 | 3358 |                 hostname: element_data.hostName,
 | 
 | 3359 |                 mac: element_data.macAddress
 | 
 | 3360 |             }, function () {
 | 
 | 3361 |                 editingHostname = 0;
 | 
 | 3362 |                 service.getHostNameList({}, function (data) {
 | 
 | 3363 |                     hostNameList = data.devices;
 | 
 | 3364 |                     if (element_data.type == 3) {
 | 
 | 3365 |                         target.fetchBlacklist(function () {
 | 
 | 3366 |                             hideLoading();
 | 
 | 3367 |                             successOverlay();
 | 
 | 3368 |                         });
 | 
 | 3369 |                     } else if (element_data.type == 2) {
 | 
 | 3370 |                         target.fetchAttachedCableDevices(function () {
 | 
 | 3371 |                             hideLoading();
 | 
 | 3372 |                             successOverlay();
 | 
 | 3373 |                         });
 | 
 | 3374 |                     } else if (element_data.type == 1) {
 | 
 | 3375 |                         target.fetchAttachedDevices(function () {
 | 
 | 3376 |                             hideLoading();
 | 
 | 3377 |                             successOverlay();
 | 
 | 3378 |                         });
 | 
 | 3379 |                     }
 | 
 | 3380 |                 });
 | 
 | 3381 |             }, function () {
 | 
 | 3382 |                 errorOverlay();
 | 
 | 3383 |             });
 | 
 | 3384 |         }
 | 
 | 3385 | 
 | 
 | 3386 |         function stationBlockEvent(element_data) {
 | 
 | 3387 |             if (config.HAS_BLACK_AND_WHITE_FILTER && originalData.ACL_mode != '2') {
 | 
 | 3388 |                 return false;
 | 
 | 3389 |             }
 | 
 | 3390 |             if (originalData.macList.split(';').length == 10) {
 | 
 | 3391 |                 showAlert('black_list_max');
 | 
 | 3392 |                 return false;
 | 
 | 3393 |             }
 | 
 | 3394 |             if (originalData.macList.indexOf(element_data.macAddress) != -1) {
 | 
 | 3395 |                 return false;
 | 
 | 3396 |             }
 | 
 | 3397 |             if (element_data.ipAddress == originalData.user_ip) {
 | 
 | 3398 |                 showAlert('black_yourself_tip');
 | 
 | 3399 |                 return false;
 | 
 | 3400 |             }
 | 
 | 3401 |             if (editingHostname) {
 | 
 | 3402 |                 target.cancelAllEditHostNameHandler();
 | 
 | 3403 |             }
 | 
 | 3404 |             showLoading('waiting');
 | 
 | 3405 |             var newHostnameList = originalData.hostnameList == '' ? element_data.hostName : element_data.hostName + ';' + originalData.hostnameList;
 | 
 | 3406 |             var newMacList = originalData.macList == '' ? element_data.macAddress : element_data.macAddress + ';' + originalData.macList;
 | 
 | 3407 |             var params = {
 | 
 | 3408 |                 ACL_mode: '2',
 | 
 | 3409 |                 wifi_hostname_black_list: newHostnameList,
 | 
 | 3410 |                 wifi_mac_black_list: newMacList
 | 
 | 3411 |             };
 | 
 | 3412 |             target.updateMacFilterList(params);
 | 
 | 3413 |         }
 | 
 | 3414 | 
 | 
 | 3415 |     }
 | 
 | 3416 | 
 | 
 | 3417 |     function bindContainer(ws_vm) {
 | 
 | 3418 |         var container = $('#container')[0];
 | 
 | 3419 |         ko.cleanNode(container);
 | 
 | 3420 |         ko.applyBindings(ws_vm, container);
 | 
 | 3421 |     }
 | 
 | 3422 |     function initialize() {
 | 
 | 3423 |         var ws_vm = new staInfoViewMode();
 | 
 | 3424 |         bindContainer(ws_vm);
 | 
 | 3425 |     }
 | 
 | 3426 | 
 | 
 | 3427 |     return {
 | 
 | 3428 |         init: initialize
 | 
 | 3429 |     };
 | 
 | 3430 | });
 | 
 | 3431 | 
 | 
 | 3432 | define("wifi_wps","underscore jquery knockout set service".split(" "),
 | 
 | 3433 |     function (_, $, ko, config, service) {
 | 
 | 3434 | 
 | 
 | 3435 |     var viaWifi = false;
 | 
 | 3436 | 
 | 
 | 3437 |     function WpsViewMode() {
 | 
 | 3438 |         var target = this;
 | 
 | 3439 |         target.hasMultiSSID = config.HAS_MULTI_SSID;
 | 
 | 3440 |         target.hasAPStation = config.AP_STATION_SUPPORT;
 | 
 | 3441 |         target.hasWifiSwitch = config.WIFI_SWITCH_SUPPORT;
 | 
 | 3442 |         target.hasWlanMacfilter = config.HAS_BLACK_AND_WHITE_FILTER;
 | 
 | 3443 | 
 | 
 | 3444 |         target.wpsType = ko.observable('');
 | 
 | 3445 |         target.wpsPin = ko.observable('');
 | 
 | 3446 | 
 | 
 | 3447 |         var state = getWpsState();
 | 
 | 3448 |         target.origin_ap_station_enable = state.ap_station_enable;
 | 
 | 3449 | 
 | 
 | 3450 |         target.wpsFlag = ko.observable(state.wpsFlag);
 | 
 | 3451 |         target.authMode = ko.observable(state.authMode);
 | 
 | 3452 | 
 | 
 | 3453 |         target.radioFlag = ko.observable(state.radioFlag);
 | 
 | 3454 |         target.encrypType = ko.observable(state.encrypType);
 | 
 | 3455 | 
 | 
 | 3456 |         target.mulOption = ko.observable(paintSSIDOption(state));
 | 
 | 3457 |         target.wpsSSID = ko.observable(getSSIDCurrWps(state));
 | 
 | 3458 | 
 | 
 | 3459 |         var infoBasic = service.getWifiBasic();
 | 
 | 3460 |         target.wifi_enable = ko.observable(infoBasic.wifi_enable);
 | 
 | 3461 | 
 | 
 | 3462 |         target.isShowSSIDInfoDiv = ko.observable(false);
 | 
 | 3463 |         if (config.WIFI_SWITCH_SUPPORT) { //软开关
 | 
 | 3464 |             if (infoBasic.wifi_enable == "1") {
 | 
 | 3465 |                 target.isShowSSIDInfoDiv(true);
 | 
 | 3466 |             } else {
 | 
 | 3467 |                 target.isShowSSIDInfoDiv(false);
 | 
 | 3468 |             }
 | 
 | 3469 |         } else {
 | 
 | 3470 |             target.isShowSSIDInfoDiv(true);
 | 
 | 3471 |         }
 | 
 | 3472 |         target.multi_ssid_enable = ko.observable(infoBasic.multi_ssid_enable);
 | 
 | 3473 |         target.origin_multi_ssid_enable = infoBasic.multi_ssid_enable;
 | 
 | 3474 | 
 | 
 | 3475 |         target.save = wpa_save;
 | 
 | 3476 | 
 | 
 | 3477 |         if (state.wpsFlag != '0') {
 | 
 | 3478 |             target.wpsType(state.wpsType == 'PIN' ? 'PIN' : 'PBC');
 | 
 | 3479 |         } else {
 | 
 | 3480 |             target.wpsType('');
 | 
 | 3481 |         }
 | 
 | 3482 | 
 | 
 | 3483 |         target.setMultiSSIDSwitch = function () {
 | 
 | 3484 |             if (target.checkSettings("switch")) {
 | 
 | 3485 |                 return;
 | 
 | 3486 |             }
 | 
 | 3487 | 
 | 
 | 3488 |             function wpsSetSwitch() {
 | 
 | 3489 |                 showLoading('waiting');
 | 
 | 3490 |                 var wps_param = {};
 | 
 | 3491 |                 wps_param.m_ssid_enable = target.multi_ssid_enable();
 | 
 | 3492 |                 if (config.WIFI_SWITCH_SUPPORT) {
 | 
 | 3493 |                     wps_param.wifiEnabled = target.wifi_enable();
 | 
 | 3494 |                 }
 | 
 | 3495 |                 service.setWifiBasicMultiSSIDSwitch(wps_param, function (result) {
 | 
 | 3496 |                     if (result.result == "success") {
 | 
 | 3497 |                         if (!viaWifi) {
 | 
 | 3498 |                             addInterval(wpsReload, 1000);
 | 
 | 3499 |                         } else {
 | 
 | 3500 |                             setTimeout(wpsReloadViaWifi, 15000);
 | 
 | 3501 |                         }
 | 
 | 3502 |                     } else {
 | 
 | 3503 |                         errorOverlay();
 | 
 | 3504 |                     }
 | 
 | 3505 |                 });
 | 
 | 3506 |             }
 | 
 | 3507 | 
 | 
 | 3508 |             var setSwitch = wpsSetSwitch;
 | 
 | 3509 |             var state = service.getStatusInfo();
 | 
 | 3510 |             if (target.wifi_enable() == "1" && config.HAS_MULTI_SSID) {
 | 
 | 3511 |                 if (target.multi_ssid_enable() == "1" && config.AP_STATION_SUPPORT && target.origin_ap_station_enable == "1") {
 | 
 | 3512 |                     if (!state.wifiStatus) {
 | 
 | 3513 |                         showConfirm("multi_ssid_enable_confirm", function () {
 | 
 | 3514 |                             setSwitch();
 | 
 | 3515 |                         });
 | 
 | 3516 |                     } else {
 | 
 | 3517 |                         showConfirm("multi_ssid_enable_confirm2", function () {
 | 
 | 3518 |                             setSwitch();
 | 
 | 3519 |                         });
 | 
 | 3520 |                     }
 | 
 | 3521 |                 } else {
 | 
 | 3522 |                     if (!state.wifiStatus) {
 | 
 | 3523 |                         setSwitch();
 | 
 | 3524 |                     } else {
 | 
 | 3525 |                         showConfirm("wifi_disconnect_confirm2", function () {
 | 
 | 3526 |                             setSwitch();
 | 
 | 3527 |                         });
 | 
 | 3528 |                     }
 | 
 | 3529 |                 }
 | 
 | 3530 |             } else {
 | 
 | 3531 |                 setSwitch();
 | 
 | 3532 |             }
 | 
 | 3533 | 
 | 
 | 3534 |             function wpsReload() {
 | 
 | 3535 |                 var state = service.getWifiBasic();
 | 
 | 3536 |                 if (state.wifi_enable == target.wifi_enable()) {
 | 
 | 3537 |                     successOverlay();
 | 
 | 3538 |                     clearTimer();
 | 
 | 3539 |                     clearValidateMsg();
 | 
 | 3540 |                     service.refreshAPStationStatus();
 | 
 | 3541 |                     initialize();
 | 
 | 3542 |                 }
 | 
 | 3543 |             }
 | 
 | 3544 |             function wpsReloadViaWifi() {
 | 
 | 3545 |                 successOverlay();
 | 
 | 3546 |                 setTimeout(function () {
 | 
 | 3547 |                     window.location.reload();
 | 
 | 3548 |                 }, 1000);
 | 
 | 3549 |                 clearTimer();
 | 
 | 3550 |                 clearValidateMsg();
 | 
 | 3551 |                 service.refreshAPStationStatus();
 | 
 | 3552 |                 initialize();
 | 
 | 3553 |             }
 | 
 | 3554 | 
 | 
 | 3555 |         };
 | 
 | 3556 | 
 | 
 | 3557 |         target.checkSettings = function (ssid) {
 | 
 | 3558 |             var state = getWpsState();
 | 
 | 3559 |             if (state.wpsFlag == '1') {
 | 
 | 3560 |                 showAlert('wps_on_info');
 | 
 | 3561 |                 return true;
 | 
 | 3562 |             }
 | 
 | 3563 |             return false;
 | 
 | 3564 |         };
 | 
 | 3565 | 
 | 
 | 3566 |         function wpa_save() {
 | 
 | 3567 |             var state = getWpsState();
 | 
 | 3568 | 
 | 
 | 3569 |             if (state.radioFlag == '0') {
 | 
 | 3570 |                 showAlert('wps_wifi_off');
 | 
 | 3571 |                 return;
 | 
 | 3572 |             }
 | 
 | 3573 | 
 | 
 | 3574 |             if (state.wpsFlag == '1') {
 | 
 | 3575 |                 showAlert('wps_on_info');
 | 
 | 3576 |                 return true;
 | 
 | 3577 |             }
 | 
 | 3578 | 
 | 
 | 3579 |             if (target.wpsSSID() == "SSID1") {
 | 
 | 3580 |                 var res = (state.AuthMode == "OPEN" && state.encrypType == "WEP")
 | 
 | 3581 |                  || (state.AuthMode == "SHARED" && state.encrypType == "WEP")
 | 
 | 3582 |                  || (state.AuthMode == "WPAPSK" && state.encrypType == "TKIP")
 | 
 | 3583 |                  || (state.AuthMode == "WPAPSK" && state.encrypType == "TKIPCCMP")
 | 
 | 3584 |                  || (state.AuthMode == "WPAPSK" && state.encrypType == "AES")
 | 
 | 3585 |                  || (state.AuthMode == "WPA2PSK" && state.encrypType == "TKIP")
 | 
 | 3586 |                  || (state.AuthMode == "WPAPSKWPA2PSK" && state.encrypType == "TKIP")
 | 
 | 3587 |                  || (state.AuthMode == "WPA3Personal")
 | 
 | 3588 |                  || (state.AuthMode == "WPA2WPA3");
 | 
 | 3589 |                 if (res) {
 | 
 | 3590 |                     showAlert('wps_auth_open');
 | 
 | 3591 |                     return;
 | 
 | 3592 |                 }
 | 
 | 3593 |             } else {
 | 
 | 3594 |                 var resm = (state.m_AuthMode == "OPEN" && state.m_encrypType == "WEP")
 | 
 | 3595 |                  || (state.m_AuthMode == "SHARED" && state.m_encrypType == "WEP")
 | 
 | 3596 |                  || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "TKIP")
 | 
 | 3597 |                  || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "TKIPCCMP")
 | 
 | 3598 |                  || (state.m_AuthMode == "WPAPSK" && state.m_encrypType == "AES")
 | 
 | 3599 |                  || (state.m_AuthMode == "WPA2PSK" && state.m_encrypType == "TKIP")
 | 
 | 3600 |                  || (state.m_AuthMode == "WPAPSKWPA2PSK" && state.m_encrypType == "TKIP")
 | 
 | 3601 |                  || (state.m_AuthMode == "WPA3Personal")
 | 
 | 3602 |                  || (state.m_AuthMode == "WPA2WPA3");
 | 
 | 3603 |                 if (resm) {
 | 
 | 3604 |                     showAlert('wps_auth_open');
 | 
 | 3605 |                     return;
 | 
 | 3606 |                 }
 | 
 | 3607 |             }
 | 
 | 3608 | 
 | 
 | 3609 |             var wpsSSID;
 | 
 | 3610 |             var wpsIndex;
 | 
 | 3611 |             if (target.wpsSSID() != "SSID1") {
 | 
 | 3612 |                 wpsSSID = state.multiSSID;
 | 
 | 3613 |                 wpsIndex = 2;
 | 
 | 3614 |             } else {
 | 
 | 3615 |                 wpsSSID = state.ssid;
 | 
 | 3616 |                 wpsIndex = 1;
 | 
 | 3617 |             }
 | 
 | 3618 | 
 | 
 | 3619 |             var basic = service.getWifiBasic();
 | 
 | 3620 |             if (wpsSSID == basic.m_SSID && wpsIndex == 2) {
 | 
 | 3621 |                 if (basic.m_broadcast == '1') {
 | 
 | 3622 |                     showAlert('wps_ssid_broadcast_disable');
 | 
 | 3623 |                     return;
 | 
 | 3624 |                 }
 | 
 | 3625 |             } else if (wpsSSID == basic.SSID && wpsIndex == 1) {
 | 
 | 3626 |                 if (basic.broadcast == '1') {
 | 
 | 3627 |                     showAlert('wps_ssid_broadcast_disable');
 | 
 | 3628 |                     return;
 | 
 | 3629 |                 }
 | 
 | 3630 |             }
 | 
 | 3631 | 
 | 
 | 3632 |             showLoading('waiting');
 | 
 | 3633 |             var wps_param = {};
 | 
 | 3634 |             wps_param.wpsType = target.wpsType();
 | 
 | 3635 |             wps_param.wpsSSID = wpsSSID;
 | 
 | 3636 |             wps_param.wpsIndex = wpsIndex;
 | 
 | 3637 |             wps_param.wpsPin = getWpsPin(target.wpsPin());
 | 
 | 3638 | 
 | 
 | 3639 |             service.openWps(wps_param, function (result) {
 | 
 | 3640 |                 if (result.result != "success") {
 | 
 | 3641 |                     errorOverlay();
 | 
 | 3642 |                 } else {
 | 
 | 3643 |                     target.wpsPin('');
 | 
 | 3644 |                     clearValidateMsg();
 | 
 | 3645 |                     successOverlay();
 | 
 | 3646 |                 }
 | 
 | 3647 |             });
 | 
 | 3648 |         }
 | 
 | 3649 | 
 | 
 | 3650 |     }
 | 
 | 3651 | 
 | 
 | 3652 |     function getWpsPin(value) {
 | 
 | 3653 |         if (value.length != 9) {
 | 
 | 3654 |             return value;
 | 
 | 3655 |         } else {
 | 
 | 3656 |             return value.substring(0, 4) + value.substring(5);
 | 
 | 3657 |         }
 | 
 | 3658 |     }
 | 
 | 3659 | 
 | 
 | 3660 |     function getWpsState() {
 | 
 | 3661 |         return service.getWpsInfo();
 | 
 | 3662 |     }
 | 
 | 3663 | 
 | 
 | 3664 |     function paintSSIDOption(info) {
 | 
 | 3665 |         var show_opt = [];
 | 
 | 3666 |         show_opt.push(new Option(info.ssid, "SSID1"));
 | 
 | 3667 |         if (info.ssidEnable == "1") {
 | 
 | 3668 |             show_opt.push(new Option(info.multiSSID, "SSID2"));
 | 
 | 3669 |         }
 | 
 | 3670 |         return show_opt;
 | 
 | 3671 |     }
 | 
 | 3672 | 
 | 
 | 3673 |     //检查当前是否通过wifi登录webui
 | 
 | 3674 |     function checkAccessMode() {
 | 
 | 3675 |         service.getParams({
 | 
 | 3676 |             nv: 'user_ip_addr'
 | 
 | 3677 |         }, function (dataIp) {
 | 
 | 3678 |             service.getParams({
 | 
 | 3679 |                 nv: 'station_list'
 | 
 | 3680 |             }, function (dataList) {
 | 
 | 3681 |                 viaWifi = isWifiConnected(dataIp.user_ip_addr, dataList.station_list);
 | 
 | 3682 |             });
 | 
 | 3683 |         });
 | 
 | 3684 |     }
 | 
 | 3685 |     function bindContainer(wpsVm) {
 | 
 | 3686 |         var container = $('#container');
 | 
 | 3687 |         ko.cleanNode(container[0]);
 | 
 | 3688 |         ko.applyBindings(wpsVm, container[0]);
 | 
 | 3689 | 
 | 
 | 3690 |         addTimeout(function () {
 | 
 | 3691 |             checkAccessMode();
 | 
 | 3692 |         }, 600);
 | 
 | 3693 | 
 | 
 | 3694 |         $('#wpsForm').validate({
 | 
 | 3695 |             submitHandler: function () {
 | 
 | 3696 |                 wpsVm.save();
 | 
 | 3697 |             },
 | 
 | 3698 |             rules: {
 | 
 | 3699 |                 txtPin: {
 | 
 | 3700 |                     "wps_pin_validator": true
 | 
 | 3701 |                 }
 | 
 | 3702 |             }
 | 
 | 3703 |         });
 | 
 | 3704 | 
 | 
 | 3705 |         $('#frmWifiSwitch').validate({
 | 
 | 3706 |             submitHandler: function () {
 | 
 | 3707 |                 wpsVm.setMultiSSIDSwitch();
 | 
 | 3708 |             }
 | 
 | 3709 |         });
 | 
 | 3710 |     }
 | 
 | 3711 |     function getSSIDCurrWps(info) {
 | 
 | 3712 |         if (info.ssid != info.multiSSID) {
 | 
 | 3713 |             return info.wpsSSID == info.multiSSID ? "SSID2" : "SSID1";
 | 
 | 3714 |         } else {
 | 
 | 3715 |             if (info.wifi_wps_index == '2') {
 | 
 | 3716 |                 return "SSID2";
 | 
 | 3717 |             } else {
 | 
 | 3718 |                 return "SSID1";
 | 
 | 3719 |             }
 | 
 | 3720 |         }
 | 
 | 3721 |     }
 | 
 | 3722 |     //视图初始化
 | 
 | 3723 |     function initialize() {
 | 
 | 3724 |         var wpsVm = new WpsViewMode();
 | 
 | 3725 |         bindContainer(wpsVm);
 | 
 | 3726 |     }
 | 
 | 3727 | 
 | 
 | 3728 |     return {
 | 
 | 3729 |         init: initialize
 | 
 | 3730 |     };
 | 
 | 3731 | });
 | 
 | 3732 | 
 |