-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcalchemy_dev.html
More file actions
2199 lines (2019 loc) · 103 KB
/
calchemy_dev.html
File metadata and controls
2199 lines (2019 loc) · 103 KB
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<!-- Calchemy (tm); Math Magic; http://www.calchemy.com -->
<!-- Copyright (c) 1988-2024 Ken Burgess and Rich Testardi. -->
<!-- top, right, bottom, left; max line length 180 -->
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<title>Calchemy™ -- Math Magic</title>
<link rel="icon" type="image/png" href="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAHrElEQVR4AZxXC1AUZxL+ZnaWJbAPWUFxMQlB5KGWiIYEVFhzghKR1EXMgS/E865AoyS84uFBFKOR5CJW4utCmZJY5tSU0RgN5kojFgc+D0HUBRXQ
oOChK8KywLKvuZ4hMbFikMls9989//zd/U3//9/zLwuJV9Tm43xcUSmfs66ETy/cJ7KgR89fuVuiK3G4JACa54J3tO5+H3nZcfhgzRJszp0nciHpH1ZVLEqITdwpepXQ9ANQKoe9kr+T/1Pux/aBbBnlkHmymjIE
0SA7Q43ALDXEITdqEOMXuJR6JZEI4OV3drX9cKgY9af+LYtMzW8kD2I/Sbl+XUkLSZEYGetq5kUVFBZOQeWpg5gh0a1wF3oksRiIabqInvY2qFsuw/L9AT/9gnSD4GVx5rL69JA9utejw8qHRc1JZTgXBcWBhR52
k9JD0kSyW5CEiFTSpJEI4MqBLcOHRMxG9f+MkPWa0Hv3dmDs8tV8VsopvzmzTmBZ/jORf5ig+2fnldMwkv+59MavUbTZlIKfJY8ztj5M+uhEOw0ZNIkAzGbzva7m60tcgl5CnfE+dK0VaNu7HaVF1+GgiCPPnEZa
6FY8p7ZCQW+aTe7XkswgVoPHOpJ5NCkBcgWqsqO19HjQJAIQRrdcOF4COB3jvG3YtceIOH8OB7/zxD9SWfinOKBPAapPAsM1wAEy0FPQeOI9tAAjSU4jIN52Gz2RRo8ABEfN2ObutMk+38JjyHgefy8xIlxnw7cX
3FGcA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bEcDQyTawOuCdLzswN8qBk7UaJE2Uo90ATB1TgfVvHMCSzL9W+US+lvaL
+JAEgHc6elQ/WgcSiM9If4mm4xAFmf8m0FUPcMLuyDJjid6Otgf0sUqTw1zDwNHUjbXTVyExVLGVzB4R+0iTqDioKHuRzfuUidEkK68A7y4nEHeAO2dlSN1hxswJVlRcVmJxEuAzyw7PsTbMTb0tW5CVzSs8fWjv
QFoGGFbm1kXBBHLwDKykjGGA/9BUJNKnaCctzNhIwH2iDQyhy9n3ENExHTh8HYiPZnCfdk/EmLO0g4qhX7lRqCaQlAHebu9SU1Dhk8NRYDnpoEx4kCwgT5PoX8XpH4D0vzGw3ARkKvqcv0X3M3mU0yEncwUVMSpW
l+/HwO4pLGdIAyDUgV4KRrFAscQM0GagHh4+BCQ1PAbjEt5Cxb0AZC8EmqsZtNWzKDoCJBOIr84BU/4yDQWr69aefHM6A7oEXyQGTwIAmm4oyERgF0q9nLjFNxAH/7gCzVVlEZoXxny6v30CYunMLg+gfMmBtGQq
XPpYKOPS+FsNhgIyF0kSAKEOCGsgl15bKPSt5OIW6Y3ElcNH4egHy5433ao923jqUJpf2HRzi/pFrKcze18jg7TimfCIScW5tYmPxXzshvwNSLy5Y6/uxWhcoANKBJ3LwomnkD5d642Pqd/ysJWKcL+L83s2qZQK
xedHbgUjbLEeBsP1vPLc18W094/obyUB6GyuW+Y/PwfTNh1FwPr9CPrwsMi+Odv4/27JFGZEmKF+z9S21lameE2J/1o1Jxfmuzc3UNev6P8AAAD//0PzZh4AAAAGSURBVAMAogO9c8sh9MoAAAAASUVORK5CYII="/>
<style>
body,select,input { background: #ededed }
a { text-decoration: none; }
#results { line-height: 1.4; }
#equation { width: 96%; font-size:120%; }
#copyright { font-size:75%; padding: 0px; }
* { overflow-wrap: anywhere; word-wrap: anywhere; }
button { overflow-wrap: normal; word-wrap: normal; }
html,button,input { font: 36px Arial, Helvetica, sans-serif; padding: 15px 10px 15px 10px; margin: 15px 0px 15px 0px; }
@media(min-width:80em){ html,button,input { font: 24px Arial, Helvetica, sans-serif; padding: 10px; margin: 10px 0px 10px 0px; } }
@supports(-webkit-touch-callout:none) { button,input { -webkit-appearance: none; border-radius: 2px; } }
img { padding: 0px; margin: 10px 10px 0px 0px; }
table,tr,td { margin: 0px; padding: 0px; }
.table1,.table2 { width: 100%; }
.td3 { width: 4%; vertical-align: bottom; text-align: right }
.i4 { filter: grayscale(75%) opacity(75%); }
.key { padding: 15px 15px 15px 15px; width: 60px }
hr { height: 2px; }
body,html { margin: 0px; }
#columns { column-width: 10em; column-count: 4; }
@media(min-width:80em){ #columns { column-width: 15em; column-count: 6; } }
.dark { filter: invert(1); background: #121212; img { filter: invert(1); } }
</style>
</head>
<body onload='Body()'>
<h1>Calchemy™ -- Math Magic</h1>
<p id='status'></p>
<table class='table1'><tr>
<td>
<button type='button' onclick="Test();">Test</button>
<button type='button' onclick="Examples();">Examples</button>
<button type='button' onclick="Copy();">Copy All</button>
<button type='button' onclick="Paste();">Paste</button>
<button type='button' onclick="Load();">Load</button>
<button type="button" onclick="Dark();" id="dark">Dark</button>
<button type='button' onclick="Help();">Help</button>
</td>
<td style='text-align: right'>
<button id='all' type='button' style='margin: 0px;' onclick="Delete('all')">Delete All</button>
<button type='button' onclick="Scroll();">Bottom</button>
</td>
</tr></table>
<input type='file' id='file' style='display: none'>
<p id='results'></p>
<input id='equation' name='equation' placeholder='enter expression ? unit' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' />
<br>
<table class='table1'><tr>
<td>
<button type='button' onclick="Enter();" id='enter'>Enter</button>
<button type='button' onclick="Clear();" id="clear">Clear</button>
<button type='button' onclick="Units();">Find Units</button>
<button type='button' onclick="Details();">Unit Details</button>
<button type='button' onclick="Equations();">Equations</button>
</td>
<td style='text-align: right'>
<button type='button' onclick="window.scrollTo(0, 0);">Top</button>
</td>
</tr></table>
<table class='table2' id='bottom'><tr>
<td>
<a href='http://www.calchemy.com' target='_blank'><img alt='Calchemy icon' src='data:image/gif;base64,
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mOFT6RGGc94UleVeZn
nudOFQEMlDRK7TLw9kx4rueEDlTw1RHDEIRbp1U23ftMAFTokJ4QAQEAOw=='/></a>
</td>
<td>
<p id='copyright'>Copyright © 1988-2026 Ken Burgess and Rich Testardi.
v1.50</p>
</td>
</tr></table>
<script>
'use strict';
var custom = null;
// XXX -- for IE, replace template strings with concatenation, replace .includes with .indexOf != -1, class likely has to be removed, too
// database format:
//
// ... # <comment> -- optional comment (will be shown in unit definition details)
// CATEGORY <name> -- define category name (categories must be defined before use)
// BASE <name> -- define base unit name (cannot be undefined)
// DERIVED <names> = <expression> -- define coefficient and exponents for a derived dimension name (cannot be undefined)
// AMBIGUOUS <names> = <expression> -- like derived, but called out for extra testing (cannot be undefined)
// PREFIX <names> = <expression> -- define coefficient for a prefix name (cannot be undefined)
// [*]<names> [+-]= <expression> -- define or undefine a unit (* = unit is prefixable)
//
// <names> format:
// [<category|dimension>[, ...]:]<name>[*][, ...] -- unit names (* = name is pluralizable)
</script>
<script type="text/javascript" src="database_dev.js">
// var database=...
</script>
<script type="text/javascript" src="engine_dev.js">
</script>
<script type="text/javascript" src="custom.js">
// custom=...
</script>
<script>
// *** html elements ******************************************************************************
// persist new results, scroll the page to the equation line, and set equation focus
function Scroll(noscroll = false)
{
if (testing) {
return;
}
// store our results history
var save = document.getElementById("results").innerHTML.trim(); // XXX -- why space when empty?
localStorage["calchemy.results"] = save;
// and our dark state
var bw = document.querySelector('body').classList.contains('dark');
localStorage["calchemy.dark"] = bw;
// enable the Delete All button if there are chunks to delete
document.getElementById("all").disabled = ! save.length;
// if we're scrolling...
if (noscroll != true) {
// scroll the equation line into view and set the focus
document.getElementById("bottom").scrollIntoView(false);
document.getElementById("equation").focus();
// if needed, scroll us all the way left
// N.B. some browsers hide our margin otherwise and it looks bad
var x = window.scrollX, y = window.scrollY;
if (x < 100) {
window.scrollTo(0, y);
}
}
}
// convert text to breakable text for the history list
// XXX -- why don't tables break anywhere on phone? Just enter long numeric string. :-(
function Break(output)
{
// allow breaks periodically
return output.match(/(.{0,20})/g).join("<wbr>");
}
// convert text to hyperlinked html for the history list
function History(text)
{
var html = Break(text);
if (html.match(/[#]/)) {
html = html.replace(/[#]/, "<i class='i4'>#").replace(/$/, "</i>");
}
return "<a href=\"javascript:Hyperlink('" + text.replace("'", "\\'").replace(/^= /, "") + "')\">" + html + "</a>";
}
function Keep(tag)
{
var keep = document.getElementById("k" + tag);
var del = document.getElementById("d" + tag);
if (keep.outerHTML.match(/Unkeep[<]/)) {
keep.outerHTML = keep.outerHTML.replace(/Unkeep[<]/, "Keep<");
del.hidden = false;
} else {
keep.outerHTML = keep.outerHTML.replace(/Keep[<]/, "Unkeep<");
del.hidden = true;
}
// update our results history
var save = document.getElementById("results").innerHTML.trim(); // XXX -- why space when empty?
localStorage["calchemy.results"] = save;
}
var lasttag = "";
// append a tagged html chunk to allow results to be deleted
function Chunk(label, result)
{
// create a random tag if a label was not specified explicitly
var tag;
if (label == null) {
tag = window.crypto.getRandomValues(new Uint32Array(4)).join('-');
label = "";
} else {
tag = label.replace(/ /g, "");
label = label + " ";
}
var kept = Delete(tag);
if (result == undefined) {
result = "";
}
// create the chunk as a searchable comment preceded by a horizontal line and followed by a table with a delete button to the right
var hrtag = "<hr><!--" + tag + "-->"; // N.B. duplicated below
var head = "<table><tr><td>";
var td = "</td><td class='td3'>";
var del = "<button type='button' id=\"d" + tag + "\" style='margin: 0px;' onclick='Delete(\"" + tag + "\")'>Delete</button>";
var keep = "<button type='button' id=\"k" + tag + "\" style='margin: 0px;' onclick='Keep(\"" + tag + "\")'>Keep</button>";
var tail = "</td></tr></table>";
document.getElementById("results").innerHTML += hrtag + head + label + result + td + del + keep + tail;
first = true;
if (lasttag == "") {
lasttag = tag;
}
if (kept) {
Keep(tag);
}
}
// the user clicked a Delete button; delete tagged html results
function Delete(tag)
{
var kept = false;
if (tag == "all") {
// delete all unkept chunks
var temp = document.getElementById("results").innerHTML;
var keep = "";
var hrtag = "<hr><!--";
while (temp.length) {
var index = temp.indexOf(hrtag, 1);
if (index == -1) {
index = temp.length;
}
var maybe = temp.slice(0, index);
if (maybe.match(/Unkeep[<]/)) {
keep += maybe;
}
temp = temp.slice(index);
}
document.getElementById("results").innerHTML = keep;
} else {
// find the requested chunk in the results
var head;
var mid;
var tail;
var orig = document.getElementById("results").innerHTML;
var hrtag = "<hr><!--" + tag + "-->"; // N.B. duplicated above
var index = orig.indexOf(hrtag);
if (index != -1) {
// delete everything up to the next chunk
head = orig.slice(0, index);
mid = orig.slice(index + hrtag.length);
var nexthr = "<hr>";
index = mid.indexOf(nexthr);
if (index != -1) {
tail = mid.slice(index);
mid = mid.slice(0, index);
} else {
tail = "";
}
kept = mid.match(/Unkeep[<]/);
// update the results
document.getElementById("results").innerHTML = head.trim() + " " + tail.trim();
cursor = 0;
}
}
// reset url
if (! testing) {
window.history.pushState("", "", window.location.href.replace(/[?#].*/, ""));
}
Scroll(true);
return kept;
}
function ReplayAllKept(temp)
{
var hrtag = "<hr><!--";
while (temp.length) {
var index = temp.indexOf(hrtag, 1);
if (index == -1) {
index = temp.length;
}
var replay = temp.slice(0, index);
if (replay.match(/Unkeep[<]/)) {
if (replay.match(/.*javascript:Hyperlink\('/) && ! replay.match(/===/)) {
var hyperlink = replay.replace(/.*javascript:Hyperlink\('/, "");
hyperlink = hyperlink.replace(/'\)">.*<\/a>.*/, "");
if (hyperlink.match(/=/)) {
LoadDatabase(hyperlink);
}
} else if (replay.match(/[.]js loaded [0-9]/)) {
var database = replay.replace(/ loaded [0-9].*/, "");
database = database.replace(/.*>/, "");
LoadRemote(database);
}
}
temp = temp.slice(index);
}
}
// snoop the test results and delete tagged html results
function SnoopAndDelete(tag)
{
// find the requested chunk in the results
var head;
var mid;
var orig = document.getElementById("results").innerHTML;
var hrtag = "<hr><!--" + tag + "-->"; // N.B. duplicated above
var index = orig.indexOf(hrtag);
if (index == -1) {
return [""];
}
// delete everything up to the next chunk
head = orig.slice(0, index);
mid = orig.slice(index + hrtag.length);
// update the results
document.getElementById("results").innerHTML = head.trim();
// return the snoop
var lines = mid.split("<br>");
var snoops = [];
for (var i = 0; i < lines.length; i++) {
var snoop = lines[i].replace(/<wbr>/g, "").replace(/<\/?[^>]+>/g, " ").replace(/ Delete /g, " ").replace(/ Unkeep/g, "").replace(/ Keep/g, "");
if (snoop.trim().length) {
snoops.push(snoop);
}
}
return snoops;
}
function LoadRuntimeDatabase(name, text)
{
var start = new Date();
try {
var number = units.length;
LoadDatabase(text);
number = units.length - number;
var ms = new Date() - start;
Chunk(name, "loaded " + number + " units in " + ms + " ms");
} catch (error) {
// append a deletable chunk with any errors
Chunk(name, error);
} finally {
offset_warn = false;
cycle_warn = false;
}
Scroll();
}
// the user loaded the webpage; initialize the units database
function Body()
{
try {
// capture our query string
var url = document.URL;
// recall our results history
var temp = localStorage["calchemy.results"];
temp = temp != undefined ? temp : "";
document.getElementById("results").innerHTML = temp;
// and our dark state
var bw = localStorage["calchemy.dark"];
if (bw == "true") {
Dark();
}
var number = units.length;
// load the units database
var start = new Date();
loading = true;
LoadDatabase(database);
loading = false;
var ms = new Date() - start;
// tests should pass now
dirty = false;
// replay all kept results
ReplayAllKept(temp);
number = units.length - number;
Chunk("database", "loaded " + number + " units in " + ms + " ms");
if (custom != null) {
number = units.length;
// load custom units
start = new Date();
LoadDatabase(custom);
ms = new Date() - start;
number = units.length - number;
Chunk("custom", "loaded " + number + " units in " + ms + " ms");
}
if (performance.navigation.type != performance.navigation.TYPE_RELOAD) {
// if we have a query string...
var index = url.indexOf('?');
if (index != -1) {
offset_warn = false;
cycle_warn = false;
// pretend the user entered the query string thru the UI
document.getElementById("equation").value = window.unescape(url.slice(index+1));
Enter();
// reset url
window.history.pushState("", "", window.location.href.replace(/[?#].*/, ""));
}
}
} catch (error) {
document.getElementById("status").innerHTML += error;
} finally {
offset_warn = false;
cycle_warn = false;
}
// handle key presses in the user equation
document.body.addEventListener("keyup", function(event) {
if (event.keyCode === 13) {
// enter -- run the command line
event.preventDefault();
document.getElementById("enter").click();
}
if (event.keyCode === 40) {
// down arrow -- recall a newer command line
event.preventDefault();
UpDown(false);
}
if (event.keyCode === 38) {
// up arrow -- recall an older command line
event.preventDefault();
UpDown(true);
}
});
// handle database load events
document.getElementById("file").addEventListener('input', function() {
var file = document.getElementById("file").files[0];
var reader = new FileReader();
reader.addEventListener('load', function(e) {
var text = e.target.result;
try {
LoadRuntimeDatabase(file.name, text);
} catch (error) {
// append a deletable chunk with any errors
Chunk(file.name, error);
}
});
reader.readAsText(file);
});
Scroll();
}
// the user clicked the Enter button; run the user command line
function Enter()
{
var success = false;
try {
// get the user command line split by '&'
var equation = document.getElementById("equation").value;
var lines = equation.split('&');
var urls = [];
var htmls = [];
for (var k = 0; k < lines.length; k++) {
// parse the requested equation from the command line
var line = lines[k];
// run the equation
var results = RunLine(line);
success = results.success;
var output = results.output;
// transform the output into hyperlinked html
var html = "";
for (var i = 0; i < output.length; i++) {
if (output[i].match(/^= /)) {
html += "<br>" + History(output[i]);
} else if (output[i].match(/^[>] /)) {
html += "<br><i>" + Break(output[i]) + "</i>";
} else {
html += "<br>" + output[i];
}
}
// if we auto-inverted left-hand-side...
if (invert_warn) {
html += "<br> Caution: Calculation auto-inverted left-hand-side.";
}
// if we accessed offset temperature units...
if (offset_warn && ! offset_warned) {
html += "<br> Caution: Calculation involves offset temperature units; see Calchemy Help.";
offset_warned = true;
}
// if we accessed units of cycle or revolution...
if (cycle_warn && ! cycle_warned) {
html += "<br> Caution: Calculation involves units of cycle or revolution; see Calchemy Help.";
cycle_warned = true;
}
// record output (even if there is an error, so the user can recall failed commands)
if (((lines.length > 1 && line.trim().length && success) || (! success)) && ! testing) {
xx = History(line);
htmls.push("<br>" + History(line) + html);
} else if (html.length) {
htmls.push(html);
}
urls.push(window.escape(line));
// stop at first error
if (! success) {
break;
}
Clear();
}
// append a deletable chunk to the results list with the results
if (equation.length && success && ! testing) {
Chunk(null, History(equation) + htmls.join(' '));
window.history.pushState("", "", window.location.href.replace(/[?#].*/, "") + '?' + urls.join('&'));
} else if (htmls.length) {
// N.B. if there is no new output we leave output from before TEST available
Chunk(null, htmls.join(' '));
}
} catch (error) {
Chunk(null, error);
}
Scroll();
return success;
}
var first = true;
var cursor = 0;
// the user typed up-arrow or down-arrow to recall an older or newer command line
function UpDown(up)
{
// get the list of lines and hyperlinks from the results history
var html = document.getElementById("results").innerHTML;
var lines = html.split(/[<>]+/);
var links = [];
for (var i = 0; i < lines.length; i++) {
if (lines[i].match(/javascript:Hyperlink/i)) {
links.push(lines[i].replace(/.*javascript[:]Hyperlink.[']/i, "").replace(/['].*/, ""));
}
}
if (first && up) {
// an initial up-arrow recalls the last hyperlink from the results history
cursor = 0;
}
if (links.length) {
// recall the requested hyperlink from the results history to the equation line
if (up) {
// older
cursor = (cursor+links.length-1)%links.length;
} else {
// newer
cursor = (cursor+1)%links.length;
}
document.getElementById("equation").value = links[cursor].replace(/&/g, '&');
first = false;
}
Scroll();
}
// the user clicked the Clear button; clear the user equation
function Clear()
{
// reset url
if (! testing) {
window.history.pushState("", "", window.location.href.replace(/[?#].*/, ""));
}
document.getElementById("equation").value = "";
Scroll();
}
// the user clicked a hyperlink; enter text into the user equation, possibly replacing the word at the cursor
function Hyperlink(string, replace=true)
{
var equation = document.getElementById("equation");
var start = equation.selectionStart;
var end = equation.selectionEnd;
// if we are properly inside a word...
if (replace && start > 0 && equation.value.slice(start-1, end).match(unit_regexp_all) ||
end < equation.value.length-1 && equation.value.slice(start, end+1).match(unit_regexp_all)) {
// find the start and end of the word at the cursor
var match = equation.value.slice(0, start).match(unit_regexp_tail);
if (match) {
start -= match[0].length;
}
match = equation.value.slice(end).match(unit_regexp_head);
if (match) {
end += match[0].length;
}
// replace the word at the cursor with the hyperlinked string
equation.value = equation.value.slice(0, start) + string + equation.value.slice(end);
} else {
// insert the hyperlinked string at the cursor
equation.value = equation.value.slice(0, start) + string + equation.value.slice(end);
}
// update the selection
equation.selectionStart = equation.selectionEnd = start + string.length;
Scroll();
}
// show details for a unit in the user equation
function ShowUnitsDetails(name)
{
// find all interpretations of the unit
var more = LookupUnits(name, false, false);
// for each interpretation of the unit...
var html = "";
for (var i = 0; i < more.length; i++) {
// if the unit is prefixed...
if (more[i].match('~')) {
// format the prefix definition and the unit definition side-by-side
// N.B. the unit definition begins with a '*', which we use to represent the multiplication!
var prefixunit = more[i].split('~');
html += "<br>" + LookupUnit(prefixunit[0]).definition + LookupUnit(prefixunit[1]).definition;
} else {
// format the unit definition alone
html += "<br>" + LookupUnit(more[i]).definition;
}
// append the dimension of the unit to the unit details
var tokens = TokenizeLine(more[i]);
var filter = EvaluateTokens(tokens);
// XXX -- hack for now to ignore interpretations
html += " " + filter.Dimension(false)[1];
}
// append a deletable chunk to the results list with the unit details
Chunk("=== unit details " + name + " ===", html);
Scroll();
}
// sort, stably folding upper/lower case
function Sort(array)
{
array.sort(function(a, b) {
var compare = a.toLowerCase().localeCompare(b.toLowerCase());
return compare ? compare : a.localeCompare(b);
});
}
// show units in a database category or dimension
function ShowUnitsByCategory(category, bydimension) // or "All Units"
{
var i, j;
var names = [];
if (bydimension != true) {
// first look for category matches
for (i = 0; i < units.length; i++) {
if (! units[i].type || units[i].type == "PREFIX") {
if (units[i].categories.includes(category)) {
for (j = 0; j < units[i].names.length; j++) {
if (! names.includes(units[i].names[j])) {
names.push(units[i].names[j]);
}
}
}
}
}
}
if (! names.length) {
// then look for dimension matches
var filter = LookupUnit(category);
if (filter || category == "All Units") {
for (i = 0; i < units.length; i++) {
if (! units[i].type) {
if (units[i].Compatible(filter, false)) {
for (j = 0; j < units[i].names.length; j++) {
if (! names.includes(units[i].names[j])) {
names.push(units[i].names[j]);
}
}
}
}
}
}
}
// finally look for SI units
for (i = 0; i < units.length; i++) {
if (units[i].type == "DERIVED" && units[i].names[0] == category) {
var name = units[i].definition.replace(/.*= */, "").replace(/ *[#].*/, "").trim();
if (! names.includes(name)) {
names.push(name);
}
}
}
// compute the list of hyperlinked units
Sort(names);
var html = "<br><div id='columns'>";
for (i = 0; i < names.length; i++) {
html += History(names[i]) + "<br>";
}
html += "</div>";
// append a deletable chunk to the results list with the units list
Chunk("=== units in category " + category + " ===", html);
Scroll();
}
// show units that can match the unit in the user equation
function ShowUnitsByName(name)
{
// find all units that match the name
var i;
var names = LookupUnits(name, false, true);
var namesets = [];
for (i = 0; i < names.length; i++) {
if (! namesets.includes(names[i])) {
namesets.push(names[i]);
}
}
// compute the list of hyperlinked units
Sort(namesets);
var html = "<br><div id='columns'>";
for (i = 0; i < namesets.length; i++) {
html += History(namesets[i]) + "<br>";
}
html += "</div>";
// append a deletable chunk to the results list with the units list
Chunk("=== units by name " + name + " ===", html);
Scroll();
}
// show database categories and dimensions
function ShowCategories()
{
// compute the list of categories and dimensions
var categories = [];
for (var i = 0; i < units.length; i++) {
for (var j = 0; j < units[i].categories.length; j++) {
if (! categories.includes(units[i].categories[j])) {
categories.push(units[i].categories[j]);
}
}
if (units[i].type == "DERIVED") {
if (! categories.includes(units[i].names[0])) {
categories.push(units[i].names[0]);
}
}
}
// compute the list of hyperlinked categories and dimensions
Sort(categories);
var html = "<div id='columns'>";
html += "<a href=\"javascript:ShowUnitsByCategory('All Units')\">All Units</a>";
for (i = 0; i < categories.length; i++) {
html += "<br>" + "<a href=\"javascript:ShowUnitsByCategory('" + categories[i] + "')\">" + categories[i] + "</a>";
}
html += "</div>";
// append a deletable chunk to the results list with the categories list
Chunk("=== unit categories ===", html);
Scroll();
}
// return the word at the cursor
function Word(extended)
{
var line = document.getElementById("equation").value;
var start = document.getElementById("equation").selectionStart;
var match = line.slice(start).match(extended?xunit_regexp_head:unit_regexp_head);
if (match) {
start += match[0].length;
}
line = line.slice(0, start);
var word = line.match(extended?xunit_regexp_tail:unit_regexp_tail);
if (word) {
word = word[0];
if (extended) {
word = word.replace(/.*:/, "");
}
}
return word;
}
// the user clicked the Find Units button; find units requested by the user
function Units()
{
// if there is a word at the cursor...
var word = Word(true);
if (word) {
var unit = LookupUnit(word);
if (unit && unit.type) {
// do a unit category search
ShowUnitsByCategory(word);
} else {
// do a unit search
ShowUnitsByName(word);
}
} else {
// do a category search
ShowCategories();
}
Scroll();
}
// the user clicked the Unit Details button; show unit details requested by the user
function Details()
{
// if there is a word at the cursor...
var word = Word(false);
if (word) {
// show unit details
ShowUnitsDetails(word);
}
Scroll();
}
// the user clicked the Copy button; copy the history and equation to the clipboard
function Copy()
{
var text = document.getElementById("results").innerText.replace(/[ \t][ \t]*/g, " ").replace(/ DeleteKeep$/gm, "").replace(/ Unkeep$/gm, "") + "\n\n" +
document.getElementById("equation").value;
navigator.clipboard.writeText(text);
Scroll();
}
// the user clicked the Paste button; paste the clipboard into the equation line up to the first error
function Paste()
{
navigator.clipboard.readText().then((text) =>
{
// for each equation line in the clipboard...
var lines = text.split(/[\r\n]+/);
for (var i = 0; i < lines.length; i++) {
if (! lines[i].match(/^[[>=]/) && ! lines[i].match(/^(un)?defined/) && ! lines[i].match(/^Caution/) && ! lines[i].match(/^Delete/) && ! lines[i].match(/^Mismatch/)) {
// evaluate the equation line
document.getElementById("equation").value = lines[i];
// if the evaluation failed...
if (! Enter()) {
// don't evaluate any more equation lines
break;
}
}
}
});
Scroll();
}
function Dark()
{
document.querySelector('body').classList.toggle('dark');
var bw = document.querySelector('body').classList.contains('dark');
if (bw) {
document.getElementById("dark").innerHTML = "Light";
} else {
document.getElementById("dark").innerHTML = "Dark";
}
Scroll(true);
}
var examples =`
0.5 * 0.32 * d_air * (60 mph)^2 * 25 square feet ? lbf # air drag force on car | = 77.7017 lbf
77.7017 lbf * 60 mph ? hp # power to overcome air drag force at speed | = 12.4323 hp
2000 lbm * grav * 60 mph ? hp # power to decelerate car at 1G | = 320 hp
1/2 * 2000 lbm * ((60 mph)^2 - (55 mph)^2) / (5 sec) ? hp # measured power drag on car | = 13.9795 hp
13.9795 hp; 55 mph; hcv_gasoline*20% ? mpg # mpg estimation at 20% engine efficiency | = 35.88 mpg
35.88 mpg ? km/l # fuel efficiency | = 15.2542 km/l
1 cup * 4 gram/tsp ? lb # weight of granulated sugar | = 0.423288 lb
1/2 pi sqrt(23 millihenry * 10 microfarad) ? Hz # frequency of LC oscillator | = 331.861 Hz
60 PiB/month ? Gbps # fast network bandwidth | = 205.644 Gbps
3.4 mega byte / (1200 baud) ? hour # slow network time | = 6.2963 hour
20000 btu/hour; 80% * 14 megajoules/day/meter^2 ? ft^2 # solar collector size | = 486.71 ft^2
2 packs; 30 rolls/pack; 425 sheets/roll; 40 sheets/poop; 1 poops/person/day; 3 persons ? months | = 6.9863 months
pi * (0.25 inch)^2; 60 ft; 5 gal/min ? sec # time for hot water to flow thru 1/2 inch pipe | = 7.34398 sec
40 gal; 120 degF - 45 degF; 1 cal/(cc deltaC); 40000 btu/hr ? min # water heater recovery time | = 37.5291 min
10 mph * 30 feet * 10 gal/acre ? gal/min # fertilizer flow rate on tractor swath | = 6.06061 gal/min
30 ft * 20 meters ? acres # lot size | = 0.0451906 acres
40 knot / (2500 rpm * 90%) ? inch/rev # propeller pitch | = 21.604 inch/rev
(3/4) cup * 1 cal/(cc deltaK) * (212 - 52) deltaF / (2 min + 4 sec) ? watt # measured power of microwave oven | = 532.196 watt
(50 ft * 30 ft * 0.75 inches/week) / (5 gal/min) ? hours/week # lawn sprinkler time | = 2.33766 hours/week
40 gal * 1 cal/(cc deltaK) * (140-45) deltaF / (40000 btu/hour) ? hour # water heater recovery time | = 0.79228 hour
45 hp; 2 pi 8000 rpm ? ft lb # convert power to torque | = 29.5431 ft lb
(3/(4 pi) * 1 gal)^(1/3) ? inches # radius of a gallon sphere | = 3.80634 inches
(1 gallon)^(1/3) ? inches # width of a gallon cube | = 6.13579 inches
50m * 25m * 3m * 0.74 / (4/3*pi*(1.57in/2)^3) ? million # how many million ping-pong balls can fit in an Olympic sized swimming pool? | = 83.5727 million
cbrt(5.975E24 kgm; 1 amu / (4/3*pi*(1fm/2)^3)) ? meter # how big a cube would the earth be if its mass had the density of a neutron? | = 123.508 meter
sqrt(5.5 kWh/m^2/day * 30%; 13.5 quads/year) ? miles # how large a solar cell on a side in Nevada would it take to power the entire USA? | = 50.3635 miles
8 foot; d_water; grav ? psi # gauge pressure at the bottom of a pool
10 gpm * (60 psi + (250 ft; d_water; grav)) / 240 volts ? amps # current for a well pump
2.45 GHz; c ? inch # wavelength of microwave in microwave oven
`;
// the user clicked the Examples button; show examples
function Examples()
{
// get all the example lines, including blanks
var lines = examples.split(/[\r\n]+/);
var html = "";
for (var i = 0; i < lines.length; i++) {
var line = lines[i].replace(/[|].*/, "").trim();
if (line.length) {
html += "<br>" + History(line);
}
}
// append a deletable chunk to the results list with the examples, replacing any existing examples chunk
Chunk("=== examples ===", html);
Scroll();
}
var preequations = `
# equation support
Cd = 1
width = 1 Length
height = 1 Length
depth = 1 Length
base = 1 Length
radius = 1 Length
f = 1/second
omega = 1 radian/second