Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="page-width">
- <h1 class="small--text-center">{{ page.title }}</h1>
- <div class="content-block">
- <div class="rte rte--indented-images">
- {{ page.content }}
- <h3 id="test">IBO Speed</h3>
- <h5>(feet per second)</h5>
- <input type="text" id="ibospeed" />
- <h3>Draw Weight</h3>
- <h5>(pounds)</h5>
- <input type="text" id="drawweight" />
- <h3>Draw Length</h3>
- <h5>(inches)</h5>
- <input type="text" id="drawlength" />
- <h3>Arrow Weight</h3>
- <h5>(grains)</h5>
- <input type="text" id="arrowweight" />
- <br><br>
- <button onclick="calc()">Calculate</button>
- <h2>Calculated Arrow Speed</h2>
- <label id="result">Calculation here.</label>
- </div>
- </div>
- {% section 'featured-products-subsection' %}
- </div>
- <script>
- function calc() {
- //Bring the values from the text boxes into variables.
- //The parseFloat will take the first number/decimal it finds as long as
- //the variable starts with a numeric character.
- var ibo = parseFloat(document.getElementById("ibospeed").value);
- var drw = parseFloat(document.getElementById("drawweight").value);
- var drl = parseFloat(document.getElementById("drawlength").value);
- var arw = parseFloat(document.getElementById("ibospeed").value);
- var flag = false;
- //If any of the text boxes weren't a valid number, then the variables value
- //would become NaN. If there is a number greater than 1 in an if() statement
- //it will evaluate to true, and if it is NaN its false. We want to change the flag
- //if it is NaN though so the value checked is flipped with !.
- if(!ibo) {
- flag = true;
- }
- else if(!drw) {
- flag = true;
- }
- else if(!drl) {
- flag = true;
- }
- else if(!arw) {
- flag = true;
- }
- //If the flag was set, display a message and hope that the user fixes it.
- //Otherwise, start performing calculations.
- if(flag) {
- document.getElementById("result").innerHTML = "Please make sure everything is a number, then hit the calculate again!";
- }
- else {
- var dla = 0;
- var dwa = 0;
- var kezero = 0;
- var awdw = (arw/drw).toPrecision(10);
- var keone = 0;
- //dla
- switch(drl) {
- case ((drl >= 18) && (drl <= 28)):
- dla = (-8 * drl) + 244;
- break;
- case (drl <= 32):
- dla = (-10 * drl) + 300;
- break;
- default:
- document.getElementById("result").innerHTML = "Sorry, Draw Length needs to be between 18 and 32 for the calculation to work.";
- return;
- };
- //dwa
- switch(drw) {
- case ((drw >= 14.75) && (drw <= 50)):
- dwa = ((-28.2 * drw) / 35.25) + (2079.75 / 35.25);
- break;
- case (drw <= 60):
- dwa = ((-9 * drw) / 10) + 64;
- break;
- case (drw <= 70):
- dwa = (-drw) + 70;
- break;
- case (drw <= 80):
- dwa = ((-9 * drw) / 10) + 63;
- break;
- case (drw <= 90):
- dwa = ((-8 * drw) / 10) + 55;
- break;
- default:
- document.getElementById("result").innerHTML = "Sorry, Draw Weight needs to be between 14.75 and 90 for the calculation to work.";
- return;
- };
- //ke0
- kezero = (drw * 5) * (((ibo-dla-dwa)^2)/450800).toPrecision(10);
- //ke1
- switch(awdw) {
- case ((awdw >= 4) && (awdw <= 5.9)):
- keone = kezero + 0;
- break;
- case (awdw <= 12):
- keone = kezero + ((5.4 * awdw) / 6) - (31.86 / 6);
- break;
- case (awdw <= 18):
- keone = kezero + ((2.2 * awdw) / 5.9) + (6.066 / 5.9);
- break;
- case (awdw <= 68):
- keone = kezero + 0;
- break;
- default:
- document.getElementById("result").innerHTML = "Sorry, something went wrong with the calculation, please contact Robert!";
- return;
- }
- document.getElementById("result").innerHTML = keone;
- }
- };
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement