home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 1999 July / www_07_1999.iso / prez / amiga / KidHTML1_25.lha / KidHTML1.25 / Script / armorcalc.js < prev    next >
Text File  |  1998-08-25  |  2KB  |  79 lines

  1.  
  2.  
  3.  
  4. <!-- TWO STEPS TO INSTALL ARMOR PENETRATION CALCULATOR:
  5.  
  6.    1.  Paste the specified coding into the HEAD of the HTML document
  7.    2.  Put the last code into the BODY of your HTML document  -->
  8.  
  9. <!-- STEP ONE: Copy this code into the HEAD your HTML document  -->
  10.         
  11.  
  12.  
  13. <SCRIPT LANGUAGE="JavaScript">
  14. <!-- Original:  Cut-N-Paste JavaScript from ISN Toolbox
  15.  
  16. <!-- This script and many more are available online from -->
  17. <!-- The JavaScript Source!! http://javascriptsource.com -->
  18.  
  19. <!-- Begin
  20. var c1;
  21. var c2;
  22. var convert_to_degrees = (2*3.1415)/360.0;
  23. function compute_pen(c1,c2,r,ang) {
  24. if (is_number(r)) {
  25. new_pen = Math.pow((c1*Math.exp(-c2*range3)),0.7);
  26. if (is_number(ang)) {
  27. ang = parseInt(ang);
  28. ang = ang*convert_to_degrees;
  29. new_pen = new_pen*Math.pow(Math.cos(ang),1.5);
  30. }
  31. return Math.round(new_pen);
  32. else {
  33. return "";
  34.    }
  35. }
  36. function is_number(a_string) {
  37. tc = a_string.charAt(0);
  38. if (tc == "0" || tc == "1" || tc == "2" || tc == "3" ||  tc == "4" || tc == "5" || tc == "6" || tc == "7" || tc == "8" || tc == "9") {
  39. return true;
  40. else {
  41. return false;
  42.    }
  43. }
  44. function compute_constants(form) {
  45. range1 =form.inputrange1.value;
  46. range2 =form.inputrange2.value;
  47. pen1 = form.pen1.value;
  48. pen2 =form.pen2.value;
  49. if (is_number(range1) && is_number(range2) && is_number(pen1) && is_number(pen2)) {
  50. range1 = parseInt(range1);
  51. range2 = parseInt(range2);
  52. pen1 = parseInt(pen1);
  53. pen2 = parseInt(pen2);
  54. ang1 = form.ang1.value;
  55. ang2 = form.ang2.value;
  56. if (is_number(ang1)) {
  57. ang1 = parseInt(ang1);
  58. ang1 = ang1 * convert_to_degrees;
  59. pen1 = pen1/Math.pow(Math.cos(ang1),1.5);
  60. }
  61. if (is_number(ang2)) {
  62. ang2 = parseInt(ang2);
  63. ang2 = ang2 * convert_to_degrees;
  64. pen2 = pen2/Math.pow(Math.cos(ang2),1.5);
  65. }            
  66. c2 = Math.log(Math.pow(pen2,1.4286)/Math.pow(pen1,1.4286))/(-range2 + range1);
  67. temp = (range1*c2);
  68. c1 = Math.pow(pen1,1.4286) * Math.exp(temp);
  69. return true;      
  70. else {
  71. alert("You need to enter two different ranges and the penetration at those ranges.");
  72. return false;
  73.    }
  74. }
  75. function armorpen(form)
  76.