forked from LHNCBC/ucum-lhc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
382 lines (369 loc) · 19.5 KB
/
demo.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<!DOCTYPE html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-75410768-4"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-75410768-4');
</script>
<link rel="canonical" href="https://ucum.nlm.nih.gov/ucum-lhc/demo.html" />
<title>UCUM-LHC Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Unified Code of Units of Measure (UCUM) LHC unit code validator and conversion calculator">
<meta name="keywords" content="UCUM,LHC,Unit Codes,Units of Measure">
<link rel="stylesheet" href="https://lforms-service.nlm.nih.gov/autocomplete-lhc-versions/16.0.1/autocomplete-lhc_jQueryUI.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="demo-dist/ucumDemo.min.css" rel="stylesheet"/>
</head>
<body id="demobody" onhashchange="demoPkg.UcumDemo.getInstance().checkTabSwitch();"
onload="demoPkg.UcumDemo.getInstance().buildAdvancedSettings();" >
<!-- page header -->
<div id="header">
<a href="http://lhncbc.nlm.nih.gov" id="logo"
title="Lister Hill National Center for Biomedical Communications">
<img src="demo-dist/assets/images/lhncbc.jpg"
alt="Lister Hill National Center for Biomedical Communications" />
</a>
<div id="siteNameBox">
<a href="index.html"><span id=siteName>UCUM-LHC</span><br>
<span id=tagline>A Unified Code for Units of Measure Software Library
from the National Library of Medicine</span></a>
</div>
</div> <!-- end page header -->
<!-- links to other ucum pages -->
<div>
<a href="https://ucum.nlm.nih.gov">UCUM Resources</a>
<a href="index.html">UCUM-LHC Overview</a>
</div>
<!-- end links to other ucum pages -->
<h1>The UCUM-LHC Validator and Converter</h1>
<!-- navigator/converter tabs -->
<ul class="tab nav nav-tabs">
<li class="active">
<a id="validation-link" href="#validation" class="tablinks"
data-toggle="tab"
onclick="demoPkg.UcumDemo.getInstance().showValidateTab()">
Validator</a></li>
<li>
<a id="conversion-link" href="#conversion" class="tablinks"
data-toggle="tab"
onclick="demoPkg.UcumDemo.getInstance().showConvertTab()">
Converter</a></li>
</ul>
<!-- Converter tab -->
<div class="tab-content">
<div id="conversion" class="tabcontent tab-pane fade">
<h2>UCUM Unit Conversions</h2>
<div id="convSection" class="section">
<p id="convMsg" class="errMsg"> </p>
<p id="convSuggestions"> </p>
<div class="inner-section">
<div class="flex-container outer-container">
<div class="flex-container inner-container"><!-- left side -->
<div>
<input type="text" id="convertFromNum"
class="input-field input-number"
onchange=
"demoPkg.UcumDemo.getInstance().checkNumVal('convertFromNum')">
</div>
<!-- input field to receive UCUM expression. Callback to handle
user's input is defined with the definition of the
autocompleter for this field, in the demo.js constructor -->
<div>
<span class="input-field">
<input type="text" id="convertFrom" class="input-field"
placeholder="Enter UCUM code ...">
</span>
<div id="convertFromName" class="unit-name" wrap="soft"></div>
</div>
</div> <!-- left inner container -->
<div class="flex-container middle-column">
<div>=</div>
</div>
<div class="flex-container inner-container"><!-- right side -->
<div>
<input type="text" id="convertToNum"
class="input-field input-number"
onchange=
"demoPkg.UcumDemo.getInstance().checkNumVal('convertToNum')">
</div>
<!-- input field to receive UCUM expression. Callback to handle
user's input is defined with the definition of the
autocompleter for this field, in the demo.js constructor -->
<div>
<span class="input-field">
<input type="text" id="convertTo" class="input-field"
placeholder="Enter UCUM code ...">
</span>
<div id="convertToName" class="unit-name" wrap="soft"></div>
</div>
<!-- we don't seem to be using the precision-line at the moment
but leaving it here is required for the precision code
left in demo.js. #precision-line in the css file is set
to display: hidden-->
<div id="precision-line">
<input type="number" min="0" max="20" id="precision"
onchange="demoPkg.UcumDemo.getInstance().updatePrecision('convMsg')">
decimal digits.
</div>
</div><!-- right inner container -->
</div> <!-- outer-container -->
<div id="molecular-weight">
Molecular weight of the substance being converted:
<input type="text" id="moleWeight"
onchange="demoPkg.UcumDemo.getInstance().checkNumVal('moleWeight')">
</div>
<span id="advSearchOpts" type="button" class="standalone-button"
onclick="demoPkg.UcumDemo.getInstance().toggleDisplay(
'advancedSearchCnv','toggleAdvancedSearchCnvB',
'Hide', 'Show')">advanced options</span>
<div id="advancedSearchCnv" style="display: none">
<!-- this section is built in the demo code when the page is loaded -->
</div> <!-- advancedSearchCnv division -->
</div><!-- inner-section -->
<!--- Not using this list -- for now
onblur="demoPkg.UcumDemo.getInstance().getCommensurables('convertFrom',
'convertTo',
'resultString')">
-->
<ul>
<li> UCUM codes are <b>case-sensitive</b>.</li>
<li> You can enter other commensurate units that are not on the
UCUM Code lists.</li>
<li><span id="toggleCnvHints" type="button"
onclick="
demoPkg.UcumDemo.getInstance().toggleDisplay('cnvHints',
'toggleCnvHints',
'Hide', 'Show')">
syntax rules</span>.
</li>
</ul>
<div id="cnvHints" class="limitWidth" style="display: none">
<br>
<h4 style="text-align: left">Unit Expression Syntax Rules</h4>
<p class="small-print">See the <a href="http://unitsofmeasure.org/ucum.html">
UCUM Specification</a> for full descriptions of grammar and syntax rules.
<ul class="small-print">
<li>A <a href="http://unitsofmeasure.org/ucum.html#section-Prefixes">UCUM
defined prefix</a> can be applied to metric units, e.g. kg for
kilogram (where k is the prefix kilo and g is the base unit gram).</li>
<li>Simple units may be <a href="http://unitsofmeasure.org/ucum.html#para-9">
raised to a power</a> by appending an integer number to the end of the
unit term, e.g., m2 for a square meter. Negative exponents must be
preceded by a minus sign ('-'). Positive exponents may be preceded by
a plus sign ('+') although the sign may be omitted.</li>
<li>All units can be combined in an <a href="http://unitsofmeasure.org/ucum.html#para-7">
algebraic term</a> using the operators for multiplication (period '.')
and division (solidus '/'), e.g., 2.m.</li>
<li>No blanks are allowed within the unit expression.</li>
<li>Multiple terms in an expression must be separated by an arithmetic
operator - either the multiplication operator (.) or the division
operator (/), e.g., 2.m, not 2m.</li>
<li>The multiplication operator (.) must be explicity specified; it is never
assumed.</li>
<li>While the multiplication operator (.) must appear between two unit terms,
the division operator (/) may appear at the beginning of the expression,
indicating inversion of the following term. So /dL is a valid unit
indicating "per deciliter". However, the division
operator normally appears between two terms.</li>
<li>Terms are evaluated from left to right, with multiplication and
division having the same precedence.</li>
<li><a href="http://unitsofmeasure.org/ucum.html#para-10">Parentheses</a>
may be used to override normal left-to-right evaluation
of an expreession. For example kg/m.s2 divides kg by m and multiplies
the result by s2. kg/(m.s2) divides kg by the result of multiplying
m by s2.</li>
</ul>
</div><!-- hints div -->
<p class="small-print">Disclaimer: Conversion results are for
demonstration purposes only. Before relying on the unit conversions
produced by this tool it is your obligation to perform your own tests
to verify that the results are sufficiently accurate for your purposes.
</p>
</div> <!-- end convSection div -->
</div> <!-- end Converter tab -->
<!-- Validator tab -->
<div id="validation" class="tabcontent tab-pane fade in active">
<h2>UCUM Unit Expression Validation</h2>
<div id="singleString" class="section">
<h3>Validate unit expressions one at a time</h3>
<!-- input field to receive UCUM expression. Callback to handle
user's input is defined with the definition of the
autocompleter for this field, in the demo.js constructor -->
<div class="flex-container" id="valStringDiv">
<div>
<input type="text" id="valString" placeholder="Enter UCUM expression ...">
</div>
<div id="validationString"> </div>
</div> <!-- valStringDiv -->
<div id="valButtonLinks">
<span id="advValSearchOpts" type="button" class="standalone-button"
tabindex="0"
onclick="demoPkg.UcumDemo.getInstance().toggleDisplay(
'advancedSearchVal','toggleAdvancedSearchValB',
'Hide', 'Show')">advanced options</span>
<span id="toggleValHints" type="button" class="standalone-button"
tabindex="0"
onclick="
demoPkg.UcumDemo.getInstance().toggleDisplay('valHints',
'toggleValHints',
'Hide', 'Show')">
syntax rules</span>.
</div>
<div id="advancedSearchVal" style="display: none">
<!-- this section is built in the demo code when the page is loaded -->
</div> <!-- advancedSearchCnv division -->
<div id="valHints" class="limitWidth" style="display: none">
<br>
<h4 style="text-align: left">Unit Expression Syntax Rules</h4>
<p class="small-print">See the <a href="http://unitsofmeasure.org/ucum.html">
UCUM Specification</a> for full descriptions of grammar and syntax rules.
<ul class="small-print">
<li>A <a href="http://unitsofmeasure.org/ucum.html#section-Prefixes">UCUM
defined prefix</a> can be applied to metric units, e.g. kg for
kilogram (where k is the prefix kilo and g is the base unit gram).</li>
<li>Simple units may be <a href="http://unitsofmeasure.org/ucum.html#para-9">
raised to a power</a> by appending an integer number to the end of the
unit term, e.g., m2 for a square meter. Negative exponents must be
preceded by a minus sign ('-'). Positive exponents may be preceded by
a plus sign ('+') although the sign may be omitted.</li>
<li>All units can be combined in an <a href="http://unitsofmeasure.org/ucum.html#para-7">
algebraic term</a> using the operators for multiplication (period '.')
and division (solidus '/'), e.g., 2.m.</li>
<li>No blanks are allowed within the unit expression.</li>
<li>Multiple terms in an expression must be separated by an arithmetic
operator - either the multiplication operator (.) or the division
operator (/), e.g., 2.m, not 2m.</li>
<li>The multiplication operator (.) must be explicity specified; it is never
assumed.</li>
<li>While the multiplication operator (.) must appear between two unit terms,
the division operator (/) may appear at the beginning of the expression,
indicating inversion of the following term. So /dL is a valid unit
indicating "per deciliter". However, the division
operator normally appears between two terms.</li>
<li>Terms are evaluated from left to right, with multiplication and
division having the same precedence.</li>
<li><a href="http://unitsofmeasure.org/ucum.html#para-10">Parentheses</a>
may be used to override normal left-to-right evaluation
of an expreession. For example kg/m.s2 divides kg by m and multiplies
the result by s2. kg/(m.s2) divides kg by the result of multiplying
m by s2.</li>
</ul>
</div><!-- hints div -->
</div><!-- singleString div -->
<div id="filevalidation" class="section">
<h3>Validate all unit expressions in a CSV file</h3>
<p>We can validate unit expressions in a <b>c</b>omma <b>s</b>eparated
<b>v</b>alues file on your system.
<ul>
<li>Use the browse button below to select the file.</li>
<li>You will then be asked for the name of the column that contains
the expressions to be validated. (Your file must include column
headers).
</li>
<li>A copy of your file will be created that includes three
additional columns at the end, confirming what expression was
validated, the validation results, and any relevant notes.
</li>
<li>You will be asked where you want the file saved. You may
change the name of the output file at that time.
</li>
<li>Note that this will only validate <b>unit</b> expressions.
Although prefixes used with a unit code, e.g., "kL" (kiloliter),
are recognized as prefixes ("k" for kilo) modifying a unit code
("L" for liter), a prefix submitted by itself, e.g., "E" (exa)
will result in an "invalid unit code" return.
</li>
</ul>
<input type="file" id="inputfile"
onchange="demoPkg.UcumDemo.getInstance().fileSelected()">
<div id="colNameDiv" style="display:none">
Name of the column that contains the expressions to be validated
<input type="text" id="colName">
<button id="startValidation"
onclick="demoPkg.UcumDemo.getInstance().columnSpecified()"
type="button">Validate File</button>
<button id="cancelValidation"
onclick="demoPkg.UcumDemo.getInstance().resetFileInput()"
type="button">Cancel</button>
</div><!-- colNameDiv -->
<!-- <a id="downlink" href="" style="'display:none'"></a> -->
</div><!-- filevalidation div -->
<div id="aboutSection" class="section">
<h3>About the UCUM-LHC Library</h3>
<ul>
<li>Here is a <a href="index.html">description</a> of the UCUM-LHC
Software Library.
</li>
<li>The code is available from the
<a href="https://github.com/lhncbc/ucum-lhc">GitHub code repository</a>.
</li>
<li>The UCUM-LHC code uses unit definitions from the
<a href="http://unitsofmeasure.org">Unified Code for Units Of
Measure</a>
<a href="http://unitsofmeasure.org/ucum-essence.xml">ucum-essence.xml</a>
file, version 2.1, revision 442, dated 2017-11-21 19:04:52 -0500 (Tue, 21 Nov 2017), with
<a href="demo/UcumEssenceModifications.html">minor content changes.</a>
</li>
<li>The ucum-essence.xml file has also been extended with commonly used
combinations of UCUM units found in <a href="https://loinc.org">LOINC</a>,
and LOINC properties have been added to UCUM records.
</li>
</ul>
</div> <!-- end aboutSection div -->
</div> <!-- end validator tab -->
</div> <!-- end tab-content div -->
<!-- page footer -->
<div id="fine-print">
<ul class="horz-list">
<li><a title="NLM copyright information"
href="http://www.nlm.nih.gov/copyright.html">Copyright</a>
</li>
<li><a title="NLM privacy policy"
href="http://www.nlm.nih.gov/privacy.html">Privacy</a>
</li>
<li><a title="NLM accessibility"
href="http://www.nlm.nih.gov/accessibility.html">
Accessibility</a>
</li>
<li><a title="NLM viewers and players"
href="http://www.nlm.nih.gov/plugins.html">Viewers & Players</a>
</li>
<li><a title="NIH Freedom of Information Act office"
href="http://www.nih.gov/icd/od/foia/index.htm">
Freedom of Information Act</a>
</li>
<li class="last-item"><a title="Contact Us"
href="https://lhncbc.nlm.nih.gov/contact-us">
Contact Us</a>
</li>
</ul>
<ul class="horz-list">
<li><a title="U.S. National Library of Medicine"
href="http://www.nlm.nih.gov/">U.S. National Library of
Medicine</a>
</li>
<li><a title="U.S. National Institutes of Health"
href="http://www.nih.gov/">U.S. National Institutes of Health</a>
</li>
<li><a title="U.S. Department of Health and Human Services"
href="http://www.hhs.gov/">U.S. Department of Health and Human
Services</a>
</li>
<li class="last-item"><a title="USA.gov" href="http://www.usa.gov/"><img
src="demo-dist/assets/images/USAgov.gif" alt="USA.gov"
id="usagov"></a>
</li>
</ul>
</div><!-- fine-print -->
<!-- end page footer -->
<script src="https://lforms-service.nlm.nih.gov/autocomplete-lhc-versions/16.0.1/autocomplete-lhc_jQuery.min.js"></script>
<script src="browser-dist/ucum-lhc.min.js"></script>
<script src="demo-dist/ucum-demo.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>