/*************************************************************** AP Setup AUTHOR(S): Matthew Smith / BOSE ***************************************************************/ //////////////////////////////////////////////////////////////// //ON READY //////////////////////////////////////////////////////////////// var host = 'http://' + document.location.hostname; //var host = 'http://10.18.99.115'; var obj_ajax; var networks = []; var curType; var show_manual; // debug version $(document).ready(function(){ $("a.manual_link").click(function(){ showManual(); }); }); $(window).load(function() { setupListeners(); getNetworks(); //showPane('theform'); }); // a function that is "activating" the manual form view //& by that disables theform form view // password fields are hidden by default function showManual() { show_manual = true; updateGabboWifiUI(); // the default in manual set up is "no security" so password fields will be hidden $('#section_password_manual').hide() } // a method for the manual setup, making sure that typing password option only // appears for secured networks and disappears otherwise and does not affect the layout if gone. function showPasswordManual() { curType="manual"; // the alue of the selected option var curSelected = $('#security').val(); if(curSelected == "none") { //to hide the password field & lock image $('#section_password_manual').hide(); } else { //to show the password field & lock image $('#section_password_manual').show(); $('#checkbox_manual').show(); } } function setupListeners() { $('#manual').on('submit', function(e) { e.preventDefault(); // cancelling the default activity of 'submit' submitForm(); }); $('#theform').on('submit', function(e) { e.preventDefault(); // cancelling the default activity of 'submit' submitForm(); }); } function showPane(pane) { $('.panes').hide(); $('#'+pane).fadeIn(); } function getNetworks() { showPane('loading'); // loading animation obj_ajax = $.ajax({ url: host + ":8090/performWirelessSiteSurvey", // timeout: 10000, type: "POST", data: "", contentType: "text/xml", success: function(data) { showPane('theform'); showPane('manual'); parseNetworks(data); }, error: function(jqXHR, status) { showPane('error'); console.log(status); } }); } function parseNetworks(data) { networks = []; console.log(data); var tmpArr = $(data).find('item'); console.log(tmpArr); if(tmpArr.length > 0) { for (i = 0; i < tmpArr.length; i++) { var tmpNet = []; var $tmpArr = $(tmpArr[i]); console.log(tmpArr[i]); tmpNet[0] = $tmpArr.attr('ssid'); //name tmpNet[1] = $tmpArr.attr('signalStrength'); //strength tmpNet[2] = $tmpArr.find('securityTypes').find('type').eq(0).text(); //security tmpNet[3] = tmpNet[0]; //full name tmpNet[4] = null; //cipher if(tmpNet[0] == '') {} // do not add blank string else if(tmpNet[0].substr(0, 5) == 'Bose ') {} // do not add Bose network and do not break from loop else if(networks.length > 0 && networks[networks.length - 1][0] == tmpNet[0] && networks[networks.length - 1][2] == tmpNet[2]) {} //de-dupe else networks.push(tmpNet); } updateGabboWifiUI(); } else { getNetworks(); } } function updateGabboWifiUI() { console.log('updateGabboWifiUI'); curType = "normal"; var optionStr = ''; var preselect = 0; for(var i = 0; i < networks.length; i++) { optionStr += '