<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link href='https://fonts.googleapis.com/css?family=Bitter' rel='stylesheet' type='text/css'>
<?!= HtmlService.createHtmlOutputFromFile('CSS_Main_Form').getContent(); ?>
</head>
<body>
<?!= HtmlService.createHtmlOutputFromFile('HTML_Body').getContent(); ?>
</body>
<?!= HtmlService.createHtmlOutputFromFile('JS_Main_Form').getContent(); ?>
<div id="idSpnr" class="spinner"></div>
</html>
<form name="ResistorCodes">
<table align="center">
<tr>
<th>Band 1</th>
<th>Band 2</th>
<th>Band 3</th>
<th>Band 4</th>
<tr>
<td bgcolor="black"> </td>
<td align="center" bgcolor="black"><input type="radio" name="band2" value="0"></td>
<td align="center" bgcolor="black"><input type="radio" name="band3" value="1"></td>
<td bgcolor="black"> </td>
</tr>
<tr>
<td align="center" bgcolor="brown"><input type="radio" name="band1" value="1"></td>
<td align="center" bgcolor="brown"><input type="radio" name="band2" value="1"></td>
<td align="center" bgcolor="brown"><input type="radio" name="band3" value="10"></td>
<td align="center" bgcolor="brown"><input type="radio" name="band4" value="1"></td>
</tr>
<tr>
<td align="center" bgcolor="red"><input type="radio" name="band1" value="2"></td>
<td align="center" bgcolor="red"><input type="radio" name="band2" value="2"></td>
<td align="center" bgcolor="red"><input type="radio" name="band3" value="100"></td>
<td align="center" bgcolor="red"><input type="radio" name="band4" value="2"></td>
</tr>
<tr>
<td align="center" bgcolor="orange"><input type="radio" name="band1" value="3"></td>
<td align="center" bgcolor="orange"><input type="radio" name="band2" value="3"></td>
<td align="center" bgcolor="orange"><input type="radio" name="band3" value="1000"></td>
<td bgcolor="orange"> </td>
</tr>
<tr>
<td align="center" bgcolor="yellow"><input type="radio" name="band1" value="4"></td>
<td align="center" bgcolor="yellow"><input type="radio" name="band2" value="4"></td>
<td align="center" bgcolor="yellow"><input type="radio" name="band3" value="10000"></td>
<td bgcolor="yellow"> </td>
</tr>
<tr>
<td align="center" bgcolor="green"><input type="radio" name="band1" value="5"></td>
<td align="center" bgcolor="green"><input type="radio" name="band2" value="5"></td>
<td align="center" bgcolor="green"><input type="radio" name="band3" value="100000"></td>
<td align="center" bgcolor="green"><input type="radio" name="band4" value="0.5"></td>
</tr>
<tr>
<td align="center" bgcolor="blue"><input type="radio" name="band1" value="6"></td>
<td align="center" bgcolor="blue"><input type="radio" name="band2" value="6"></td>
<td align="center" bgcolor="blue"><input type="radio" name="band3" value="1000000"></td>
<td align="center" bgcolor="blue"><input type="radio" name="band4" value="0.25"></td>
</tr>
<tr>
<td align="center" bgcolor="violet"><input type="radio" name="band1" value="7"></td>
<td align="center" bgcolor="violet"><input type="radio" name="band2" value="7"></td>
<td align="center" bgcolor="violet"><input type="radio" name="band3" value="10000000"></td>
<td align="center" bgcolor="violet"><input type="radio" name="band4" value="0.10"></td>
</tr>
<tr>
<td align="center" bgcolor="gray"><input type="radio" name="band1" value="8"></td>
<td align="center" bgcolor="gray"><input type="radio" name="band2" value="8"></td>
<td bgcolor="gray"> </td>
<td align="center" bgcolor="gray"><input type="radio" name="band4" value="0.05"></td>
</tr>
<tr>
<td align="center" bgcolor="white"><input type="radio" name="band1" value="9"></td>
<td align="center" bgcolor="white"><input type="radio" name="band2" value="9"></td>
<td bgcolor="white"> </td>
<td bgcolor="white"> </td>
</tr>
<tr>
<td bgcolor="silver"> </td>
<td bgcolor="silver"> </td>
<td align="center" bgcolor="silver"><input type="radio" name="band3" value="0.01"></td>
<td align="center" bgcolor="silver"><input type="radio" name="band4" value="10"></td>
</tr>
<tr>
<td bgcolor="gold"> </td>
<td bgcolor="gold"> </td>
<td align="center" bgcolor="gold"><input type="radio" name="band3" value="0.1"></td>
<td align="center" bgcolor="gold"><input type="radio" name="band4" value="5"></td>
</tr>
<tr>
<td align="center" colspan="4"><output name="rCode"></output></td>
</tr>
<tr>
<td align="center" colspan="2"><output name="toleranceMinus"></output></td>
<td align="center" colspan="2"><output name="tolerancePlus"></output></td>
</tr>
</table><br>
<input type="button" value="Calculate" onClick="calculate()">
<input type="reset" value="Reset"><br>
</form>
<script type="text/javascript">
function calculate()
{
// initialize the resistor bands vairables.
var band1, band2, band3, band4;
// copy in the user input from the ResistorCodes form.
band1 = Number(document.ResistorCodes.band1.value);
band2 = Number(document.ResistorCodes.band2.value);
band3 = Number(document.ResistorCodes.band3.value);
band4 = Number(document.ResistorCodes.band4.value);
// Do the math for the results to be passed back to the HTML form.
var ohms, kohms, mohms, gohms;
ohms = (band1 + "" + band2)*(band3);
kohms = (((band1 + "" + band2)*(band3))/1000);
mohms = (((band1 + "" + band2)*(band3))/100000);
gohms = (((band1 + "" + band2)*(band3))/10000000);
// Check if band multiplier value is in speicific ranges for KΩ, MΩ, and GΩ values.
// If it is in those ranges adjust the output for readability.
if(band3 < 100)
{
document.ResistorCodes.rCode.value = ohms + "Ω";
document.ResistorCodes.toleranceMinus.value = (ohms - ((ohms * band4) / 100)).toFixed(2) + "Ω";
document.ResistorCodes.tolerancePlus.value = (ohms + ((ohms * band4) / 100)).toFixed(2) + "Ω";
}
else if(band3 < 100000)
{
document.ResistorCodes.rCode.value = kohms + "KΩ";
document.ResistorCodes.toleranceMinus.value = (kohms - ((kohms * band4) / 100)).toFixed(2) + "KΩ";
document.ResistorCodes.tolerancePlus.value = (kohms + ((kohms * band4) / 100)).toFixed(2) + "KΩ";
}
else if(band3 < 10000000)
{
document.ResistorCodes.rCode.value = mohms + "MΩ";
document.ResistorCodes.toleranceMinus.value = (mohms - ((mohms * band4) / 100)).toFixed(2) + "MΩ";
document.ResistorCodes.tolerancePlus.value = (mohms + ((mohms * band4) / 100)).toFixed(2) + "MΩ";
}
else
{
document.ResistorCodes.rCode.value = gohms + "GΩ";
document.ResistorCodes.toleranceMinus.value = (gohms - ((gohms * band4) / 100)).toFixed(2) + "GΩ";
document.ResistorCodes.tolerancePlus.value = (gohms + ((gohms * band4) / 100)).toFixed(2) + "GΩ";
}
}
</script>
<style type="text/css">
body
{
text-align: center;
}
table
{
width:80%;
padding:30px;
margin: auto;
background: #FFF;
border-radius: 10px;
-webkit-border-radius:10px;
-moz-border-radius: 10px;
box-shadow: 0px 0px 10px #524f49;
-moz-box-shadow: 0px 0px 10px #524f49;
-webkit-box-shadow: 0px 0px 10px #524f49;
}
th, td
{
border: 1px solid #257C9E;
}
input[type="button"], input[type="reset"]
{
background: #73AD21;
padding: 8px 20px 8px 20px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
color: #fff;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.12);
font: 100% Arial, Helvetica, sans-serif;
-moz-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
-webkit-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.17);
border: 1px solid #257C9E;
font-size: 100%; /* button size */
-moz-appearance: none;
-webkit-appearance: none;
}
input[type="button"]:hover, input[type="reset"]:hover
{
background: #2A6881;
-moz-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
-webkit-box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
box-shadow: inset 0px 2px 2px 0px rgba(255, 255, 255, 0.28);
-moz-appearance: none;
-webkit-appearance: none;
}
</style>