custom.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Wifi Hotspot app for YunoHost
  2. * Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
  3. * Contribute at https://github.com/jvaubourg/hotspot_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. $('.fileinput').click(function() {
  22. var realinputid = '#' + $(this).attr('id').replace(/_chooser.*/, '');
  23. $(realinputid).click();
  24. });
  25. $('input[type="file"]').change(function() {
  26. var choosertxtid = '#' + $(this).attr('id') + '_choosertxt';
  27. $(choosertxtid).val($(this).val().replace(/^.*[\/\\]/, ''));
  28. });
  29. $('.dropdown-menu li').click(function() {
  30. var menu = $(this).parent();
  31. var items = menu.children();
  32. var button = menu.prev();
  33. var input = button.prev();
  34. items.removeClass('active');
  35. $(this).addClass('active');
  36. button.text($(this).text());
  37. button.append(' <span class="caret"></span>');
  38. input.attr('value', $(this).text());
  39. });
  40. $('.switch').bootstrapToggle();
  41. $('#save').click(function() {
  42. $(this).prop('disabled', true);
  43. $('#save-loading').show();
  44. $('#form').submit();
  45. });
  46. $('#saveconfirm').click(function() {
  47. $(this).hide();
  48. $('#saveconfirmation').show();
  49. });
  50. $('#status .close').click(function() {
  51. $(this).parent().hide();
  52. });
  53. $('#statusbtn').click(function() {
  54. if($('#status-loading').is(':hidden')) {
  55. $('#status').hide();
  56. $('#status-loading').show();
  57. $.ajax({
  58. url: '?/status',
  59. }).done(function(data) {
  60. $('#status-loading').hide();
  61. $('#status-text').html('<ul>' + data + '</ul>');
  62. $('#status').show('slow');
  63. });
  64. }
  65. });
  66. $('#wifiparty').click(function() {
  67. $('#wifiparty_screen').show('slow');
  68. });
  69. $('#wifiparty_zoomin_ssid').mousedown(function() {
  70. $('#wifiparty_ssid').css('fontSize', (parseInt($('#wifiparty_ssid').css('fontSize')) + 5) + "px");
  71. });
  72. $('#wifiparty_zoomout_ssid').mousedown(function() {
  73. $('#wifiparty_ssid').css('fontSize', (parseInt($('#wifiparty_ssid').css('fontSize')) - 5) + "px");
  74. });
  75. $('#wifiparty_zoomin_passphrase').mousedown(function() {
  76. $('#wifiparty_passphrase').css('fontSize', (parseInt($('#wifiparty_passphrase').css('fontSize')) + 7) + "px");
  77. });
  78. $('#wifiparty_zoomout_passphrase').mousedown(function() {
  79. $('#wifiparty_passphrase').css('fontSize', (parseInt($('#wifiparty_passphrase').css('fontSize')) - 7) + "px");
  80. });
  81. $('#wifiparty_close').click(function() {
  82. $('#wifiparty_screen').hide();
  83. });
  84. $('#wifi_secure').change(function() {
  85. if($('#wifi_secure').parent().hasClass('off')) {
  86. $('.secure').hide('slow');
  87. } else {
  88. $('.secure').show('slow');
  89. }
  90. });
  91. $('#service_enabled').change(function() {
  92. if($('#service_enabled').parent().hasClass('off')) {
  93. $('.enabled').hide('slow');
  94. } else {
  95. $('.enabled').show('slow');
  96. }
  97. });
  98. });
  99. $(document).keydown(function(e) {
  100. if(e.keyCode == 27) {
  101. $('#wifiparty_close').click();
  102. }
  103. });