You are viewing an old version of this page. Return to the latest version.
Difference between revisions of "MediaWiki:Common.js"
Line 29: | Line 29: | ||
{ | { | ||
$('#speedcalc_root').html('<div id="SpeedCalc" class="table_small no_print"><h3 id="calculator" class="table_small"><i class="fa fa-tachometer fa-2x" aria-hidden="true" style="color: #CC0000"></i> Robot Speed Calculator</h3><p><i>* If the red fields in the form below are not populated, please refresh your browser.</i></p> <ul> <li><label for="rpm">Motor Output Speed</label> <input type="text" name="rpm" value="190"> <span>rpm</span></li> <li><label for="ratio">Reduction*</label> <input type="text" name="ratio" value="1"> <span>ratio</span></li> <li><label for="diameter">Wheel Diameter</label> <input type="text" name="diameter" value="6"> <span>inches</span></li> <li><label for="circ">Wheel Circumference</label> <input type="text" name="circ" disabled="disabled"> <span>inches</span></li> <li><label for="speedIPM">Speed</label> <input type="text" name="speedIPM" disabled="disabled"> <span>inches per minute</span></li> <li><label for="speedFPM">Speed</label> <input type="text" name="speedFPM" disabled="disabled"> <span>feet per minute</span></li> <li><label for="speedMPH">Speed</label> <input type="text" name="speedMPH" disabled="disabled"> <span>miles per hour</span></li> <li><label for="speedMPM">Speed</label> <input type="text" name="speedMPM" disabled="disabled"> <span>meters per minute</span></li> <li><label for="speedKPH">Speed</label> <input type="text" name="speedKPH" disabled="disabled"> <span>km per hour</span></li> <li>* This is the reduction from the output of the gear motor to the wheel. If direct drive, reduction = 1. If your reduction is 1:2 put in 0.5.</li> </ul> </div> '); | $('#speedcalc_root').html('<div id="SpeedCalc" class="table_small no_print"><h3 id="calculator" class="table_small"><i class="fa fa-tachometer fa-2x" aria-hidden="true" style="color: #CC0000"></i> Robot Speed Calculator</h3><p><i>* If the red fields in the form below are not populated, please refresh your browser.</i></p> <ul> <li><label for="rpm">Motor Output Speed</label> <input type="text" name="rpm" value="190"> <span>rpm</span></li> <li><label for="ratio">Reduction*</label> <input type="text" name="ratio" value="1"> <span>ratio</span></li> <li><label for="diameter">Wheel Diameter</label> <input type="text" name="diameter" value="6"> <span>inches</span></li> <li><label for="circ">Wheel Circumference</label> <input type="text" name="circ" disabled="disabled"> <span>inches</span></li> <li><label for="speedIPM">Speed</label> <input type="text" name="speedIPM" disabled="disabled"> <span>inches per minute</span></li> <li><label for="speedFPM">Speed</label> <input type="text" name="speedFPM" disabled="disabled"> <span>feet per minute</span></li> <li><label for="speedMPH">Speed</label> <input type="text" name="speedMPH" disabled="disabled"> <span>miles per hour</span></li> <li><label for="speedMPM">Speed</label> <input type="text" name="speedMPM" disabled="disabled"> <span>meters per minute</span></li> <li><label for="speedKPH">Speed</label> <input type="text" name="speedKPH" disabled="disabled"> <span>km per hour</span></li> <li>* This is the reduction from the output of the gear motor to the wheel. If direct drive, reduction = 1. If your reduction is 1:2 put in 0.5.</li> </ul> </div> '); | ||
− | + | ||
}); | }); |
Revision as of 19:05, 23 March 2021
/* Any JavaScript here will be loaded for all users on every page load. */
$("input:enabled").change(function()
{
calcValues();
});
function calcValues ()
{
var rpm = $("input[name='rpm']").val();
var ratio = $("input[name='ratio']").val();
var cir = $("input[name='diameter']").val() * Math.PI;
var ipm = rpm * ratio * cir;
var fpm = ipm / 12.0;
var mph = fpm * 60 / 5280;
var mpm = fpm * 0.3048;
var kph = mpm * 60 / 1000;
$("input[name='circ']").val(cir.toFixed(2));
$("input[name='speedIPM']").val(ipm.toFixed(2));
$("input[name='speedFPM']").val(fpm.toFixed(2));
$("input[name='speedMPH']").val(mph.toFixed(2));
$("input[name='speedMPM']").val(mpm.toFixed(2));
$("input[name='speedKPH']").val(kph.toFixed(2));
}
$(function()
{
$('#speedcalc_root').html('<div id="SpeedCalc" class="table_small no_print"><h3 id="calculator" class="table_small"><i class="fa fa-tachometer fa-2x" aria-hidden="true" style="color: #CC0000"></i> Robot Speed Calculator</h3><p><i>* If the red fields in the form below are not populated, please refresh your browser.</i></p> <ul> <li><label for="rpm">Motor Output Speed</label> <input type="text" name="rpm" value="190"> <span>rpm</span></li> <li><label for="ratio">Reduction*</label> <input type="text" name="ratio" value="1"> <span>ratio</span></li> <li><label for="diameter">Wheel Diameter</label> <input type="text" name="diameter" value="6"> <span>inches</span></li> <li><label for="circ">Wheel Circumference</label> <input type="text" name="circ" disabled="disabled"> <span>inches</span></li> <li><label for="speedIPM">Speed</label> <input type="text" name="speedIPM" disabled="disabled"> <span>inches per minute</span></li> <li><label for="speedFPM">Speed</label> <input type="text" name="speedFPM" disabled="disabled"> <span>feet per minute</span></li> <li><label for="speedMPH">Speed</label> <input type="text" name="speedMPH" disabled="disabled"> <span>miles per hour</span></li> <li><label for="speedMPM">Speed</label> <input type="text" name="speedMPM" disabled="disabled"> <span>meters per minute</span></li> <li><label for="speedKPH">Speed</label> <input type="text" name="speedKPH" disabled="disabled"> <span>km per hour</span></li> <li>* This is the reduction from the output of the gear motor to the wheel. If direct drive, reduction = 1. If your reduction is 1:2 put in 0.5.</li> </ul> </div> ');
});