// ==UserScript== // @name BMI and converter // @namespace Stanscript // @description Calculates BMI, Converts from lb to kg, in to cm. // @include *oscarEncounter/oscarMeasurements/SetupMeasurements.do?groupName=Vitals // @require http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js // @grant none // ==/UserScript== var input1=document.createElement("input"); input1.type="button"; input1.value="Calculate BMI"; input1.onclick = ButtonFunction1; input1.setAttribute("style", "font-size:9px;position:fixed;top:60px;left:3px;;color:green;"); document.body.appendChild(input1); function ButtonFunction1(){ vHTin = $("input[name='value(inputValue-11)']").val(); vHTcm = $("input[name='value(inputValue-12)']").val(); vWTlb = $("input[name='value(inputValue-19)']").val(); vWTkg = $("input[name='value(inputValue-20)']").val(); if(vWTlb){ vWTkg = (Number(vWTlb)/2.2).toFixed(1); $("input[name='value(inputValue-20)']").val(+vWTkg); $("input[name='value(comments-19)']").val(+vWTkg+ " kg");} if(vWTkg){ vWTlb = (Number(vWTkg)*2.2).toFixed(0); $("input[name='value(inputValue-19)']").val(+vWTlb); $("input[name='value(comments-20)']").val(+vWTlb+ " lbs");} if(vHTin){ vHTcm = (Number(vHTin)*2.54).toFixed(1); $("input[name='value(inputValue-12)']").val(+vHTcm); $("input[name='value(comments-11)']").val(vHTcm + " cm");} if(vHTcm){ vHTin = (Number(vHTcm)/2.54).toFixed(1); var realFeet = vHTin/12; var feet = Math.floor(realFeet); var inches = Math.round((realFeet - feet) * 12); $("input[name='value(inputValue-11)']").val(+vHTin); $("input[name='value(comments-12)']").val(+vHTin+" inches"+" or "+ feet + " ft "+inches + " in");} vBMI = vWTkg/(vHTcm*0.01*vHTcm*0.01); $("input[name='value(inputValue-3)']").val(+vBMI.toFixed(1)); } $("input[name='value(inputValue-11)']").change(ButtonFunction1); $("input[name='value(inputValue-12)']").change(ButtonFunction1); $("input[name='value(inputValue-19)']").change(ButtonFunction1); $("input[name='value(inputValue-20)']").change(ButtonFunction1);