From 1e7655604937454ee49c1128776eeed18555b940 Mon Sep 17 00:00:00 2001 From: Julien VAUBOURG Date: Sat, 2 May 2015 15:59:42 +0200 Subject: [PATCH] Max ssids and delete features implemented --- TODO | 2 -- sources/public/css/style.css | 10 +++++++ sources/public/js/custom.js | 46 +++++++++++++++++++++++++++++++++ sources/views/_ssid.html.php | 4 +++ sources/views/settings.html.php | 4 +-- 5 files changed, 62 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 24e9198..f58949b 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ * Translate PHP interface in French * multissid -** WEB: limit to N ssid max depending on the antenna specs -** WEB: add ssid delete feature ** WEB: update is_connected_through_hotspot feature ** WEB: autocomplete ipv4 nat prefix (.242, .243, .244, etc) ** WEB: check if ipv6 delgated prefixes and ipv4 nat prefixes are unique diff --git a/sources/public/css/style.css b/sources/public/css/style.css index 8674676..3e31aed 100644 --- a/sources/public/css/style.css +++ b/sources/public/css/style.css @@ -152,3 +152,13 @@ div.tabs { div.tabs a { outline: none; } + +div.deletessid { + text-align: center; + padding: 10px; +} + +div.deletessid button { + display: block; + width: 100%; +} diff --git a/sources/public/js/custom.js b/sources/public/js/custom.js index 1c8449e..cc1b69d 100644 --- a/sources/public/js/custom.js +++ b/sources/public/js/custom.js @@ -52,6 +52,45 @@ function dropDownClick() { input.val($(this).text()); } +function updateNbSsidRemaining() { + multissid = $('#devlist .active').data('multissid'); + current = $('.ssid').length; + remaining = multissid - current; + + $('.ssid').each(function(i) { + if(i >= multissid) { + $(this).removeClass('panel-default'); + $(this).addClass('panel-danger'); + + } else { + $(this).removeClass('panel-danger'); + $(this).addClass('panel-default'); + } + }); + + $('.ssid').find('.deletessid').hide(); + $('.ssid').last().find('.deletessid').show(); + $('.ssid').first().find('.deletessid').hide(); + + if(remaining <= 0) { + $('#newssid').attr('disabled', true); + $('#newssid').removeClass('btn-success'); + $('#newssid').addClass('btn-danger'); + + } else { + $('#newssid').attr('disabled', false); + $('#newssid').removeClass('btn-danger'); + $('#newssid').addClass('btn-success'); + } + + $('#newssid span').text(remaining); +} + +function deleteClick() { + $(this).closest('.ssid').remove(); + updateNbSsidRemaining(); +} + $(document).ready(function() { $('.btn-group').button(); $('[data-toggle="tooltip"]').tooltip(); @@ -143,6 +182,7 @@ $(document).ready(function() { }); clone.find('[data-toggle="tooltip"]').tooltip(); + clone.find('.deletessid').click(deleteClick); clone.find('input[type=text]').each(function() { if($(this).attr('name').match('dns')) { @@ -170,7 +210,13 @@ $(document).ready(function() { }); $('#ssids').append(clone); + + updateNbSsidRemaining(); }); + + $('.deletessid').click(deleteClick); + + updateNbSsidRemaining(); }); $(document).keydown(function(e) { diff --git a/sources/views/_ssid.html.php b/sources/views/_ssid.html.php index 794a009..c2955cf 100644 --- a/sources/views/_ssid.html.php +++ b/sources/views/_ssid.html.php @@ -91,5 +91,9 @@ + + diff --git a/sources/views/settings.html.php b/sources/views/settings.html.php index 8b8f134..0360144 100644 --- a/sources/views/settings.html.php +++ b/sources/views/settings.html.php @@ -83,7 +83,7 @@
-
@@ -121,7 +121,7 @@ - +