Difference between revisions of "MediaWiki:Common.js"

From BEASTX Wiki
Jump to: navigation, search
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
var textinput = null;
 
  
 
$(function () {
 
$(function () {
        textinput = $('#mw-bllength');
+
 
$('#mw-beastx-pitchcalc').html('<input type="button" id="myButton" onclick="myFunction()" value="Calculate">');
+
$('#mw-beastx-sixcalc').html('<input type="button" id="myButton" onclick="calcSixDegrees()" value="Calculate">');
 +
$('#mw-beastx-pitchcalc').html('<input type="button" id="myButton" onclick="calcPitch()" value="Calculate">');
 
}());
 
}());
  
function myFunction() {
+
function calcSixDegrees() {
if (textinput != null)
+
{   
+
 
       var nBlLength = Number(document.getElementById("mw-bllength").value);
 
       var nBlLength = Number(document.getElementById("mw-bllength").value);
 
       nBlLength = nBlLength * Math.sin(6 * Math.PI / 180);
 
       nBlLength = nBlLength * Math.sin(6 * Math.PI / 180);
 
       nBlLength = Math.round(nBlLength);
 
       nBlLength = Math.round(nBlLength);
 
       $('#mw-result').html("Distance: <b>" + nBlLength + "mm</b>");
 
       $('#mw-result').html("Distance: <b>" + nBlLength + "mm</b>");
}
+
};
 +
 
 +
function calcPitch() {
 +
      var nBlLength = Number(document.getElementById("mw-bllength-pitch").value);
 +
      var nPitchDeg = Number(document.getElementById("mw-degrees-pitch").value);
 +
      nBlLength = nBlLength * Math.sin(nPitchDeg  * Math.PI / 180);
 +
      nBlLength = Math.round(nBlLength);
 +
      $('#mw-result').html("Distance: <b>" + nBlLength + "mm</b>");
 
};
 
};

Revision as of 15:16, 3 June 2020

/* Any JavaScript here will be loaded for all users on every page load. */

$(function () {

	$('#mw-beastx-sixcalc').html('<input type="button" id="myButton" onclick="calcSixDegrees()" value="Calculate">');
	$('#mw-beastx-pitchcalc').html('<input type="button" id="myButton" onclick="calcPitch()" value="Calculate">');
}());

function calcSixDegrees() {
      var nBlLength = Number(document.getElementById("mw-bllength").value);
      nBlLength = nBlLength * Math.sin(6 * Math.PI / 180);
      nBlLength = Math.round(nBlLength);
      $('#mw-result').html("Distance: <b>" + nBlLength + "mm</b>");
};

function calcPitch() {
      var nBlLength = Number(document.getElementById("mw-bllength-pitch").value);
      var nPitchDeg = Number(document.getElementById("mw-degrees-pitch").value);
      nBlLength = nBlLength * Math.sin(nPitchDeg  * Math.PI / 180);
      nBlLength = Math.round(nBlLength);
      $('#mw-result').html("Distance: <b>" + nBlLength + "mm</b>");
};