-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.html
93 lines (88 loc) · 3.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<meta charset="utf-8">
<title>resisto.rs</title>
<link rel="stylesheet" href="styles.css">
<!--[if lt IE 9]><script src="html5shiv.js"><![endif]-->
<meta name="viewport" content="initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<h1>resisto.rs</h1>
<input id="resistor-query" placeholder="e.g. 3.3K">
<label class="resistor-query-label" for="resistor-query">Ω</label>
<div id="resistor-result" style="display:none">
<h2>four bands</h2>
<div class="resistor-diagram resistor-diagram-4">
<div id="resistor-stripe-4-1" class="resistor-stripe"></div>
<div id="resistor-stripe-4-2" class="resistor-stripe"></div>
<div id="resistor-stripe-4-3" class="resistor-stripe"></div>
<div id="resistor-stripe-4-4" class="resistor-stripe"> <br> </div>
<div class="resistor-stripe-tolerance resistor-stripe" style="color: #000; background-color: #cfb53b">gold<br>±5%</div>
</div>
<h2>five bands</h2>
<div class="resistor-diagram resistor-diagram-5">
<div id="resistor-stripe-5-1" class="resistor-stripe"></div>
<div id="resistor-stripe-5-2" class="resistor-stripe"></div>
<div id="resistor-stripe-5-3" class="resistor-stripe"></div>
<div id="resistor-stripe-5-4" class="resistor-stripe"></div>
<div class="resistor-stripe-tolerance resistor-stripe" style="color: #fff; background-color: #964b00">brown<br>±1%</div>
</div>
<h2>surface mount</h2>
<div id="resistor-smt-3" class="resistor-smt"></div>
<!--
<div id="resistor-smt-4" class="resistor-smt"></div>
<div id="resistor-smt-eia96" class="resistor-smt"></div>
-->
</div>
<footer>
by <a href="http://joewalnes.com" target="_blank">Joe Walnes</a>
(<a href="https://twitter.com/joewalnes" target="_blank">@joewalnes</a>).
<a href="https://github.com/joewalnes/resisto.rs/" target="_blank">fork me on github</a>.
</footer>
<script src="analytics.js"></script>
<script src="resistors.js"></script>
<script>
var queryEl = document.getElementById('resistor-query'),
resultEl = document.getElementById('resistor-result');
function showStripes(colors, prefix) {
for (var i = 0; i < colors.length; i++) {
var color = colors[i];
var stripeEl = document.getElementById('resistor-stripe-' + prefix + '-' + (i + 1));
stripeEl.style.backgroundColor = color.hex;
stripeEl.style.color = color.label;
var text = color.name + '<br>';
if (i == colors.length - 1) {
if (color.multiplier !== undefined) {
text += '×' + color.multiplier;
} else {
text += ' ';
}
} else {
text += color.figure;
}
stripeEl.innerHTML = text;
}
}
queryEl.onchange = queryEl.onkeyup = function() {
location.hash = encodeURIComponent(queryEl.value);
var result = resistors.query(queryEl.value);
if (result) {
resultEl.style.display = 'block';
showStripes(result.colors4, '4');
showStripes(result.colors5, '5');
document.getElementById('resistor-smt-3').innerHTML = result.smt3;
//document.getElementById('resistor-smt-4').innerHTML = result.smt4;
//document.getElementById('resistor-smt-eia96').innerHTML = result.smtEia96;
} else {
resultEl.style.display = 'none';
}
};
if (location.hash) {
queryEl.value = decodeURIComponent(location.hash.substring(1));
queryEl.onchange();
}
window.onhashchange = function() {
queryEl.value = decodeURIComponent(location.hash.substring(1));
queryEl.onchange();
};
queryEl.focus();
</script>