custom.js 2.3 KB

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