-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
executable file
·1075 lines (940 loc) · 53.6 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
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 http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/leaflet.css'>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script type="text/javascript" src="dist/bwip-js-min.js"></script>
<script language="javascript">
var s4tPrimaryIdentifiers=[
{"code":'00',"label":'SSCC',"grouping":'PrimaryIdentifiers',"datatype":"xsd:string","definition":'Serial Shipping Container Code (SSCC)',"example":"195212342345678909","percentEncoded":false,"pattern":"[0-9]{18}"},
{"code":'401',"label":'GINC',"grouping":'PrimaryIdentifiers',"datatype":"xsd:string","definition":'Global Identification Number for Consignment (GINC)',"example":"9521234ABC12345","percentEncoded":false,"pattern":"[0-9]{4}.{0,26}"},
{"code":'402',"label":'GSIN',"grouping":'PrimaryIdentifiers',"datatype":"xsd:string","definition":'Global Shipment Identification Number (GSIN)',"example":"95212340000000013","percentEncoded":false,"pattern":"[0-9]{17}"}
];
var countryCodes={"AF":"Afghanistan","AX":"Åland Islands","AL":"Albania","DZ":"Algeria","AS":"American Samoa","AD":"Andorra","AO":"Angola","AI":"Anguilla","AQ":"Antarctica","AG":"Antigua and Barbuda","AR":"Argentina","AM":"Armenia","AW":"Aruba","AU":"Australia","AT":"Austria","AZ":"Azerbaijan","BS":"Bahamas","BH":"Bahrain","BD":"Bangladesh","BB":"Barbados","BY":"Belarus","BE":"Belgium","BZ":"Belize","BJ":"Benin","BM":"Bermuda","BT":"Bhutan","BT":"Bhutan","BO":"Bolivia (Plurinational State of)","BO":"Bolivia (Plurinational State of)","BQ":"Bonaire, Sint Eustatius and Saba","BA":"Bosnia and Herzegovina","BW":"Botswana","BV":"Bouvet Island","BR":"Brazil","IO":"British Indian Ocean Territory","BN":"Brunei Darussalam","BG":"Bulgaria","BF":"Burkina Faso","BI":"Burundi","KH":"Cambodia","CM":"Cameroon","CA":"Canada","CV":"Cabo Verde","KY":"Cayman Islands","CF":"Central African Republic","TD":"Chad","CL":"Chile","CL":"Chile","CN":"China","CX":"Christmas Island","CC":"Cocos (Keeling) Islands","CO":"Colombia","CO":"Colombia","KM":"Comoros","CG":"Congo","CD":"Congo (Democratic Republic of the)","CK":"Cook Islands","CR":"Costa Rica","CI":"Côte d'Ivoire","HR":"Croatia","CU":"Cuba","CU":"Cuba","CW":"Curaçao","CY":"Cyprus","CZ":"Czech Republic","DK":"Denmark","DJ":"Djibouti","DM":"Dominica","DO":"Dominican Republic","EC":"Ecuador","EG":"Egypt","SV":"El Salvador","SV":"El Salvador","GQ":"Equatorial Guinea","ER":"Eritrea","EE":"Estonia","ET":"Ethiopia","FK":"Falkland Islands (Malvinas)","FO":"Faroe Islands","FJ":"Fiji","FI":"Finland","FR":"France","GF":"French Guiana","PF":"French Polynesia","TF":"French Southern Territories","GA":"Gabon","GM":"Gambia","GE":"Georgia","DE":"Germany","GH":"Ghana","GI":"Gibraltar","GR":"Greece","GL":"Greenland","GD":"Grenada","GP":"Guadeloupe","GU":"Guam","GT":"Guatemala","GG":"Guernsey","GN":"Guinea","GW":"Guinea-Bissau","GY":"Guyana","HT":"Haiti","HT":"Haiti","HM":"Heard Island and McDonald Islands","VA":"Holy See","HN":"Honduras","HK":"Hong Kong","HU":"Hungary","IS":"Iceland","IN":"India","ID":"Indonesia","IR":"Iran (Islamic Republic of)","IQ":"Iraq","IE":"Ireland","IM":"Isle of Man","IL":"Israel","IT":"Italy","JM":"Jamaica","JP":"Japan","JE":"Jersey","JO":"Jordan","KZ":"Kazakhstan","KE":"Kenya","KI":"Kiribati","KP":"Korea (Democratic People's Republic of)","KR":"Korea (Republic of)","KW":"Kuwait","KG":"Kyrgyzstan","LA":"Lao People's Democratic Republic","LV":"Latvia","LB":"Lebanon","LS":"Lesotho","LS":"Lesotho","LR":"Liberia","LY":"Libya","LI":"Liechtenstein","LT":"Lithuania","LU":"Luxembourg","MO":"Macao","MK":"Macedonia (the former Yugoslav Republic of)","MG":"Madagascar","MW":"Malawi","MY":"Malaysia","MV":"Maldives","ML":"Mali","MT":"Malta","MH":"Marshall Islands","MQ":"Martinique","MR":"Mauritania","MU":"Mauritius","YT":"Mayotte","MX":"Mexico","MX":"Mexico","FM":"Micronesia (Federated States of)","MD":"Moldova (Republic of)","MC":"Monaco","MN":"Mongolia","ME":"Montenegro","MS":"Montserrat","MA":"Morocco","MZ":"Mozambique","MM":"Myanmar","NA":"Namibia","NA":"Namibia","NR":"Nauru","NP":"Nepal","NL":"Netherlands","NC":"New Caledonia","NZ":"New Zealand","NI":"Nicaragua","NE":"Niger","NG":"Nigeria","NU":"Niue","NF":"Norfolk Island","MP":"Northern Mariana Islands","NO":"Norway","OM":"Oman","PK":"Pakistan","PW":"Palau","PS":"Palestine, State of","PA":"Panama","PA":"Panama","PG":"Papua New Guinea","PY":"Paraguay","PE":"Peru","PH":"Philippines","PN":"Pitcairn","PL":"Poland","PT":"Portugal","PR":"Puerto Rico","QA":"Qatar","RE":"Réunion","RO":"Romania","RU":"Russian Federation","RW":"Rwanda","BL":"Saint Barthélemy","SH":"Saint Helena, Ascension and Tristan da Cunha","KN":"Saint Kitts and Nevis","LC":"Saint Lucia","MF":"Saint Martin (French part)","PM":"Saint Pierre and Miquelon","VC":"Saint Vincent and the Grenadines","WS":"Samoa","SM":"San Marino","ST":"Sao Tome and Principe","SA":"Saudi Arabia","SN":"Senegal","RS":"Serbia","SC":"Seychelles","SL":"Sierra Leone","SG":"Singapore","SX":"Sint Maarten (Dutch part)","SK":"Slovakia","SI":"Slovenia","SB":"Solomon Islands","SO":"Somalia","ZA":"South Africa","GS":"South Georgia and the South Sandwich Islands","SS":"South Sudan","ES":"Spain","LK":"Sri Lanka","SD":"Sudan","SR":"Suriname","SJ":"Svalbard and Jan Mayen","SZ":"Swaziland","SE":"Sweden","CH":"Switzerland","SY":"Syrian Arab Republic","TW":"Taiwan, Province of China","TJ":"Tajikistan","TZ":"Tanzania, United Republic of","TH":"Thailand","TL":"Timor-Leste","TG":"Togo","TK":"Tokelau","TO":"Tonga","TT":"Trinidad and Tobago","TN":"Tunisia","TR":"Turkey","TM":"Turkmenistan","TC":"Turks and Caicos Islands","TV":"Tuvalu","UG":"Uganda","UA":"Ukraine","AE":"United Arab Emirates","GB":"United Kingdom of Great Britain and Northern Ireland","US":"United States of America","UM":"United States Minor Outlying Islands","UY":"Uruguay","UY":"Uruguay","UZ":"Uzbekistan","VU":"Vanuatu","VE":"Venezuela (Bolivarian Republic of)","VN":"Viet Nam","VG":"Virgin Islands (British)","VI":"Virgin Islands (U.S.)","WF":"Wallis and Futuna","EH":"Western Sahara","YE":"Yemen","ZM":"Zambia","ZW":"Zimbabwe"};
var s4tTerms=[
{"code":'330n',"label":'Logistic Weight (kg)',"grouping":'Measurements',"datatype":"gs1:Measurement","definition":'Logistic weight (kg)',"example":"13.542","unit":"kg","percentEncoded":false},
{"code":'331n',"label":'Length of first dimension (m)',"grouping":'Measurements',"datatype":"gs1:Measurement","definition":'Length of first dimension (m)',"example":"0.75","unit":"m","percentEncoded":false},
{"code":'332n',"label":'Width of second dimension (m)',"grouping":'Measurements',"datatype":"gs1:Measurement","definition":'Width of second dimension (m)',"example":"0.55","unit":"m","percentEncoded":false},
{"code":'333n',"label":'Depth, thickness, height (m)',"grouping":'Measurements',"datatype":"gs1:Measurement","definition":'Depth, thickness, height or third dimension (m)',"example":"0.35","unit":"m","percentEncoded":false},
{"code":'336n',"label":'Logistic volume (cubic metres)',"grouping":'Measurements',"datatype":"gs1:Measurement","definition":'Logistic volume (cubic metres)',"example":"0.085","unit":"m^3","percentEncoded":false},
{"code":'4300',"label":'Ship-to / Deliver-to company',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Name of the company and/or per receiving the freight unit',"example":"Café Niçoise at GS1 AISBL","percentEncoded":true},
{"code":'4301',"label":'Ship-to / Deliver-to contact',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Name of the company and/or per receiving the freight unit',"example":"Jaco Voorspuij","percentEncoded":true},
{"code":'4302',"label":'Ship-to / Deliver-to address line 1',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Receiving company/residential street address (Line 1)',"example":"Avenue Louise 326","percentEncoded":true},
{"code":'4303',"label":'Ship-to / Deliver-to address line 2',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Receiving company/residential street address (Line 2)',"example":"Blue Tower","percentEncoded":true},
{"code":'4304',"label":'Ship-to / Deliver-to suburb',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Receiving company/residential Suburb',"example":"Ixelles","percentEncoded":true},
{"code":'4305',"label":'Ship-to / Deliver-to locality (town/city)',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Receiving company/residential Locality (town/city)',"example":"Bruxelles","percentEncoded":true},
{"code":'4306',"label":'Ship-to / Deliver-to region (state/county)',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Receiving company Region (state/county)',"example":"Brussels-Capital Region","percentEncoded":true},
{"code":'4307',"label":'Ship-to / Deliver-to country code',"grouping":'ShippingAddressInformation',"datatype":"gs1:CountryCode","definition":'Receiving company/residential Country',"example":"BE","percentEncoded":false},
{"code":'420',"label":'Ship-to / Deliver-to postal code',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Receiving company/residential Postcode',"example":"1050","percentEncoded":false},
{"code":'4308',"label":'Ship-to / Deliver-to phone number',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'Contact phone number for the receiver of the freight unit. Used to populate the system when no EDI has been received','example':"+32 2 788 78 00","percentEncoded":false},
{"code":'4309',"label":'Ship-to / Deliver-to geocode',"grouping":'ShippingAddressInformation',"datatype":"xsd:string","definition":'20-digit geocode representing WGS84 latitude,/longitude for ship-to/deliver-to location','example':"14220219500001282028","percentEncoded":false,"geocode":true},
{"code":'4310',"label":'Return-to company name',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Company name for the return to address',"example":"GS1 Global Office","percentEncoded":true},
{"code":'4311',"label":'Return-to contact',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Name of the contact freight unit is to be returned to',"example":"Dan Mullen","percentEncoded":true},
{"code":'4312',"label":'Return-to address line 1',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Return to company/residential street address (Line 1)',"example":"300 Charles Ewing Boulevard","percentEncoded":true},
{"code":'4313',"label":'Return-to address line 2',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Return to company/residential street address (Line 2)',"example":"Ground Floor Suite","percentEncoded":true},
{"code":'4314',"label":'Return-to suburb',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Return to company/residential Suburb',"example":"Ewingville","percentEncoded":true},
{"code":'4315',"label":'Return-to locality (town/city)',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Return to company/residential Locality (town/city)',"example":"Ewing","percentEncoded":true},
{"code":'4316',"label":'Return-to region (state/county)',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Return to company/residential Region (state/county)',"example":"New Jersey","percentEncoded":true},
{"code":'4317',"label":'Return-to country code',"grouping":'ReturnAddressInformation',"datatype":"gs1:CountryCode","definition":'Return to company/residential Country',"example":"US","percentEncoded":false},
{"code":'4318',"label":'Return-to postal code',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Return to company/residential Postcode',"example":"08628","percentEncoded":false},
{"code":'4319',"label":'Return-to phone number',"grouping":'ReturnAddressInformation',"datatype":"xsd:string","definition":'Contact phone number for the receiver of the freight unit. Used to populate the system when no EDI has been received','example':"+32 2 788 78 00","percentEncoded":false},
{"code":'4320',"label":'Service code description',"grouping":'TransportTaskInformation',"datatype":"xsd:string","definition":'Freight service code specifies if it is a standard, express, overnight, same day service, etc. This will be unique to the shipper.',"example":"express","percentEncoded":true},
{"code":'4321',"label":'Dangerous goods flag',"grouping":'FreightUnitInformation',"datatype":"xsd:boolean","definition":'A flag to indicate if the freight unit contains Dangerous Goods',"example":"0","percentEncoded":false},
{"code":'4322',"label":'Authority to leave',"grouping":'DeliveryInstructions',"datatype":"xsd:boolean","definition":'This indicates to the operator that he/she may leave the transport unit at the destination location. Implies the operator does not need to hand the transport unit over to a person. Also implies no signature from recipient is required.',"example":"0","percentEncoded":false},
{"code":'4323',"label":'Signature required flag',"grouping":'DeliveryInstructions',"datatype":"xsd:boolean","definition":'This indicates to the operator that the operator must get a signature from the recipient for having delivered the transport unit to the intended destination. This implies that delivery must be made to a person.',"example":"1","percentEncoded":false},
{"code":'4324',"label":'Not before delivery date time',"grouping":'DeliveryInstructions',"datatype":"xsd:dateTime","definition":'In transportation, it is a common business requirement to not deliver before a set date.',"example":"2020-01-18T00:00","percentEncoded":false},
{"code":'4325',"label":'Not after delivery date time',"grouping":'DeliveryInstructions',"datatype":"xsd:dateTime","definition":'In transportation, it is a common business requirement to deliver before a set date.',"example":"2020-01-25T00:00","percentEncoded":false},
{"code":'4326',"label":'Release date',"grouping":'DeliveryInstructions',"datatype":"xsd:date","definition":"Sometimes transport service providers are required to 'hold' transport units for a while before these transport units are allowed to be sent out to recipients.","example":"2020-01-15","percentEncoded":false},
{"code":'401',"label":'GINC',"grouping":'OtherIdentifiers',"datatype":"xsd:string","definition":'Global Identification Number for Consignment (GINC)',"example":"9521234ABC12345","percentEncoded":false},
{"code":'402',"label":'GSIN',"grouping":'OtherIdentifiers',"datatype":"xsd:string","definition":'Global Shipment Identification Number (GSIN)',"example":"95212340000000012","percentEncoded":false},
{"code":'8003',"label":'GRAI',"grouping":'OtherIdentifiers',"datatype":"xsd:string","definition":'Global Returnable Asset Identifier (GRAI)',"example":"095211411234545678","percentEncoded":false,"pattern":"(\d{14})([\x21-\x22\x25-\x2F\x30-\x39\x3A-\x3F\x41-\x5A\x5F\x61-\x7A]{0,16})"},
{"code":'403',"label":'Routing code',"grouping":'OtherIdentifiers',"datatype":"xsd:string","definition":'Routing Code: AI(403)',"example":"DEF19485","percentEncoded":false},
{"code":'410',"label":'Ship-to / Deliver-to GLN',"grouping":'OtherIdentifiers',"datatype":"xsd:string","definition":'Ship-to / Deliver-to GLN',"example":"9529876987655","percentEncoded":false},
{"code":'413',"label":'Ship-for / Deliver-for GLN',"grouping":'OtherIdentifiers',"datatype":"xsd:string","definition":'Ship-for / Deliver-for GLN',"example":"9529876567895","percentEncoded":false}
];
var demoAddresses=[
{"label":"JP - GS1 Japan","4300":"GS1 Japan","4301":"ヨッシー","4302":"9F, Shin Aoyama Bldg., East","4303":"1-1-1, Minami Aoyama","4304":"Minato-ku","4305":"Tokyo","420":"107-0062","4307":"JP","lat":"35.6724794","lon":"139.7247291"},
{"label":"FR - GS1 France","4300":"GS1 France","4302":"21, boulevard Haussmann","4305":"Paris","420":"75009","4307":"FR","lat":"48.8725873","lon":"2.333899"},
{"label":"FR - Transport LAMBOLLEY","4300":"Transport LAMBOLLEY","4302":"Zone Industrielle des feuilles, Zone A","4303":"21 Rue des entrepôts","4305":"SEYSSUEL","420":"38200","4307":"FR"},
{"label":"IE - GS1 Ireland","4300":"GS1 Ireland","4302":"2nd Floor, The Merrion Centre","4303":"Nutley Lane","4304":"Donnybrook","4305":"Dublin 4","4306":"County Dublin","420":"D04KF62","4307":"IE","lat":"53.3187097","lon":"-6.2133590"},
{"label":"US - GS1","4300":"GS1","4302":"300 Charles Ewing Blvd.","4305":"Ewing Township","420":"08628","4307":"US","lat":"40.2867254","lon":"-74.7893725"},
{"label":"AU - GS1 Australia","4300":"GS1 Australia Melbourne Office","4302":"Nexus Business Park","4303":"8 Nexus Court","4304":"Mulgrave","4305":"Melbourne","420":"3170","4306":"Victoria","4307":"AU","lat":"-37.9089017","lon":"145.1592176"},
{"label":"BR - GS1 Brasil","4300":"GS1 Brasil","4302":"Av. 9 de Julho, 3183","4303":"Apt 125","4304":"Jardim Paulista","4305":"São Paulo","420":"CEP 01407-000","4306":"SP","4307":"BR","lat":"-23.5680013","lon":"-46.6596382"}
];
function filterByGrouping(grouping) {
return function(element) {
return element.grouping==grouping;
};
}
function filterExcludeGrouping(grouping) {
return function(element) {
return element.grouping!==grouping;
};
}
function filterByLabel(id) {
return function(element) {
return element.label==id;
};
}
function filterExcludeLabel(id) {
return function(element) {
return element.label!==id;
};
}
function gs1date(xsdDate) {
return xsdDate.replace(/\d\d(\d\d)-(\d\d)-(\d\d)/,"$1$2$3");
}
function gs1dateTime(xsdDateTime) {
return xsdDateTime.replace(/\d\d(\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d)/,"$1$2$3$4$5");
}
function gs1measurement(val) {
var ndp=0;
var rv={};
var numeric="";
if (val.indexOf(".")> -1) {
var parts=val.split(".");
ndp=parts[1].length;
numeric=parts[0]+parts[1];
} else {
numeric=val;
}
if (numeric.length < 6) {
numeric="0".repeat(6-numeric.length)+numeric;
}
rv.ndp=ndp;
rv.sixdigit=numeric;
return rv;
}
function latlon2geocode(lat,lon) {
function pad10(str) {
return "0".repeat(10-str.length)+str;
}
let rv="";
if ((lat!=="") && (lon !=="")) {
let la=parseFloat(lat);
let lo=parseFloat(lon);
if (lo < 0) {
lo+=360;
}
la+=90;
let lat7=Math.floor(la*1e7+0.499);
let lon7=Math.floor(lo*1e7+0.499);
rv= pad10(lat7.toString())+pad10(lon7.toString());
}
return rv;
}
function geocode2latlon(geocode) {
function truncateAfter7Digits(str) {
let re=new RegExp('^([-]?\\d+\\.\\d{7})(\\d+)$');
if (re.test(str)) {
let arr = re.exec(str);
return arr[1];
} else {
return str;
}
}
let re=new RegExp('^[0-9]{20}$');
if ( (geocode !=="") && (re.test(geocode)) ) {
let clat=geocode.substr(0,10);
let clon=geocode.substr(10,10);
let lat=(parseInt(clat)-900000000)/1e7;
let lon=parseInt(clon)/1.00000000e7;
if (lon > 180) {
lon -=360;
}
return {"lat":truncateAfter7Digits(lat.toString()),"lon":truncateAfter7Digits(lon.toString())};
} else {
return {}
}
}
function osmMapURL(lat,lon) {
if ((lat!=="")&&(lon!=="")){
return "https://www.openstreetmap.org/?mlat="+lat+"+&mlon="+lon+"#map=18/"+lat+"/"+lon;
} else {
return "";
}
}
function processS4Tarray(s4tTermsF) {
var orderedKeys=[];
var obj={};
var rv={};
s4tTermsF.forEach(function(element) {
orderedKeys.push(element.code);
obj[element.code]=element;
});
rv.orderedKeys=orderedKeys;
rv.obj=obj;
return rv;
}
var s4tObj=processS4Tarray(s4tTerms);
var mode=0;
var zeroToFive=["0","1","2","3","4","5"];
var shipToLat="";
var shipToLon="";
</script>
<style type="text/css">
body { font-family: Verdana; }
h1 {text-align: center;}
h2 {text-align: center;}
tr.transportTaskInfo { background-color: #FFCCCC;}
tr.shippingAddress { background-color: #FFFFCC;}
tr.deliveryInstructions { background-color: #CCFFCC;}
tr.returnAddress { background-color: #CCCCFF;}
tr.freightUnitInformation { background-color: #CCFFFF;}
tr.otherIdentifiers { background-color: #FFCC99;}
tr.measurements { background-color: #D9D9D9;}
td.label {text-align: right; font-weight: 700;}
div.qrpanel1 {float: right; width: 49%;}
div.qrpanel2 {float: left; width: 49%;}
table#inputData {float: left;}
table#decodedData {float: right;}
textarea#dlOutput { width: 100%; font-size: 1em; height: 140px; overflow-y: scroll;}
textarea#elsOutput { width: 100%; font-size: 1em; height: 140px; overflow-y: scroll;}
textarea#dlInput { width: 100%; font-size: 1em; height: 140px; overflow-y: scroll;}
textarea#elsInput { width: 100%; font-size: 1em; height: 140px; overflow-y: scroll;}
td.s4tCode {text-align: center;}
input.maxWidth {width: 100%;}
div#symbol2D {position: absolute; top: calc(9em + 155px); left: 50%; width: 50%; }
div#stats {position: absolute; right: 2%; width: 48%; height: 1em; text-align: center; }
div#navbar {width: 100%; height: 1.5em;}
input.navbutton {width: 49%; text-align: center; font-weight: 700;}
input#encode { float: left; }
input#decode {float: right; }
.activeButton {background-color: #000099; color: #FFFFFF;}
.inactiveButton {background-color: #FFFFFF; color: #000099;}
table#size tr th {text-align: center;}
div#inputform {width: 49%; float: left}
div#decoded {width: 49%; float: right}
canvas {border: 16px solid white; background-color: #FFFFFF; margin-left: auto; margin-right: auto; }
.hidden {display: none;}
.selectCode {font-size: 1.2em; font-weight: 700;}
.geocode {width: 20em; background-color: #FFFFCC;}
#map { width:calc(100% - 100px); height: 500px; }
.showing {visibility: show; height:500px;}
.hidden {visibility: hidden; height: 0px;}
.showmap {background-color: #00FF00; font-weight: 700; border-radius: 12px;}
.hidemap {background-color: #FF0000; font-weight: 700; color: #FFFFFF; border-radius: 12px;}
</style>
</head>
<body>
<script src='https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.2.0/leaflet.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/Turf.js/5.0.4/turf.min.js'></script>
<h1>GS1 Scan4Transport Interactive Demo</h1>
<div id="mapblock">
<div class="map_container" :class="showingInputMap ? 'showing' : 'hidden'">
<div id="map"></div>
</div>
</div>
<div id="app1">
<div id="navbar">
<input button id="encode" class="navbutton" value="ENCODE / GENERATE" @click="setMode(0)" v-bind:class="{ activeButton: (mode==0), inactiveButton: (mode==1) }"/><input button id="decode" class="navbutton" value="DECODE" @click="setMode(1)" v-bind:class="{ activeButton: (mode==1), inactiveButton: (mode==0) }"/>
</div>
<div id="inputform" v-if="mode==0">
<table id="inputData">
<tbody>
<tr><td>Choose 2D symbol</td><td colspan="3">
<select v-model="whichCode" class="selectCode">
<option value="0">QR code with GS1 Digital Link URI</option>
<option value="1">GS1 Data Matrix with element string</option>
</select>
</td></tr>
</tbody>
<tbody>
<tr><td>SSCC</td><td colspan="2"><input class="maxWidth" type="text" v-model="primaryValue"></td><td><input type="button" value="demo" @click="demoData2(primaryAIobj.example)"></td></tr>
<tr><td>URI stem</td><td colspan="4"><input class="maxWidth" type="text" v-model="uriStem"></td></tr>
<tr><td></td><td></td><td></td><td style="text-align: center;">AI</td></tr>
</tbody>
<tbody v-for="ex in otherIdentifiers">
<tr class="otherIdentifiers"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'"><input type="text" v-model="s4tData[ex.code]" class="maxWidth"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'"><input class="date" type="date" v-model="s4tData[ex.code]"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'"><select v-model="s4tData[ex.code]"><option value="1">Yes</option><option value="0">No</option></select></span></td><td><input type="button" value="demo" @click="demoData(ex.code)"></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody v-for="ex in transportTaskInformation">
<tr class="transportTaskInfo"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'"><input type="text" v-model="s4tData[ex.code]" class="maxWidth"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'"><input class="date" type="date" v-model="s4tData[ex.code]"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'"><select v-model="s4tData[ex.code]"><option value="1">Yes</option><option value="0">No</option></select></span></td><td><input type="button" value="demo" @click="demoData(ex.code)"></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody v-for="ex in freightUnitInformation">
<tr class="freightUnitInformation"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'"><input type="text" v-model="s4tData[ex.code]" class="maxWidth"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'"><input class="date" type="date" v-model="s4tData[ex.code]"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'"><select v-model="s4tData[ex.code]"><option value="1">Yes</option><option value="0">No</option></select></span></td><td><input type="button" value="demo" @click="demoData(ex.code)"></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody>
<tr class="shippingAddress"><td><b>Ship-to / deliver-to address</b></td><td colspan="3" style="text-align:right;"><select @change="demoShipAddress" v-model="shipDemo">
<option value="shipDemoMenu">Pull down to select a demo value</option>
<option value="clear">Clear the shipping address demo</option>
<option v-for="ex in demoAddresses" :value="JSON.stringify(ex)">{{ex.label}}</option>
</select></td></tr>
</tbody>
<tbody v-for="ex in shippingAddressInfo">
<tr class="shippingAddress" v-if="ex.geocode!==true"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'"><input type="text" v-model="s4tData[ex.code]" class="maxWidth"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'"><input class="date" type="date" v-model="s4tData[ex.code]"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'"><select v-model="s4tData[ex.code]"><option value="1">Yes</option><option value="0">No</option></select></span><span v-if="s4tObj.obj[ex.code].datatype=='gs1:CountryCode'"><select v-model="s4tData[ex.code]"><option v-for="el in Object.keys(countryCodes)" :value="el">{{countryCodes[el]}}</option></select></span></td><td><input type="button" value="demo" @click="demoData(ex.code)"></td><td class="s4tCode">{{ex.code}}</td></tr>
<tr class="shippingAddress" v-if="ex.geocode==true"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'"><input type="text" :value="shipToGeo" class="maxWidth" @keyup="calcLatLon($event)" ></span></td><td><input type="button" value="demo" @click="demoDataLatLon()"></td><td class="s4tCode">{{ex.code}}</td></tr>
<tr class="shippingAddress" v-if="ex.geocode==true"><td><input type="button" @click="toggleInputMap" :value="showingInputMap ? 'Hide map' : 'Show map'" :class="showingInputMap ? 'hidemap' : 'showmap'"></td><td colspan="2" style="text-align:right;">WGS84 Latitude <input type="text" v-model="shipToLat"><td></td></tr>
<tr class="shippingAddress" v-if="ex.geocode==true"><td></td><td colspan="2" style="text-align:right;">WGS84 Longitude <input type="text" v-model="shipToLon"><td></td></tr>
</tbody>
<tbody v-for="ex in deliveryInstructions">
<tr class="deliveryInstructions"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'"><input type="text" v-model="s4tData[ex.code]" class="maxWidth"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'"><input class="date" type="date" v-model="s4tData[ex.code]"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:dateTime'"><input class="date" type="datetime-local" v-model="s4tData[ex.code]"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'"><select v-model="s4tData[ex.code]"><option value="1">Yes</option><option value="0">No</option></select></span></td><td><input type="button" value="demo" @click="demoData(ex.code)"></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody>
<tr class="returnAddress"><td><b>Return address</b></td><td colspan="3" style="text-align:right;"><select @change="demoReturnAddress" v-model="returnDemo">
<option value="returnDemoMenu">Pull down to select a demo value</option>
<option value="clear">Clear the return address demo</option>
<option v-for="ex in demoAddresses" :value="JSON.stringify(ex)">{{ex.label}}</option>
</select></td></tr>
</tbody>
<tbody v-for="ex in returnAddressInfo">
<tr class="returnAddress"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'"><input type="text" v-model="s4tData[ex.code]" class="maxWidth"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'"><input class="date" type="date" v-model="s4tData[ex.code]"></span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'"><select v-model="s4tData[ex.code]"><option value="1">Yes</option><option value="0">No</option></select></span><span v-if="s4tObj.obj[ex.code].datatype=='gs1:CountryCode'"><select v-model="s4tData[ex.code]"><option v-for="el in Object.keys(countryCodes)" :value="el">{{countryCodes[el]}}</option></select></span></td><td><input type="button" value="demo" @click="demoData(ex.code)"></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody v-for="ex in measurements">
<tr class="measurements"><td v-bind:title="ex.definition">{{ex.label}}</td><td><input type="text" v-model="s4tData[ex.code]">{{ex.unit}}</td><td><input type="button" value="demo" @click="demoData(ex.code)"></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody>
</tbody>
</table>
</div>
<div class="qrpanel1" v-if="mode==0">
<textarea id="dlOutput" v-if="whichCode==0" :value="gs1dlURI" @change="changedDLoutput($event)"></textarea>
<textarea id="elsOutput" v-if="whichCode==1" :value="gs1elementString" @change="changedESoutput($event)"></textarea>
<p class="hidden"><input id="selection" type="text" v-model="selectedCanvas"/></p>
<p v-if="showingInputMap"><input type="button" @click="toggleInputMap" :value="showingInputMap ? 'Click to close the map and see the barcode' : 'Show map'" :class="showingInputMap ? 'hidemap' : 'showmap'"></p>
<div v-if="this.primaryValue !== ''" id="stats"><span v-if="!showingInputMap">{{moduleCount}}x{{moduleCount}} modules. Minimum/Target size: {{symbolSizeMinimum}} mm. Maximum size {{symbolSizeMaximum}} mm.</span></div>
</div>
<div class="qrpanel2" v-if="((mode==1) && !(showingInputMap))">
<select v-model="whichCode" class="selectCode">
<option value="0">QR code with GS1 Digital Link URI</option>
<option value="1">GS1 Data Matrix with element string</option>
</select>
<p class="hidden"><input id="selection2" type="text" v-model="selectedCanvas2"/></p>
<div id="gs1DigitalLinkDecode">
<textarea v-if="whichCode==0" id="dlInput" v-model="gs1dlURI2decode"></textarea>
<textarea v-if="whichCode==1" id="elsInput" v-model="gs1els2decode"></textarea>
</div>
</div>
<div id="decoded" v-if="mode==1">
<table id="decodedData">
<tbody>
<tr><td><span>{{primaryValueExtracted.code}}</span></td><td colspan="1">{{primaryValueExtracted.value}}</td><td></td></tr>
<tr><td>URI stem</td><td colspan="3">{{uriStemExtracted}}</td></tr>
<tr><td>Scan4Transport URI ?</td><td colspan="3">{{s4tDetected}}</td></tr>
<tr><td></td><td></td><td>S4T Code</td></tr>
</tbody>
<tbody v-for="ex in otherIdentifiers">
<tr class="otherIdentifiers"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'">{{queryStringExtracted[ex.code]}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'">{{gs1date3(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'">{{booleanValue(queryStringExtracted[ex.code])}}</span></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody v-for="ex in transportTaskInformation">
<tr class="transportTaskInfo"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'">{{queryStringExtracted[ex.code]}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'">{{gs1date3(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'">{{booleanValue(queryStringExtracted[ex.code])}}</span></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody v-for="ex in freightUnitInformation">
<tr class="freightUnitInformation"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'">{{queryStringExtracted[ex.code]}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'">{{gs1date3(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'">{{booleanValue(queryStringExtracted[ex.code])}}</span></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody v-for="ex in shippingAddressInfo">
<tr class="shippingAddress"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'">{{queryStringExtracted[ex.code]}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'">{{gs1date3(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'">{{booleanValue(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='gs1:CountryCode'">{{countryCodes[queryStringExtracted[ex.code]]}}</span></td><td class="s4tCode">{{ex.code}}</td></tr>
<tr class="shippingAddress" v-if="ex.geocode == true"><td></td><td>Lat: {{decodedLat}}<br/>Lon: {{decodedLon}}</td><td></td></tr>
<tr class="shippingAddress" v-if="ex.geocode == true"><td></td><td><span v-if="osMapLink"><a :href="osMapLink" target="_blank">View on OpenStreetMap</a></td><td></td></tr>
</tbody>
<tbody v-for="ex in deliveryInstructions">
<tr class="deliveryInstructions"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'">{{queryStringExtracted[ex.code]}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'">{{gs1date3(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:dateTime'">{{gs1date4(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'">{{booleanValue(queryStringExtracted[ex.code])}}</span></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody v-for="ex in returnAddressInfo">
<tr class="returnAddress"><td v-bind:title="ex.definition">{{ex.label}}</td><td><span v-if="s4tObj.obj[ex.code].datatype=='xsd:string'">{{queryStringExtracted[ex.code]}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:date'">{{gs1date3(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='xsd:boolean'">{{booleanValue(queryStringExtracted[ex.code])}}</span><span v-if="s4tObj.obj[ex.code].datatype=='gs1:CountryCode'">{{countryCodes[queryStringExtracted[ex.code]]}}</span></td><td class="s4tCode">{{ex.code}}</td></tr>
</tbody>
<tbody v-for="ex in measurements">
<tr class="measurements"><td v-bind:title="ex.definition">{{ex.label}}</td><td>{{gs1ToMeasurement(queryStringExtracted, ex.code).value}} <span v-if="gs1ToMeasurement(queryStringExtracted, ex.code).value > ''">{{ex.unit}}</span></td><td class="s4tCode">{{gs1ToMeasurement(queryStringExtracted, ex.code).code}}</td></tr>
</tbody>
<tbody>
</tbody>
</table>
</div>
<div id="symbol2D" v-if="((!(showingInputMap) && !(firstLoad))|| firstLoad)">
<canvas v-show="!showingInputMap && whichCode==0" style="padding-left: 0; padding-right: 0; margin-left: auto; margin-right: auto; display: block;" id="canvas0"></canvas>
<canvas v-show="!showingInputMap && whichCode==1" style="padding-left: 0; padding-right: 0; margin-left: auto; margin-right: auto; display: block;" id="canvas1"></canvas>
<p style="text-align:center;" v-if="!showingInputMap">2D barcode generated using <a href="https://github.com/metafloor/bwip-js/" target="_blank">https://github.com/metafloor/bwip-js/</a><br/> <br/>For questions/feedback about this tool, please contact <a href="mailto:[email protected]">[email protected]</a><br/> <br/><b>Note:</b><br/>Please note that the demo values shown in this tool are shown as human-readable values without the use of percent-encoding that is expected for non-Latin characters and space characters for Application Identifiers (4300)-(4306), (4310)-(4316) and (4320) even when those Application Identifiers and their values are expressed in GS1 element strings.</p>
</div>
</div>
<script language="javascript">
var sscc="";
var uriStem="https://example.com";
var s4tData={};
var qrURI="blank.png";
var gs1dlURI2decode="";
var gs1els2decode="";
var booleans={"1":"Yes","0":"No",undefined:""};
var primary="SSCC";
var primaryValue="";
var shipDemo="shipDemoMenu";
var returnDemo="returnDemoMenu";
function updateCanvas(elem,code,stringToEncode) {
try {
// The return value is the canvas element
let canvas = bwipjs.toCanvas(elem, {
bcid: code, // Barcode type
text: stringToEncode, // Text to encode
scaleX: 2, // 3x scaling factor
scaleY: 2, // 3x scaling factor
includetext: false, // Show human-readable text
textxalign: 'center', // Always good to set this
});
let el=document.getElementById(elem);
return el.width/4;
} catch (e) {
// `e` may be a string or Error object
}
}
let mapblock=Vue.createApp({
data() {
return {
showingInputMap : true
}
},
mounted() {
this.showingInputMap=false;
},
methods : {
toggleInputMap: function() {
let newval=!this.showingInputMap;
this.showingInputMap = newval;
if (app1 !==undefined) {
app1.showingInputMap = newval;
app1.firstLoad=false;
if (newval == false) {
app1.toggleSSCC();
}
}
},
}
}).mount("#mapblock");
let app1=Vue.createApp({
data() {
return {
showingInputMap : true,
firstLoad : true,
s4tTerms: s4tTerms,
s4tPrimaryIdentifiers : s4tPrimaryIdentifiers,
sscc: sscc,
countryCodes : countryCodes,
primary: primary,
primaryValue: primaryValue,
uriStem: uriStem,
s4tData: s4tData,
mode: mode,
booleans: booleans,
zeroToFive: zeroToFive,
gs1dlURI2decode : gs1dlURI2decode,
gs1els2decode : gs1els2decode,
shipDemo : shipDemo,
shipToLat : shipToLat,
shipToLon : shipToLon,
returnDemo : returnDemo,
demoAddresses : demoAddresses,
whichCode : 0,
showingInputMap : false,
tempSSCC : "",
tempMode : null,
}
},
computed : {
decodedGeo : function() {
let g = this.queryStringExtracted['4309'];
return geocode2latlon(g);
},
decodedLat : function() {
if (this.decodedGeo.hasOwnProperty("lat")) {
return this.decodedGeo.lat;
} else {
return "";
}
},
decodedLon : function() {
if (this.decodedGeo.hasOwnProperty("lon")) {
return this.decodedGeo.lon;
} else {
return "";
}
},
osMapLink : function() {
return osmMapURL(this.decodedLat,this.decodedLon);
},
shipToGeo : function() {
if ((this.shipToLat !== "") && (this.shipToLon !== "")) {
recentreMap(this.shipToLat,this.shipToLon,18);
showPoint(this.shipToLat, this.shipToLon);
let g=latlon2geocode(this.shipToLat, this.shipToLon);
this.s4tData['4309']=g;
return g;
} else {
return "";
}
},
primaryAIobj: function() {
return this.s4tPrimaryIdentifiers.filter(filterByLabel(this.primary))[0];
},
s4tObj : function() {
return processS4Tarray(this.s4tTerms);
},
s4tDataJSON : function() {
return JSON.stringify(this.s4tData);
},
deliveryInstructions : function() {
return s4tTerms.filter(filterByGrouping("DeliveryInstructions"));
},
taskInfo : function() {
return s4tTerms.filter(filterByGrouping("TransportTaskInformation"));
},
returnAddressInfo : function() {
return s4tTerms.filter(filterByGrouping("ReturnAddressInformation"));
},
shippingAddressInfo : function() {
return s4tTerms.filter(filterByGrouping("ShippingAddressInformation"));
},
transportTaskInformation : function() {
return s4tTerms.filter(filterByGrouping("TransportTaskInformation"));
},
freightUnitInformation: function() {
return s4tTerms.filter(filterByGrouping("FreightUnitInformation"));
},
otherIdentifiers: function() {
return s4tTerms.filter(filterByGrouping("OtherIdentifiers")).filter(filterExcludeLabel(this.primary));
},
measurements: function() {
return s4tTerms.filter(filterByGrouping("Measurements"));
},
queryStringExtracted: function() {
var qso={};
if (this.whichCode ==0 ){
var uri=this.gs1dlURI2decode;
if (uri !== undefined && uri !== null && uri !== "") {
if (uri.indexOf(" ")> -1) {
uri=uri.substr(0,uri.indexOf(" "));
}
var qsa=uri.substr(1-(0-uri.indexOf("?"))).split("&");
qsa.forEach(function(el) {
if (el !== undefined) {
var kv=el.split("=");
if (kv[1] !== null & kv[1] !== undefined) {
var v=kv[1].replace(/\+/g,"%20");
qso[kv[0]]=decodeURIComponent(v);
}
}
});
}
} else {
let els=this.gs1els2decode;
if (els !== undefined && els !== null && els !== "") {
let splits=els.match(/(\(\d{2,4}\))|([^(]+)/g);
for (let i=0; i<splits.length/2; i++) {
let k=splits[i*2].replace(/[()]/g,"");
let v=splits[1+i*2].replace(/\+/g,"%20");
qso[k]=decodeURIComponent(v);;
}
}
}
return qso;
},
s4tDetected : function() {
let rv="No";
if (this.whichCode ==0) {
if (this.gs1dlURI2decode.slice(-4) == "&s4t") {
rv="Yes";
}
}
return rv;
},
primaryValueExtracted : function() {
let pathInfo="";
let rv={};
let c={"00":"SSCC","402":"GSIN","401":"GINC"};
let digits=new RegExp("^\\d+$");
if (this.whichCode ==0) {
if (this.gs1dlURI2decode !== undefined && this.gs1dlURI2decode !== null && this.gs1dlURI2decode !== "") {
var inq = this.gs1dlURI2decode.indexOf("?");
if (inq== -1) {
pathInfo = this.gs1dlURI2decode;
} else {
pathInfo = this.gs1dlURI2decode.substr(0,this.gs1dlURI2decode.indexOf("?"));
}
var rePath=new RegExp("\\/(sscc|00|gsin|402|ginc|401)\\/(\\d{4}.+?)$");
if (rePath.test(pathInfo)) {
let code=pathInfo.match(rePath)[1].toUpperCase();
if (digits.test(code)) {
code=c[code];
}
rv.code=code;
rv.value=pathInfo.match(rePath)[2];
} else {
rv.code="";
rv.value="";
}
}
} else {
let qso={};
let els=this.gs1els2decode;
let splits=els.match(/(\(\d{2,4}\))|([^(]+)/g);
for (let i=0; i<splits.length/2; i++) {
let k=splits[i*2].replace(/[()]/g,"");
let v=splits[1+i*2].replace(/\+/g,"%20");
qso[k]=decodeURIComponent(v);;
}
rv.code="SSCC";
rv.value=qso["00"];
}
return rv;
},
uriStemExtracted: function() {
var uriStem="";
if (this.whichCode ==0 ) {
if (this.gs1dlURI2decode !== undefined && this.gs1dlURI2decode !== null && this.gs1dlURI2decode !== "") {
var inq = this.gs1dlURI2decode.indexOf("?");
if (inq== -1) {
pathInfo = this.gs1dlURI2decode;
} else {
pathInfo = this.gs1dlURI2decode.substr(0,this.gs1dlURI2decode.indexOf("?"));
}
var rePath=new RegExp("\\/(sscc|00|gsin|402|ginc|401)\\/(\\d{4}.+?)$");
if (rePath.test(pathInfo)) {
let l=pathInfo.match(rePath)[0].length;
uriStem = pathInfo.substr(0,pathInfo.length-l);
}
}
}
return uriStem;
},
queryString: function() {
s4to=JSON.parse(this.s4tDataJSON);
kvPairs=[];
s4tObj.orderedKeys.forEach(function(k) {
let xc = this.primaryAIobj;
if ((s4to.hasOwnProperty(k)) && (s4to[k] !== "")) {
var valToEncode="";
if (this.s4tObj.obj[k].datatype=="xsd:date") {
valToEncode=gs1date(s4to[k]);
}
if (this.s4tObj.obj[k].datatype=="xsd:dateTime") {
valToEncode=gs1dateTime(s4to[k]);
}
if (this.s4tObj.obj[k].datatype=="gs1:Measurement") {
var rv=gs1measurement(s4to[k]);
valToEncode = rv.sixdigit;
k=k.replace("n",rv.ndp);
}
if (valToEncode == "") {
valToEncode=encodeURIComponent(s4to[k]);
}
kvPairs.push(k+"="+valToEncode);
}
});
return kvPairs.join("&")+"&s4t";
},
gs1dlURI: function() {
var uriStem=this.uriStem.replace(/\/$/,"");
var qs=this.queryString.replace(/\%20/g,"+");
var dl = "";
if (this.primaryValue !== "") {
dl = uriStem+"/"+this.primaryAIobj.code+"/"+this.primaryValue;
if (qs !== "") {
dl+="?"+qs;
}
}
// this.generateQR(dl);
this.gs1dlURI2decode = dl;
return dl;
},
gs1elementString: function() {
let rv="";
if (this.primaryValue !== "") {
rv="(00)"+this.primaryValue;
s4to=JSON.parse(this.s4tDataJSON);
kvPairs=[];
s4tObj.orderedKeys.forEach(function(k) {
let xc = this.primaryAIobj;
if ((s4to.hasOwnProperty(k)) && (s4to[k] !== "")) {
var valToEncode="";
if (this.s4tObj.obj[k].datatype=="xsd:date") {
valToEncode=gs1date(s4to[k]);
}
if (this.s4tObj.obj[k].datatype=="xsd:dateTime") {
valToEncode=gs1dateTime(s4to[k]);
}
if (this.s4tObj.obj[k].datatype=="gs1:Measurement") {
var rv=gs1measurement(s4to[k]);
valToEncode = rv.sixdigit;
k=k.replace("n",rv.ndp);
}
if (valToEncode == "") {
// valToEncode=encodeURIComponent(s4to[k]);
valToEncode=s4to[k];
}
kvPairs.push("("+k+")"+valToEncode);
}
});
rv+=kvPairs.join("");
}
this.gs1els2decode = rv;
return rv;
},
"res1" : function() {
if (this.mode==0) {
return updateCanvas("canvas0","qrcode",this.gs1dlURI);
} else {
if (this.gs1dlURI2decode == "") { this.gs1dlURI2decode = this.gs1dlURI }
return updateCanvas("canvas0","qrcode",this.gs1dlURI2decode);
}
},
"res2" : function() {
if (this.mode==0) {
return updateCanvas("canvas1","gs1datamatrix",this.gs1elementString);
} else {
if (this.gs1els2decode == "") { this.gs1els2decode = this.gs1elementString; }
return updateCanvas("canvas1","gs1datamatrix",this.gs1els2decode);
}
},
"selectedCanvas": function() {
let toHide = 1-this.whichCode;
let elh=document.getElementById("canvas"+toHide);
let els=document.getElementById("canvas"+this.whichCode);
if ((elh !== undefined) && (elh !== null) && (els !== undefined) && (els !== undefined)) {
elh.style.display="none";
els.style.display="block";
return "canvas"+this.whichCode;
} else {
return null
}
},
"selectedCanvas2": function() {
if (this.selectedCanvas !== null) {
return this.res1+this.res2+this.selectedCanvas+this.gs1elementString+this.gs1dlURI;
} else {
return null;
}
},
moduleCount: function() {
if (this.whichCode==0) { return this.res1; }
if (this.whichCode==1) { return this.res2; }
},
symbolSizeMinimum: function() {
return Math.floor(this.moduleCount * 743)/1000;
},
symbolSizeTarget: function() {
return Math.floor(this.moduleCount * 743)/1000;
},
symbolSizeMaximum: function() {
return Math.floor(this.moduleCount * 1500)/1000;
}
},
methods: {
toggleSSCC : function() {
this.tempMode=this.mode;
if (this.mode ==0) {
this.tempSSCC=this.primaryValue;
this.primaryValue="";
}
setTimeout(this.restoreSSCC,500);
},
restoreSSCC : function() {
if (this.tempMode==0) {
this.primaryValue=this.tempSSCC;
this.setMode(0);
}
},
toggleInputMap: function() {
window.scrollTo(0,0);
this.showingInputMap = !this.showingInputMap;
mapblock.showingInputMap = this.showingInputMap;
recentreMap(this.shipToLat,this.shipToLon);
},
calcLatLon: function(event) {
let newVal=event.target.value;
let re=new RegExp("^[0-9]{20}$");
if (re.test(newVal)) {
let o=geocode2latlon(newVal);
this.shipToLat=o.lat;
this.shipToLon=o.lon;
}
},
demoDataLatLon: function(event) {
this.shipToLat="52.2021950";
this.shipToLon="0.1282028";
},
demoShipAddress: function(event) {
let newValue = event.target.value;
let a=["4300","4301","4302","4303","4304","4305","4306","4307","420"];
if (newValue == "clear") {
for (i in a) {
this.s4tData[a[i]]="";
}
this.shipToLat = "";
this.shipToLon = "";
} else {
let o = JSON.parse(newValue);
let i;
for (i in a) {
this.s4tData[a[i]]="";
this.s4tData[a[i]]=o[a[i]];
}
if ((o.hasOwnProperty("lat")) && (o.hasOwnProperty("lon")) && (o.lat !== "") && (o.lon !== "")) {
this.shipToLat = o.lat;
this.shipToLon = o.lon;
} else {
this.shipToLat = "";
this.shipToLon = "";
}
}
},
demoReturnAddress: function(event) {
let newValue = event.target.value;
let a=["4300","4301","4302","4303","4304","4305","4306","4307","420"];
let m={"4300":"4310","4301":"4311","4302":"4312","4303":"4313","4304":"4314","4305":"4315","4306":"4316","4307":"4317","420":"4318"};
if (newValue == "clear") {
for (i in a) {
this.s4tData,m[a[i]]="";
}
} else {
let o = JSON.parse(newValue);
let i;
for (i in a) {
this.s4tData[m[a[i]]]="";
this.s4tData[m[a[i]]]=o[a[i]];
}
}
},
changedDLoutput: function(event) {
let newValue = event.target.value;
// this.generateQR(newValue);
this.gs1dlURI2decode = newValue;
this.gs1dlURI = newValue;
},
clearPrimaryIdentifierValues: function() {
this.s4tPrimaryIdentifiers.forEach(function(el) {
this.s4tData[el.code]="";
});
this.primaryValue="";
},
demoData: function(el) {
var demoVal = s4tObj.obj[el].example;
this.s4tData[el]=demoVal;
},
demoData2: function(demoVal) {
this.primaryValue=demoVal;
},
gs1ToMeasurement: function(queryStringExtracted,code) {
var rv={};
this.zeroToFive.forEach(function(el) {
var tempCode=code.replace("n",el);
if (queryStringExtracted.hasOwnProperty(tempCode)) {
rv.value=queryStringExtracted[tempCode]/Math.pow(10,parseInt(el));
rv.code=tempCode;
}
});
return rv;
},
gs1date3: function(gs1Date) {
var rv="";
var regexDate= new RegExp("^\\d{6}$");
if (gs1Date !== undefined && regexDate.test(gs1Date)) {
var doubleDigits = gs1Date.split(/(\d{2})/);
// TODO determine this correctly based on whether >=51 - see Gen Specs
var year=parseInt(doubleDigits[1]);
var currentYear=new Date().getFullYear().toString();
var currentLastYY=parseInt(currentYear.substr(-2));
var currentFirstYY=parseInt(currentYear.substr(0,2));
var diff=year-currentLastYY;
var fullyear=currentFirstYY.toString()+year.toString();
if (diff >=51 && diff <= 99) {
fullyear=(currentFirstYY-1).toString()+year.toString();
}
if (diff >= -99 && diff <= -50) {
fullyear=(currentFirstYY+1).toString()+year.toString();
}
if (fullyear !== undefined) {
rv=doubleDigits[5]+"/"+doubleDigits[3]+"/"+fullyear;
}
}
return rv;
},
gs1date4: function(gs1Date) {
var rv="";
var regexDate= new RegExp("^\\d{6}|\\d{8}|\\d{10}$");
if (gs1Date !== undefined && regexDate.test(gs1Date)) {
var doubleDigits = gs1Date.split(/(\d{2})/);
// TODO determine this correctly based on whether >=51 - see Gen Specs
var year=parseInt(doubleDigits[1]);
var currentYear=new Date().getFullYear().toString();
var currentLastYY=parseInt(currentYear.substr(-2));
var currentFirstYY=parseInt(currentYear.substr(0,2));
var diff=year-currentLastYY;
var fullyear=currentFirstYY.toString()+year.toString();
if (diff >=51 && diff <= 99) {
fullyear=(currentFirstYY-1).toString()+year.toString();
}
if (diff >= -99 && diff <= -50) {
fullyear=(currentFirstYY+1).toString()+year.toString();
}
var hour="00";
var min="00";
if (gs1Date.length > 6) {
hour=doubleDigits[7];
}
if (gs1Date.length > 8) {
min=doubleDigits[9];
}
if (fullyear !== undefined) {
rv=doubleDigits[5]+"/"+doubleDigits[3]+"/"+fullyear+" "+hour+":"+min;
}
}
return rv;
},
setMode: function(el) {
this.mode=el;
var qrc=document.getElementById("symbol2D");