common.ui.js 745 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Create key for an entry.
  3. *
  4. * @access public
  5. * @return void
  6. */
  7. function createKey()
  8. {
  9. var chars = '0123456789abcdefghiklmnopqrstuvwxyz'.split('');
  10. var key = '';
  11. for(var i = 0; i < 32; i ++)
  12. {
  13. key += chars[Math.floor(Math.random() * chars.length)];
  14. }
  15. $('#key').val(key);
  16. }
  17. /**
  18. * Disable ip if allIP is checked.
  19. *
  20. * @param event $event
  21. * @access public
  22. * @return void
  23. */
  24. function toggleAllIP(event)
  25. {
  26. if($(event.target).prop('checked'))
  27. {
  28. $('#ip').attr('disabled', 'disabled');
  29. $('#ip').after("<input class='form-group hidden' type='text' id='ip' name='ip'>");
  30. }
  31. else
  32. {
  33. $('#ip').removeAttr('disabled');
  34. $('input.hidden#ip').remove();
  35. }
  36. }