Advertisement
Guest User

Untitled

a guest
Nov 4th, 2011
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. <script type="text/javascript" language="javascript">
  2.  
  3. function validate() {
  4. var elmnt_id;
  5. elmnt_id = document.getElementById('custom');
  6. if (elmnt_id.selected) {
  7. if (is_blank(document.form1.s_port_s)) {
  8. document.form1.s_port_s.focus();
  9. return fail("You must provide a starting port and (optionally) an ending one!");
  10. }
  11. else if (!is_valid_Port(document.form1.s_port_s.value)) {
  12. document.form1.s_port_s.focus();
  13. return fail("Ports are between 1 and 65535!");
  14. }
  15. else if (!is_blank(document.form1.s_port_e) && !is_valid_Port(document.form1.s_port_e.value)) {
  16. document.form1.s_port_e.focus();
  17. return fail("Ports are between 1 and 65535!");
  18. }
  19. else if (!is_blank(document.form1.s_port_e)) {
  20. var sport_s = parseInt(document.form1.s_port_s.value,10);
  21. var sport_e = parseInt(document.form1.s_port_e.value,10);
  22. if (sport_s > sport_e) {
  23. document.form1.s_port_s.focus();
  24. return fail("Start port values must be less or equal than ending port values!");
  25. }
  26. }
  27. }
  28. elmnt_id = document.getElementById('host_list');
  29. if (elmnt_id.selected) {
  30. if (is_blank(document.form1.in_host_list)) {
  31. document.form1.in_host_list.focus();
  32. return fail("You must provide a comma-separated list of remote hosts/IPs!");
  33. }
  34. //else {
  35. //var host_array = document.form1.in_host_list.value.split(",");
  36. //var host_id = 0;
  37. //while (host_id < host_array.length) {
  38. //alert(host_array[host_id]);
  39. //host_id += 1;
  40. //}
  41. //}
  42. }
  43. if (!is_valid_IP(document.form1.d_ip.value)) {
  44. document.form1.d_ip.focus();
  45. return fail("Invalid IP address!");
  46. }
  47. elmnt_id = document.getElementById('diff');
  48. return true;
  49. }
  50.  
  51. function change_protocol(field) {
  52. switch ( field.value ) {
  53. case 'custom':
  54. document.form1.s_type.disabled = false;
  55. document.form1.s_port_s.disabled = false;
  56. document.form1.s_port_e.disabled = false;
  57. document.form1.s_type.value = 'both';
  58. document.form1.s_port_s.value = '';
  59. document.form1.s_port_e.value = '';
  60. set_visible('on_proto_port_1', 1);
  61. set_visible('on_proto_port_2', 1);
  62. set_visible('on_dest_port', 1);
  63. set_visible('off_dest_port', 0);
  64. document.form1.d_port.disabled = false;
  65. document.form1.d_port.value = '';
  66. break;
  67. default:
  68. document.form1.s_type.value = '';
  69. document.form1.s_port_s.value = '';
  70. document.form1.s_port_e.value = '';
  71. document.form1.s_type.disabled = true;
  72. document.form1.s_port_s.disabled = true;
  73. document.form1.s_port_e.disabled = true;
  74. set_visible('on_proto_port_1', 0);
  75. set_visible('on_proto_port_2', 0);
  76. set_visible('on_dest_port', 0);
  77. set_visible('off_dest_port', 1);
  78. elmnt_id = document.getElementById('same');
  79. elmnt_id.checked = true;
  80. document.form1.d_port.value = '';
  81. document.form1.d_port.disabled = true;
  82. break;
  83. }
  84. document.getElementById("same").checked = true;
  85. change_r_port(document.getElementById("same"));
  86. }
  87.  
  88. function change_in_host(field) {
  89. switch ( field.value ) {
  90. case 'host_list':
  91. document.form1.in_host_list.disabled = false;
  92. break;
  93. default:
  94. document.form1.in_host_list.value = '';
  95. document.form1.in_host_list.disabled = true;
  96. break;
  97. }
  98. }
  99.  
  100. function change_r_port(field) {
  101. if (field.value == 'same') {
  102. document.form1.d_port.disabled = true;
  103. }
  104. else {
  105. document.form1.d_port.disabled = false;
  106. }
  107. return true;
  108. }
  109.  
  110. function change_multiple(field) {
  111. if (field && field.value != '') {
  112. set_visible('on_dest_port', 0);
  113. } else {
  114. set_visible('on_dest_port', 1);
  115. }
  116. }
  117.  
  118. function init() {
  119. var elmnt_id;
  120. if (elmnt_id = document.getElementById("")) {
  121. elmnt_id.selected = true;
  122. }
  123. if (elmnt_id = document.getElementById("custom")) {
  124. elmnt_id.selected = true;
  125. }
  126. change_protocol(document.form1.protocol);
  127. if ("custom" == 'custom') {
  128. document.form1.s_type.value = "both";
  129. document.form1.s_port_s.value = "";
  130. document.form1.s_port_e.value = "";
  131. }
  132. if (elmnt_id = document.getElementById("host_all")) {
  133. elmnt_id.selected = true;
  134. }
  135. change_in_host(document.form1.in_host);
  136. document.form1.d_ip.value = "";
  137. document.form1.in_host_list.value = "";
  138. if (elmnt_id = document.getElementById("same")) {
  139. elmnt_id.checked = true;
  140. change_r_port(elmnt_id);
  141. }
  142. document.form1.d_port.value = "";
  143. if (document.getElementById('s_port_s').value != '') {
  144. change_multiple(document.getElementById('s_port_e'));
  145. }
  146. return true;
  147. }
  148.  
  149. </script>
  150.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement