custom.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* VPN Client app for YunoHost
  2. * Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
  3. * Contribute at https://github.com/labriqueinternet/piratebox_ynh
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. $(document).ready(function() {
  19. $('.btn-group').button();
  20. $('[data-toggle="tooltip"]').tooltip();
  21. $('.switch').bootstrapToggle();
  22. $('#save').click(function() {
  23. $(this).prop('disabled', true);
  24. $('#save-loading').show();
  25. $('#form').submit();
  26. });
  27. $('#status .close').click(function() {
  28. $(this).parent().hide();
  29. });
  30. $('#statusbtn').click(function() {
  31. if($('#status-loading').is(':hidden')) {
  32. $('#status').hide();
  33. $('#status-loading').show();
  34. $.ajax({
  35. url: '?/status',
  36. }).done(function(data) {
  37. $('#status-loading').hide();
  38. $('#status-text').html('<ul>' + data + '</ul>');
  39. $('#status').show('slow');
  40. });
  41. }
  42. });
  43. $('#service_enabled').change(function() {
  44. if($('#service_enabled').parent().hasClass('off')) {
  45. $('.enabled').hide('slow');
  46. } else {
  47. $('.enabled').show('slow');
  48. }
  49. });
  50. $('.dropdown-menu li').click(function() {
  51. var menu = $(this).parent();
  52. var items = menu.children();
  53. var button = menu.prev();
  54. var input = button.prev();
  55. items.removeClass('active');
  56. $(this).addClass('active');
  57. button.text($(this).text());
  58. button.append(' <span class="caret"></span>');
  59. input.val($(this).data('device-id'));
  60. });
  61. });