transfer.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* $Id: transfer.js 2937 2007-04-20 18:42:51Z b4rt $ */
  2. /**
  3. * validateSettings
  4. */
  5. function validateSettings(type) {
  6. var msg = "";
  7. switch (type) {
  8. case 'torrent':
  9. if (isNumber(document.theForm.max_upload_rate.value) == false) {
  10. msg = msg + "* Max Upload Rate must be a valid number.\n";
  11. document.theForm.max_upload_rate.focus();
  12. }
  13. if (isNumber(document.theForm.max_download_rate.value) == false) {
  14. msg = msg + "* Max Download Rate must be a valid number.\n";
  15. document.theForm.max_download_rate.focus();
  16. }
  17. if (isNumber(document.theForm.max_uploads.value) == false) {
  18. msg = msg + "* Max # Uploads must be a valid number.\n";
  19. document.theForm.max_uploads.focus();
  20. }
  21. if (isNumber(document.theForm.maxcons.value) == false) {
  22. msg = msg + "* Max Cons must be a valid number.\n" ;
  23. }
  24. if (isNumber(document.theForm.sharekill.value) == false) {
  25. msg = msg + "* Keep seeding until Sharing % must be a valid number.\n";
  26. document.theForm.sharekill.focus();
  27. }
  28. if (isNumber(document.theForm.rerequest.value) == false) {
  29. msg = msg + "* Rerequest Interval must have a valid number.\n";
  30. document.theForm.rerequest.focus();
  31. }
  32. if (document.theForm.rerequest.value < 10) {
  33. msg = msg + "* Rerequest Interval must be 10 or greater.\n";
  34. document.theForm.rerequest.focus();
  35. }
  36. if ((isNumber(document.theForm.minport.value) == false) || (isNumber(document.theForm.maxport.value) == false)) {
  37. msg = msg + "* Port Range must have valid numbers.\n";
  38. document.theForm.minport.focus();
  39. }
  40. if ((document.theForm.maxport.value > 65535) || (document.theForm.minport.value > 65535)) {
  41. msg = msg + "* Port can not be higher than 65535.\n";
  42. document.theForm.minport.focus();
  43. }
  44. if ((document.theForm.maxport.value < 0) || (document.theForm.minport.value < 0)) {
  45. msg = msg + "* Can not have a negative number for port value.\n";
  46. document.theForm.minport.focus();
  47. }
  48. if (document.theForm.maxport.value < document.theForm.minport.value) {
  49. msg = msg + "* Port Range is not valid.\n";
  50. document.theForm.minport.focus();
  51. }
  52. break;
  53. case 'wget':
  54. if (isNumber(document.theForm.max_download_rate.value) == false) {
  55. msg = msg + "* Max Download Rate must be a valid number.\n";
  56. document.theForm.max_download_rate.focus();
  57. }
  58. break;
  59. case 'nzb':
  60. if (isNumber(document.theForm.max_download_rate.value) == false) {
  61. msg = msg + "* Max Download Rate must be a valid number.\n";
  62. document.theForm.max_download_rate.focus();
  63. }
  64. if (isNumber(document.theForm.maxcons.value) == false) {
  65. msg = msg + "* Max Cons must be a valid number.\n" ;
  66. }
  67. break;
  68. }
  69. if (msg != "") {
  70. alert("Please check the following:\n\n" + msg);
  71. return false;
  72. } else {
  73. return true;
  74. }
  75. }