-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
94 lines (76 loc) · 2.06 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
94
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>si-tools</title>
<script src="si.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootswatch/3.2.0/simplex/bootstrap.min.css" rel="stylesheet">
<!--[if lt IE 8]>
<script src="//cdn.jsdelivr.net/json3/3.3.2/json3.min.js"></script>
<![endif]-->
</head>
<body>
<div class="jumbotron">
<div class="container">
<h1>si-tools</h1>
<p>Parsing and Formatting of SI numbers.</p>
</div>
</div>
<div class="container">
<h2>Formatting</h2>
<div class="form-inline">
<div class="input-group">
<label>Number</label>
<input id="formatNumber" type="text" value="0.000005" onkeyup="demoFormat()" class="form-control">
</div>
<div class="input-group">
<label>Unit</label>
<input id="formatUnit" type="text" value="m" onkeyup="demoFormat()" class="form-control">
</div>
<div class="input-group">
<label>Separator</label>
<input id="formatSeparator" type="text" value=" " onkeyup="demoFormat()" class="form-control">
</div>
</div>
<br />
<label>Output</label>
<pre id="formatOutput">formatOutput</pre>
</div>
<br />
<hr />
<br />
<div class="container">
<h2>Parsing</h2>
<label>Input</label>
<input id="demo1input" type="text" value="1.21GW" onkeyup="demo1()" class="form-control">
<br />
<label>Output</label>
<pre id="demo1pre">demo</pre>
</div>
<br />
<hr />
<br />
<div class="container">
<a href="https://github.com/stereosteve/si-tools">code</a>
</div>
<br />
<br />
<br />
<script>
function demoFormat() {
var formatted = ' '
var number = parseFloat(formatNumber.value, 10)
var unit = formatUnit.value
var separator = formatSeparator.value
if (number) formatted = SI.format(number, unit, separator)
formatOutput.innerText = formatted
}
function demo1() {
var input = demo1input.value
var parsed = SI.parse(input)
demo1pre.innerText = JSON.stringify(parsed, undefined, 2)
}
demo1()
demoFormat()
</script>
</body>
</html>