<div id="main"><!-- [et_pb_line_break_holder] --> <div class="titleBlock"><h2>Trailer Safety Chain Calculator</h2></div><!-- [et_pb_line_break_holder] --> <div class="content"><!-- [et_pb_line_break_holder] --> <p>Check to see if your trailer chains are safely configured!</p><!-- [et_pb_line_break_holder] --> <p>Take these measurements of your trailer setup and click the "Calculate" button. We'll let you know if your trailer is safe.</p>
<div class="image measureImg"></div><!-- [et_pb_line_break_holder] --> <p class="description">Descriptions:</p><!-- [et_pb_line_break_holder] --> <ul class="description"><!-- [et_pb_line_break_holder] --> <li>h<sub>1</sub> - height to trailer chain attachment</li><!-- [et_pb_line_break_holder] --> <li>h<sub>2</sub> - height to bottom of trailer tongue</li><!-- [et_pb_line_break_holder] --> <li>h<sub>3</sub> - height to vehicle chain attachment</li><!-- [et_pb_line_break_holder] -->
<p class="description">Descriptions:</p><!-- [et_pb_line_break_holder] --> <ul class="description"><!-- [et_pb_line_break_holder] --> <li>W<sub>1</sub> - width between chain attachments at the tongue</li><!-- [et_pb_line_break_holder] --> <li>W<sub>2</sub> - width between chain attachments at the receiver</li><!-- [et_pb_line_break_holder] -->
<p class="description">Descriptions:</p><!-- [et_pb_line_break_holder] --> <ul class="description"><!-- [et_pb_line_break_holder] --> <li>L<sub>chain</sub> - length of chain from connection point on the trailer tongue when pulled straight</li><!-- [et_pb_line_break_holder] --> </ul><!-- [et_pb_line_break_holder] --> <div><!-- [et_pb_line_break_holder] --> h<sub>1</sub><br><!-- [et_pb_line_break_holder] --> <input type="number" class="numberIN inputSlct" name="h1" min="0" max="50" value="19" step="0.0625"> inches<br><br><!-- [et_pb_line_break_holder] --> h<sub>2</sub><br><!-- [et_pb_line_break_holder] --> <input type="number" class="numberIN inputSlct" name="h2" min="0" max="50" value="21" step="0.0625"> inches<br><br><!-- [et_pb_line_break_holder] --> h<sub>3</sub><br><!-- [et_pb_line_break_holder] --> <input type="number" class="numberIN inputSlct" name="h3" min="0" max="50" value="18" step="0.0625"> inches<br><br><!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --> W<sub>1</sub><br><!-- [et_pb_line_break_holder] --> <input type="number" class="numberIN inputSlct" name="Wtng" min="0" max="50" value="3" step="0.0625"> inches<br><br><!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --> W<sub>2</sub><br><!-- [et_pb_line_break_holder] --> <input type="number" class="numberIN inputSlct" name="Wtng" min="0" max="50" value="3" step="0.0625"> inches<br><br><!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --> L<sub>chain</sub><br><!-- [et_pb_line_break_holder] --> <input type="number" class="numberIN inputSlct" name="Lchain" min="1" max="100" value="18" step="0.0625"> inches<br><br><!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --> <input class="button" type="button" id="calcBtn" value="Calculate"><br><br><!-- [et_pb_line_break_holder] --> </div><!-- [et_pb_line_break_holder] --> <p>Results:</p><!-- [et_pb_line_break_holder] --> <p id="outputTxt">No calcuations made yet!</p><!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> <p>Always make sure to cross the chains when you hook up your trailer.</p><!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> </div><!-- [et_pb_line_break_holder] --> </div><!-- [et_pb_line_break_holder] --><script><!-- [et_pb_line_break_holder] -->function runCalculation(valuesIN) {<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> var h1 = valuesIN[0],<!-- [et_pb_line_break_holder] --> h2 = valuesIN[1],<!-- [et_pb_line_break_holder] --> h3 = valuesIN[2],<!-- [et_pb_line_break_holder] --> Wtng = valuesIN[3],<!-- [et_pb_line_break_holder] --> Wrecvr = valuesIN[4],<!-- [et_pb_line_break_holder] --> Lchain = valuesIN[5],<!-- [et_pb_line_break_holder] --> rangeVals = [[1, 50], [1, 50], [1, 50], [1, 50], [1, 50], [1, 100]],<!-- [et_pb_line_break_holder] --> invalidInputFlag = false,<!-- [et_pb_line_break_holder] --> invalidString = "Invalid Input ",<!-- [et_pb_line_break_holder] --> j = 0,<!-- [et_pb_line_break_holder] --> D1 = 0,<!-- [et_pb_line_break_holder] --> D2 = 0,<!-- [et_pb_line_break_holder] --> temp1 = 0,<!-- [et_pb_line_break_holder] --> temp2 = 0,<!-- [et_pb_line_break_holder] --> Margin = 0,<!-- [et_pb_line_break_holder] --> output = document.getElementById("outputTxt");<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> //STEP 1 CHECK VALIDITY OF OUTPUTS<!-- [et_pb_line_break_holder] --> for (j = 0; j < 6; j++) {<!-- [et_pb_line_break_holder] --> if (valuesIN[j] < rangeVals[j][0] || valuesIN[j] > rangeVals[j][1]) {<!-- [et_pb_line_break_holder] --> invalidInputFlag = true;<!-- [et_pb_line_break_holder] --> break;<!-- [et_pb_line_break_holder] --> }<!-- [et_pb_line_break_holder] --> }<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> if (invalidInputFlag === false) {<!-- [et_pb_line_break_holder] --> if (h1 >= h2) {<!-- [et_pb_line_break_holder] --> D1 = h1 - h2;<!-- [et_pb_line_break_holder] --> }<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --> if (h1 >= h2) {<!-- [et_pb_line_break_holder] --> D2 = Wtng;<!-- [et_pb_line_break_holder] --> } else {<!-- [et_pb_line_break_holder] --> D2 = Math.sqrt(Math.pow(Wtng, 2) + Math.pow((h2 - h1), 2));<!-- [et_pb_line_break_holder] --> }<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --> temp1 = Math.pow((Lchain - (D1 + D2)), 2);<!-- [et_pb_line_break_holder] --> temp2 = Math.pow(((Wrecvr - Wtng) / 2), 2);<!-- [et_pb_line_break_holder] --> Margin = h3 - Math.sqrt(temp1 - temp2);<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --> //console.log(Margin);<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --> if (Margin > 0) {<!-- [et_pb_line_break_holder] --> output.innerHTML = "Trailer chains are a safe length";<!-- [et_pb_line_break_holder] --> output.style.color = "#00db5b";<!-- [et_pb_line_break_holder] --> } else {<!-- [et_pb_line_break_holder] --> output.innerHTML = "THIS TRAILER IS NOT SAFE! Buy a link lock!!";<!-- [et_pb_line_break_holder] --> output.style.color = "#F00";<!-- [et_pb_line_break_holder] --> }<!-- [et_pb_line_break_holder] --> } else {<!-- [et_pb_line_break_holder] --> output.style.color = "#FFE100";<!-- [et_pb_line_break_holder] --> switch (j) {<!-- [et_pb_line_break_holder] --> case 0:<!-- [et_pb_line_break_holder] --> invalidString += "h1 must be between " + rangeVals[0][0] + " and " + rangeVals[0][1] + " inches.";<!-- [et_pb_line_break_holder] --> output.innerHTML = invalidString;<!-- [et_pb_line_break_holder] --> break;<!-- [et_pb_line_break_holder] --> case 1:<!-- [et_pb_line_break_holder] --> invalidString += "h2 must be between " + rangeVals[1][0] + " and " + rangeVals[1][1] + " inches.";<!-- [et_pb_line_break_holder] --> output.innerHTML = invalidString;<!-- [et_pb_line_break_holder] --> break;<!-- [et_pb_line_break_holder] --> case 2:<!-- [et_pb_line_break_holder] --> invalidString += "h3 must be between " + rangeVals[2][0] + " and " + rangeVals[2][1] + " inches.";<!-- [et_pb_line_break_holder] --> output.innerHTML = invalidString;<!-- [et_pb_line_break_holder] --> break;<!-- [et_pb_line_break_holder] --> case 3:<!-- [et_pb_line_break_holder] --> invalidString += "Wtongue must be between " + rangeVals[3][0] + " and " + rangeVals[3][1] + " inches.";<!-- [et_pb_line_break_holder] --> output.innerHTML = invalidString;<!-- [et_pb_line_break_holder] --> break;<!-- [et_pb_line_break_holder] --> case 4:<!-- [et_pb_line_break_holder] --> invalidString += "Wreceiver must be between " + rangeVals[4][0] + " and " + rangeVals[4][1] + " inches.";<!-- [et_pb_line_break_holder] --> output.innerHTML = invalidString;<!-- [et_pb_line_break_holder] --> break;<!-- [et_pb_line_break_holder] --> case 5:<!-- [et_pb_line_break_holder] --> invalidString += "Lchain must be between " + rangeVals[5][0] + " and " + rangeVals[5][1] + " inches.";<!-- [et_pb_line_break_holder] --> output.innerHTML = invalidString;<!-- [et_pb_line_break_holder] --> break; <!-- [et_pb_line_break_holder] --> default:<!-- [et_pb_line_break_holder] --> break;<!-- [et_pb_line_break_holder] --> } <!-- [et_pb_line_break_holder] --> }<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] -->}<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->function init() {<!-- [et_pb_line_break_holder] --> var calcBTN = document.getElementById("calcBtn");<!-- [et_pb_line_break_holder] --> document.getElementById("calcBtn").addEventListener("click", function () {<!-- [et_pb_line_break_holder] --> // step 1 --- grab inputs<!-- [et_pb_line_break_holder] --> var inputsDOM = document.getElementsByClassName("inputSlct"),<!-- [et_pb_line_break_holder] --> j = 0,<!-- [et_pb_line_break_holder] --> inputs = [];<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> for (j = 0; j < inputsDOM.length; j++) { <!-- [et_pb_line_break_holder] --> inputs[j] = (inputsDOM[j].value) * 1;<!-- [et_pb_line_break_holder] --> }<!-- [et_pb_line_break_holder] --> <!-- [et_pb_line_break_holder] --> // step 2 --- run calculation<!-- [et_pb_line_break_holder] --> runCalculation(inputs);<!-- [et_pb_line_break_holder] --> });<!-- [et_pb_line_break_holder] -->}<!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] --><!-- [et_pb_line_break_holder] -->window.onload = init();<!-- [et_pb_line_break_holder] --></script>