add_dns_rec.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. //
  3. // Updates database dns record dynamically, showing its full domain path
  4. App.Actions.DB.update_dns_record_hint = function(elm, hint) {
  5. // clean hint
  6. if (hint.trim() == '') {
  7. $(elm).parent().find('.hint').html('');
  8. }
  9. // set domain name without rec in case of @ entries
  10. if (hint == '@') {
  11. hint = '';
  12. }
  13. // dont show pregix if domain name = rec value
  14. if (hint == GLOBAL.DNS_REC_PREFIX + '.') {
  15. hint = '';
  16. }
  17. // add dot at the end if needed
  18. if (hint != '' && hint.slice(-1) != '.') {
  19. hint += '.';
  20. }
  21. $(elm).parent().find('.hint').text(hint + GLOBAL.DNS_REC_PREFIX);
  22. }
  23. //
  24. // listener that triggers dns record name hint updating
  25. App.Listeners.DB.keypress_dns_rec_entry = function() {
  26. var ref = $('input[name="v_rec"]');
  27. var current_rec = ref.val();
  28. if (current_rec.trim() != '') {
  29. App.Actions.DB.update_dns_record_hint(ref, current_rec);
  30. }
  31. ref.bind('keypress input', function(evt) {
  32. clearTimeout(window.frp_usr_tmt);
  33. window.frp_usr_tmt = setTimeout(function() {
  34. var elm = $(evt.target);
  35. App.Actions.DB.update_dns_record_hint(elm, $(elm).val());
  36. }, 100);
  37. });
  38. }
  39. //
  40. // Page entry point
  41. // Trigger listeners
  42. App.Listeners.DB.keypress_dns_rec_entry();