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