-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
1018 lines (961 loc) · 26.2 KB
/
index.html
File metadata and controls
1018 lines (961 loc) · 26.2 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>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="./MICR/c.png">
</head>
<body>
<style>
html, body {
padding: 0;
margin: 0;
}
body {
background: black;
color: skyblue;
}
div {
position: relative;
box-sizing: border-box;
}
div, ul, li, form, p, span, input, textarea {
-webkit-transition: all 0.3s;
transition: all 0.3s;
box-sizing: border-box;
}
@media print {
html, body {
background: white;
}
}
@font-face {
font-family: 'Lace';
src: url('/+/fonts/Lace.ttf') format('truetype');
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'HomemadeApple';
src: url('/+/fonts/HomemadeApple.ttf') format('truetype');
font-style: normal;
font-display: swap;
}
.Lace, .Lace + label {
font-family: Lace;
}
.none {
display: none;
}
.say {
text-align: center;
}
.envelope {
padding: 10% 0;
overflow-x: scroll;
}
.check {
width: 50em;
max-width: 50em;
margin: 1em auto;
padding: 0.4em;
background: skyblue;
color: black;
}
.check .designer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
filter: contrast(1.8) saturate(2);
background-size: cover;
background: repeating-radial-gradient( circle at 0% 0%, plum 1px, skyblue 3px )
}
.check {
z-oom: 40%;
}
.check:hover {
z-oom: 100%;
transition: 2s zoom;
}
.check .designer::before {
dis-play: none;
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, plum, skyblue);
background: repeating-radial-gradient(circle at 100% 200%, plum 1px, skyblue 2px);
mix-blend-mode: color-burn;
background-size: cover;
}
.check .designer::after {
dis-play: none;
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle at 25% -55%, skyblue 50%, plum 90%);
mix-blend-mode: color;
background-size: cover;
filter: contrast(3) saturate(1);
opacity: 0.65;
}
.flipit .designer {
opacity: 0;
}
.flipit {
zoom: 100%;
}
.paper {
width: 100%;
p-adding-bottom: 40%;
position: relative;
border: solid black 0.3em;
}
.back .check {
background: white;
}
.back .paper {
border: solid #EEE 0.3em;
}
.check .row {
height: 2.6em;
pointer-events: none;
}
.check .row > * {
pointer-events: all;
}
div[contenteditable] {
white-space: pre;
cursor: text;
}
[contenteditable="true"]:hover,
.routing:hover,
.account:hover,
.inaccount input:hover {
outline: solid gold 0.1em;
}
.routing:hover, .account:hover {
outline-offset: 6px;
cursor: text;
}
.flipit:hover .vertical, .flipit.hover .flipit,
.flipped .vertical, .flipped .flipit,
/** Keep check flipped if endorse in focused */
.flipit .vertical:has(.endorse > div[contenteditable]:focus),
.flipped .flipit:has(.endorse > div[contenteditable]:focus) {
-ms-transform: rotateX(-180deg);
transform: rotateX(-180deg);
}
.flip {
-ms-perspective: 1000px;
perspective: 1000px;
position: relative;
height: 22em;
width: 90%;
margin: 0 auto;
}
.vertical {
height: 2em;
width: 50em;
max-width: 50em;
margin: 0 auto;
}
.vertical {
position: relative;
-ms-transition: 1.2s;
transition: 1.2s;
-ms-transform-style: preserve-3d;
transform-style: preserve-3d;
-ms-transform-origin: 100% 11em; /* half of height */
transform-origin: 100% 11em; /* half of height */
}
.front, .back {
-ms-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
}
.front {
z-index: 2;
-ms-transform: rotateX(0deg);
transform: rotateX(0deg);
}
.back {
-ms-transform: rotateX(-180deg);
transform: rotateX(-180deg);
}
.what {
font-size: 0.8em;
float: left;
}
.address {
float: left;
height: 4em;
width: 40%;
margin: 1em 0 0 1.5em;
}
.top .number, .top label {
font-size: 16pt;
font-family: Arial;
}
.top .number {
margin: 0.5em 2em 0 0;
float: right;
width: 10%;
}
.envelope .top label {
left: unset;
right: 74px;
top: 11px;
}
.number img {
height: 1em;
}
.number img {
height: 1em;
margin: 0 0.1em;
}
.scan .numbers:hover .number {
display: none;
}
.when {
float: right;
padding: 0 0em 0 0;
text-align: right;
margin-top: -0.5em;
}
.when .what {
float: right;
}
.date {
padding: 0.1em;
width: 10em;
font-size: 1.2em;
text-align: center;
border-bottom: solid black 1px;
}
.date .font {
transform: scale(1.7) translate(0.8em, -0.2em) rotate(-1.6deg);
letter-spacing: 0.1em;
width: 70%;
}
.fractional {
width: 10em;
float: right;
text-align: center;
}
.fractional .numbers {
font-family: Arial;
font-size: 8pt;
}
.fractional .numbers .fraction {
white-space: initial;
word-break: break-all;
line-height: 1.2em; /* default, but to be strict */
max-height: 2.4em;
overflow: hidden;
}
.who .what {
width: 7em;
padding-left: 1em;
}
.payee {
float: left;
width: 60%;
font-size: 1.4em;
padding-left: 2%;
border-bottom: solid black 1px;
border-right: solid black 1px;
}
.payee .font, .payee .font + label {
transform: scale(2) translate(3em, -2px) rotate(-1.1deg);
letter-spacing: 0.1em;
width: 50%;
}
.currency {
float: left;
padding: 0 0.5em 0 0.5em;
font-size: 1.5em;
}
.amount {
float: left;
width: 20%;
font-size: 1.4em;
background: white;
border: solid black 1px;
padding: 0 0.2em 0 0.2em;
}
.amount .font, .amount .font + label {
transform: scale(1.7) translate(0.8em);
letter-spacing: 0.1em;
width: 60%;
}
.amounts {
float: left;
width: 80%;
font-size: 1.4em;
margin-left: 0.7em;
padding-left: 2%;
border-bottom: solid black 1px;
}
.amounts .font, .amounts .font + label {
transform: scale(1.5) translate(3em) rotate(0.9deg);
letter-spacing: 0.1em;
width: 70%;
}
.moneys .what {
padding-top: 1em;
}
.moneys .details {
font-size: 0.5em;
width: 5em;
padding-top: 0em;
}
.moneys .lock {
float: left;
width: 1.25em;
padding: 0.5em;
box-sizing: initial;
}
.bank {
float: left;
height: 3.6em;
width: 40%;
margin: 0 0 0 1.5em;
}
.why {
clear: both;
}
.why .what {
padding-left: 1em;
margin-top: 1em;
}
.memo {
float: left;
width: 40%;
font-size: 1.4em;
margin-left: 0.2em;
padding-left: 1%;
border-bottom: solid black 1px;
}
.memo .font {
text-align: center;
transform: scale(1.5) translate(0.8em) rotate(-2deg);
letter-spacing: 0.1em;
width: 90%;
}
.signature {
float: right;
width: 45%;
font-size: 1.5em;
margin-top: -0.2em;
margin-right: 1em;
padding-left: 2%;
text-align: center;
border-bottom: solid black 1px;
height: 1.5em;
}
.signature .font, .signature .font + label {
position: absolute;
font-family: 'Yellowtail', cursive;
font-family: 'HomemadeApple', cursive;
transform: scale(1.3,1) translate(0em, 0em) rotate(-2deg);
font-style: italic;
width: calc(100%/1.3);
}
.signature::after {
content: "MP"; /* This is the text that will be inserted */
font-family: Arial;
text-decoration: bold;
font-weight: 800;
letter-spacing: -0.25em;
font-size: 40%;
float: right;
transform: translate(0px, 2.25em);
}
.check .scan {
height: 3.6em;
}
.MICR {
float: left;
padding: 1.5em 0 0 1.5em;
}
.MICR img {
height: 1em;
margin: 0 0.2em;
}
.MICR > img {
margin: 0 -0.1em;
}
.routing {
}
.MICR:hover .routing {
/*display: none;*/
}
.inroute {
display: none;
}
.inroute input,
.inaccount input {
margin-top: -0.3em;
font-size: 1.4em;
width: 9em;
position: absolute;
z-index: -1;
}
.inroute, .inaccount {
display: inline;
}
.inroute input:focus,
.inaccount input:focus {
position: initial;
}
.inroute input:focus + span,
.inaccount input:focus + span {
display: none;
}
.account {
padding: 0 0 0 1.5em;
}
.MICR .numbers {
float: right;
padding: 0 0 0 2em;
}
.back {
font-family: Arial;
}
.back .height {
height: 21em;
position: relative;
}
.back .side {
position: absolute;
top: 100%;
width: 21em;
height: 5em;
padding: 0.5em;
transform-origin: 0em 0em;
transform: rotateZ(-90deg);
}
.back .accept {
position: relative;
float: left;
width: 30%;
height: 100%;
}
.back .original {
position: relative;
float: left;
width: 50%;
height: 100%;
background: #EEE;
}
.back .security {
position: relative;
float: left;
width: 20%;
height: 100%;
background: #EEE;
border: solid black 1px;
}
.back .what {
float: none;
color: #AAA;
}
.back .endorse {
font-size: 2.2em;
font-family: 'Yellowtail', cursive;
border-bottom: solid black 1px;
}
.back .institution {
text-align: center;
margin-top: -3em;
}
.back .institution .small {
font-size: 90%;
}
.back .document {
text-align: center;
color: white;
font-size: 4em;
}
.back .security a {
color: #999;
}
.send, .help {
font-family: Arial;
clear: both;
margin: 0 auto;
padding: 0 2%;
text-align: center;
color: #444;
}
.send .submit input,
.send .submit button {
width: 15em;
height: 3em;
font-size: 1.2em;
border: 0em;
padding: 0;
text-align: center;
}
.send .submit input {
width: 15em !important;
height: 1.3em;
color: white;
background: black;
font-family: Arial;
border-bottom: dashed #AAA 0.1em;
}
.send .submit input:hover {
color: goldenrod;
}
.send .submit button {
width: 4.4em;
color: white;
background-color: #3BCE76;
background: black;
-webkit-transition: color 1s;
transition: color 1s;
}
.send .submit button:hover {
color: #3BCE76;
-webkit-transition: color 1s;
transition: color 1s;
}
.notice {
width: 80%;
margin: 0 auto;
text-align: justify;
overflow: hidden;
}
.notice:hover {
font-size: 18pt;
color: white;
transition: all 0.2s;
padding-bottom: 3em;
}
.open {
text-align: center;
color: white;
}
.open img {
height: 3em;
margin: 0 1em;
}
.error {
outline: red 3px solid;
transition: all 0.5s;
}
.envelope label {
position: absolute;
top: 0px;
left: 24px;
pointer-events: none !important;
opacity: 0.7;
}
.flipit label {
/* don't show labels when check is being presented */
display: none;
}
div.address + label {
top: 16px;
}
[blank="false"] + label {
display: none;
}
.amounts .font::first-letter {
text-transform: capitalize;
}
#app {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
width: 100%; min-height: 100vh;
overflow: scroll;
font-size: 12pt;
line-height: initial;
}
#app input {
width: initial;
}
#tray {
margin-top: 99vh;
background: black;
}
.mid-screen {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
[x-cloak] {
display: none !important;
}
</style>
<div id="app">
<div class="envelope">
<div class="flip">
<div class="vertical">
<div class="front">
<div class="check">
<div class="designer"></div>
<div class="paper">
<div class="row">
<div class="address" contenteditable="true"></div>
<label>Your Name<br>Your Address<br>City, STATE ZIP</label>
<div class="numbers top">
<div class="number" contenteditable="true" for="numbera"></div>
<label>5000</label>
</div>
</div>
<div class="row">
<div class="fractional">
<div class="numbers">
<div class="fraction" contenteditable="true"></div>
<label>XX-YYYY/ZZZZ</label>
</div>
</div>
<div class="when">
<div class="date"><div class="font Lace" contenteditable="true"> </div></div>
<span class="what">DATE</span>
</div>
</div>
<div class="row">
<div class="who">
<div class="what">PAY TO THE ORDER OF</div>
<div class="payee">
<div class="font Lace" contenteditable="true"></div>
<label>Payee</label>
</div>
<div class="currency">
$
</div>
<div class="amount">
<div class="font Lace" contenteditable="true"></div>
<label>00.00</label>
</div>
</div>
</div>
<div class="row">
<div class="moneys">
<div class="amounts">
<div class="font Lace" contenteditable="true"></div>
<label>Zero and 0/100 --------------</label>
</div>
<span class="what">Dollars</span>
<div><img class="lock" src="./lock.png"></div>
<span class="what details">Security Features detailed on back</span>
</div>
</div>
<div class="row">
<div class="bank" contenteditable="true"></div>
<label>Your Bank<br>Bank's Address<br>City, STATE ZIP</label>
</div>
<div class="row">
<div class="why">
<div class="what">For</div>
<div class="memo"><div class="font Lace" contenteditable="true"> </div></div>
<div class="signature">
<div class="font" contenteditable="true"></div>
<label>signature</label>
</div>
</div>
</div>
<div class="scan row">
<div class="MICR">
<img src="MICR/c.png">
<div class="inroute">
<input for="routing" placeholder="routing number" autocomplete="off">
<span class="routing">
<img src="MICR/0.png"><img src="MICR/1.png"><img src="MICR/2.png"><img src="MICR/3.png"><img src="MICR/4.png"><img src="MICR/5.png"><img src="MICR/6.png"><img src="MICR/7.png"><img src="MICR/8.png"><img src="MICR/9.png">
</span>
</div>
<img src="MICR/c.png">
<div class="inaccount">
<input for="account" placeholder="account number" autocomplete="off">
<span class="account">
<img src="MICR/0.png"><img src="MICR/1.png"><img src="MICR/2.png"><img src="MICR/3.png"><img src="MICR/4.png"><img src="MICR/5.png"><img src="MICR/6.png"><img src="MICR/7.png"><img src="MICR/8.png"><img src="MICR/9.png">
</span>
</div>
<img src="MICR/p.png">
<div class="numbers">
<span class="numbera">
<img src="MICR/5.png">
<img src="MICR/0.png">
<img src="MICR/0.png">
<img src="MICR/0.png">
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="back">
<div class="check">
<div class="paper">
<div class="height">
<div class="accept">
<div class="side">
<div class="what">
ENDORSE HERE
</div>
<div class="endorse"><div class="font" contenteditable="true"></div></div>
<div class="endorse"><div class="font" contenteditable="true"></div></div>
</div>
</div>
<div class="original">
<div class="side">
<div class="what institution">
<span>DO NOT WRITE, STAMP OR SIGN BELOW THIS LINE</span>
<span class="small">RESERVED FOR FINANCIAL INSTITUTION USE</span>
</div>
</div>
<div class="document">
</br>ORIGINAL DOCUMENT
</div>
</div>
<div class="security">
<div class="side">
<div class="what features">
<span>Security Features listed below:</span>
<ul>
<li>Government grade encryption (AES)</li>
<li>Data loaded over secure channels (HTTPS)</li>
<li>Decryption keys are never sent to the servers</li>
<li>This is a legal copy of your check. You can use it the same way you would use the original check.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="send none">
<div class="submit">
<input placeholder="person.to.pay@example.com"><a id="go" target="_blank"><button>send</button></a>
</div>
<div class="open none">
choose:<br/><br/>
<a class="email" href="#" target="_blank"><img src="./email.png"></a>
<a class="gmail" href="#" target="_blank"><img src="./gmail.png"></a>
</div>
<div class="notice">
<p class="what">* Your account number is end-to-end encrypted with government grade standards (AES) and the decryption key is never transmitted to the servers. Only the email you are sending the check to will have access to the decryption key. Checks may be void after 30 days, as data may be deleted for added security. Checkard is only compatible with USA Banks that support mobile deposited checks.
<p class="what">Instructions: To pay someone, fill in the digital check by copying information from your physical check. Then type in their email address, hit send, and choose your email provider.</p>
</div>
</div>
<div class="end">
</div>
</div>
<div id="tray" class="card">
</div>
<script src="https://cdn.jsdelivr.net/npm/gun/examples/jquery.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/lib/webrtc.js"></script>
<script>
;(function(){
app.load = function load(url){
$('#tray').append($('<div>').load(url));
}
//localStorage.clear();
// could also be: var key, code = location.hash.split(':'), or split including
var hash = location.hash.split(':'), key, code;
key = hash[0].slice(1);
code = hash[1];
var gun = app.gun = GUN(['https://test.era.eco/gun','https://59.thesource.fm/gun','https://try.axe.eco/gun','https://relay.129.153.59.37.nip.io/gun']); // data is end-to-end encrypted BEFORE using these relays to send data.
// console.warn(gun)
if(key && code){
app.filled = true;
$('.flip').toggleClass('flipit');
$('#tray').css({'margin-top': '102vh'}); // on deposit, force scroll.
$('.envelope').addClass('mid-screen'); // default for now
$("[contenteditable]:not(.endorse .font)").attr('contenteditable', false);
load.to = setTimeout(load, 3000);
gun.get(key).on(load);
async function load(data){
if(!data){
$('.payee').text(app.err = "CHECK NOT FOUND");
$('.amounts').text("Please make sure payer is also online, see instructions below.");
return;
}
clearTimeout(load.to);
var msg = data[1]||data.en;
var check = await de(msg, code);
setTimeout(()=>$('.amount, .amounts, .memo, .payee, .signature, .endorse').trigger('keyup'),9);
// console.warn(check)
if(!check){
$('.amounts').text(app.err = "Invalid decryption password");
return;
}
$('.address').text(check.address);
$('.date .font').text(check.date.replace(/\//g, '-'));
$('.payee .font').text(check.payee.replace('_',' '));
$('.amount .font').text(check.amount);
$('.amounts .font').text(check.amounts.replace(/\//g, '⁄'));
$('.bank').text(check.bank);
$('.memo .font').text(check.memo);
$('.fraction').text(check.fraction);
$('.signature .font').text(check.signature);
$('.inroute input').val(check.routing);
$('.inaccount input').val(check.account);
$('.number').text(check.number);
micr.call($('.inroute input'));
micr.call($('.inaccount input'));
micr.call($('.number'));
};
return;
} else { app.filled = false }
/* try and parse the querystring for values, convert to regular object for dot notation */
var params = Object.fromEntries((new URLSearchParams(location.search)).entries());
// param takes precedence over today's date but fill it in either way
$('.date .font').text(params.date || new Date().toLocaleDateString("en-US").replace(/\//g, '-')).attr("blank", false);
params.payee && $('.payee .font').text(params.payee.replace('_',' ')).attr("blank", false);
params.pay && $('.payee .font').text(params.pay.replace('_',' ')).attr("blank", false);
params.amount && $('.amount .font').text(params.amount).attr("blank", false);
params.amounts && $('.amounts .font').text(params.amounts).attr("blank", false);
params.bank && $('.bank').text(params.bank).attr("blank", false);
params.memo && $('.memo .font').text(params.memo).attr("blank", false);
params.to && $('.submit input').val(params.to).attr("blank", false);
params.email && $('.submit input').val(params.email).attr("blank", false);
/* expected from the recipient */
// $('.address')
// $('.fraction')
// $('.signature .font')
// $('.inroute input')
// $('.inaccount input')
// $('.number')
$('.inroute input').on('keyup', micr);
$('.inaccount input').on('keyup', micr);
$('.top .number').on('keyup', micr);
$('[contenteditable="true"]').on('input', maybeBlank);
$('[contenteditable="true"]:not(.address):not(.bank):not(.fraction)').on('keydown', eve => {if(eve.key == 'Enter'){eve.preventDefault()}});
$('.account').on('mousedown', eve => {eve.preventDefault(); $('input[for="account"]').focus();});
$('.routing').on('mousedown', eve => {eve.preventDefault(); $('input[for="routing"]').focus();});
function maybeBlank({target}){
target.setAttribute("blank", !target.textContent.trim())
}
function micr(eve){ eve = eve || '';
if(!key){ code += eve.timeStamp / eve.which } // increase entropy
var chars = $(this).val() || $(this).text();
chars = (chars||'0000').replace(/\D/ig, '').split('');
var as = $('.' + $(this).attr('for')).empty();
$.each(chars, function(i, c){
as.append($('<img> ').attr('src', './MICR/' + c + '.png'));
});
}
code = Math.random(); // mix with keystrokes to increase random
$('.send').removeClass('none');
$('.send button').on('click', async function(){
var check = {
address: $('.address')[0].innerText.trim(), // innerText preserve newlines cross-browser
date: $('.date').text().trim(),
payee: $('.payee .font').text().trim(),
amount: $('.amount .font').text().trim(),
amounts: $('.amounts .font').text().trim(),
bank: $('.bank')[0].innerText.trim(),
memo: $('.memo').text().trim(),
fraction: $('.fraction').text().trim(),
signature: $('.signature .font').text().trim(),
routing: $('.inroute input').val(),
account: $('.inaccount input').val(),
number: $('.number').text().trim()
//number: $('.number input').first().val() || $('.number input').last().val()
};
// console.warn(check)
if(!check.account || !check.routing){ return err('.MICR') }
if(!check.number){ return err('.number') }
if(!check.payee){ return err('.payee') }
if(!check.amount){ return err('.amount') }
if(!check.date){ return err('.date') }
if(!check.signature){ return err('.signature') }
if(!check.fraction){ return err('.fraction') }
//TODO: document the method of comparing the fraction against routing
//var tmp = check.fraction.split('/').slice(-1)[0];
//if(tmp != check.routing.slice(0, tmp.length)){ return err('.fraction'), err('.inaccount') }
$("[contenteditable]").attr('contenteditable', false);
code = ((code||Math.random()) - Math.random()).toString(32).replace('.','');
key = Math.random().toString(32).slice(2);
emailize(check.amount, check.memo);
$('.submit').addClass('none');
$('.open').removeClass('none');
if(screen.width < screen.height){
$('#go').attr('href', $('.email').attr('href'));
}
var msg = await en(check, code);
gun.get(key).put({'1': msg});
code = null;
});
function emailize(amount, memo){
var email = $('.submit input').val();
var subject = "$" + amount + (
memo.match(/\w/ig)?
" for " + memo
: " Payment!");
var body = "You've got money! You can immediately deposit it by opening this link on your computer:%0D%0A%0D%0A"
+ "https://checkard.com/%23" + key + ':' + code
+ "%0D%0A%0D%0AInstructions: Open checkard on your computer to endorse the check, then on your phone open your bank's official app and use it to take a picture of the front and back of the check to mobile deposit it."
+ "%0D%0A%0D%0AWarning: Do not forward this email to anyone, as it contains the decryption keys for confidential information. The encrypted check may be deleted and become void after 30 days for security reasons."
+ "%0D%0A%0D%0AEnjoy!";
$('.gmail').attr('href', "https://mail.google.com/mail/?view=cm&fs=1&to="
+ email
+ "&su="
+ subject
+ "&body="
+ body
);
$('.email').attr('href', "mailto:"
+ email
+ "?subject="
+ subject
+ "&body="
+ body
);
};
function err(s){
$(s).addClass('error')
setTimeout(function(){ $(s).removeClass('error') }, 5000);
}
async function en(m, p){
return await SEA.encrypt(m, p);
};
async function de(m, p){
return await SEA.decrypt(m, p);
};
var text = $.prototype.text;
$.prototype.texts = function(a){
if(a){ return text.call(this, a) }
var html = this.html();
html = html.replace(/\<div\>/ig, '\n').replace(/\<\/div\>/ig,'').replace(/\<br\>/ig, '\n').replace(/\<\/br\>/ig, '\n').replace(/[<=:]/ig,'').replace(/&#/ig,'');
this.html(html); // THIS IS SAFE, because its only reusing HTML it already had, not remote.
return text.call(this);
}