-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
914 lines (910 loc) · 29 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
<!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title></title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="https://fonts.googleapis.com/css?family=Caveat|Gloria+Hallelujah|Roboto:400,600"
rel="stylesheet"
/>
<link rel="stylesheet" href="css/app-styles.css" />
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">
You are using an <strong>outdated</strong> browser. Please
<a href="#">upgrade your browser</a> to improve your experience.
</p>
<![endif]-->
<div id="app">
<div class="creuzer-app-frame" v-cloak>
<div class="creuzer-app-matte">
<figure class="logo-frame" @click="handleReset()">
<a href="//www.sercante.com" class="no-underline" target="_blank"><img src="assets/img/Sercante.png" /></a>
</figure>
<!--stepOne-->
<div id="vanishingContent" v-if="displayCard === 'stepOne'">
<header>
<h1>Split Values for Use in Pardot & Salesforce Rule Criteria</h1>
<p>
Need to split a big list of values for use in Pardot dynamic
lists or Salesforce report filters? We got you covered.
</p>
<ol>
<li>Paste Your Text in the Box Below</li>
<li>
(Optional): If you need to swap commas, semi-colons, or line breaks... select 'Data Manipulation' and pick the update needed.</span>
</li>
<li>
Select Data Chunk Size. (250 characters - for Pardot, 1000 characters - for Salesforce)
</li>
<li>Split my data!</li>
</ol>
<!-- <p>
Don't have a list yet, but want to take a test drive?<br />
<a href="#" @click.prevent="loadSampleData()">
Click here to try with sample data
</a>
</p> -->
<span>SFDC Report Line Splitter / Pardot Dynamic lists / Country Codes</span>
</header>
<main>
<div class="textarea-frame">
<textarea
id="thetext"
placeholder="Paste your text"
v-model="userData"
></textarea>
</div>
<!-- <p>
Don't have a list yet, but want to take a test drive?<br />
<a href="#" @click.prevent="loadSampleData()">
Click here to try with sample data
</a>
</p> -->
<div class="clear-btn-frame">
<transition name="fade">
<a href="#" v-if="userData" @click.prevent="userData = ''; transformOption = ''; chunkSize = '';">
Clear Input
</a>
</transition>
</div>
<p v-show="formError" class="error-message">{{ errorMessage }}</p>
<!-- <p>
Paste your text into the text box above and click the 'Split the
Data' button. You can try the sample data as well just to see
this work
</p> -->
<div id="buttonFrame" class="button-frame" >
<label
for="dataManipulationSelect"
class="custom-select"
:class="{'arrow-down': !transformOption}"
>
<select
id="dataManipulationSelect"
v-model="transformOption"
>
<option disabled value="">Data Manipulation</option>
<template v-for="(option, index) in transformDataOptions">
<option :key="index">{{ option }}</option>
</template>
</select>
</label>
<label for="splitSize" class="custom-select" :class="{'arrow-down': !chunkSize}">
<select id="splitSize" v-model="chunkSize">
<option disabled value="">Data Chunk Size</option>
<template v-for="(data, index) in dataSplitSizeOptions">
<option :key="index">{{ data }}</option>
</template>
</select>
</label>
<button id="split" @click="checkForData()">
Split the Data
</button>
</div>
<p>
Don't have a list yet, but want to take a test drive?<br />
<a href="#" @click.prevent="loadSampleData()">
Click here to try with sample data
</a>
</p>
</main>
</div>
<!--/stepOne-->
<!--stepTwo-->
<div class="stepTwo" v-if="displayCard === 'stepTwo'">
<div class="p-b-2" v-if="!showAll">
<div class="flex-box_between p-xt-2">
<div class="align-self_end">
<span>
{{ dataChunkIndex + 1 }} of
{{ chunkedDataList.length }}
</span>
<a @click="showAll = !showAll" class="show-all">show all</a>
</div>
<div class="flex-box align-self_end">
<button class="prev-btn" @click="handlePrev()">
<
</button>
<button class="next-btn" @click="handleNext()">
>
</button>
</div>
</div>
<textarea
id="dataChunk"
class="data-chunk-frame"
:class="{'disabled-text': textDisabled.includes(`dataChunk${dataChunkIndex}`)}"
readonly
:value="dataChunk"
></textarea>
<div class="p-xt-1">
<button @click="handleReset()" class="reset-btn">
Start Over
</button>
<button
class="copy-btn"
:class="{'disabled-btn': textDisabled.includes(`dataChunk${dataChunkIndex}`)}"
@click="handleCopy(dataChunkIndex)"
>
Copy
</button>
</div>
</div>
<div class="p-b-2 p-xt-2" v-else>
<div class="p-b-2" v-for="(chunk, index) in chunkedDataList">
<textarea
:id="'chunk' + index"
class="data-chunk-frame"
:class="{'disabled-text': textDisabled.includes('chunk' + index)}"
readonly
:value="chunk"
></textarea>
<button
@click="handleReset()"
class="reset-btn"
v-if="index === chunkedDataList.length -1"
>
Start Over
</button>
<button
class="copy-btn"
:class="{'disabled-btn': textDisabled.includes('chunk' + index)}"
@click="handleCopy(index)"
>
Copy
</button>
</div>
</div>
</div>
<!--stepTwo-->
</div>
<!-- <footer>
<p>© 2019 Sercante</p>
</footer> -->
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>
var app = new Vue({
el: "#app",
data: {
displayCard: "stepOne",
dataSplitSizeOptions: ["250 (Pardot)", "1000 (SFDC)"],
userData: "",
chunkedDataList: [],
transformDataOptions: [
"Line Breaks to Commas (SFDC)",
"Line Breaks to Semicolons (Pardot)",
"Semicolons to Commas (Pardot to SFDC)",
"Commas to Semicolons (SFDC to Pardot)",
"Country Codes to Country Names"
],
transformOption: "",
chunkSize: "",
selectedSplitSize: 0,
dataChunk: "",
dataChunkIndex: -1,
semiToColon: false,
formError: false,
errorMessage: "",
showAll: false,
textDisabled: [],
delimiterAdded: false,
additionalDebugToConsole: false,
maxChunks: 1000,
isoCountries: { // First column all caps, second column how we want the data
'AD':'Andorra',
'AE':'United Arab Emirates',
'AF':'Afghanistan',
'AG':'Antigua and Barbuda',
'AI':'Anguilla',
'AL':'Albania',
'AM':'Armenia',
'AO':'Angola',
'AQ':'Antarctica',
'AR':'Argentina',
'AT':'Austria',
'AU':'Australia',
'AW':'Aruba',
'AX':'Aland Islands',
'AZ':'Azerbaijan',
'BA':'Bosnia and Herzegovina',
'BB':'Barbados',
'BD':'Bangladesh',
'BE':'Belgium',
'BF':'Burkina Faso',
'BG':'Bulgaria',
'BH':'Bahrain',
'BI':'Burundi',
'BJ':'Benin',
'BL':'Saint Barthélemy',
'BM':'Bermuda',
'BN':'Brunei Darussalam',
'BO':'Bolivia, Plurinational State of',
'BQ':'Bonaire, Sint Eustatius and Saba',
'BR':'Brazil',
'BS':'Bahamas',
'BT':'Bhutan',
'BV':'Bouvet Island',
'BW':'Botswana',
'BY':'Belarus',
'BZ':'Belize',
'CA':'Canada',
'CC':'Cocos (Keeling) Islands',
'CD':'Congo, the Democratic Republic of the',
'CF':'Central African Republic',
'CG':'Congo',
'CH':'Switzerland',
'CI':"Cote d'Ivoire",
'CK':'Cook Islands',
'CL':'Chile',
'CM':'Cameroon',
'CN':'China',
'CO':'Colombia',
'CR':'Costa Rica',
'CU':'Cuba',
'CV':'Cape Verde',
'CW':'Cura�ao',
'CX':'Christmas Island',
'CY':'Cyprus',
'CZ':'Czech Republic',
'DE':'Germany',
'DJ':'Djibouti',
'DK':'Denmark',
'DM':'Dominica',
'DO':'Dominican Republic',
'DZ':'Algeria',
'EC':'Ecuador',
'EE':'Estonia',
'EG':'Egypt',
'EH':'Western Sahara',
'ER':'Eritrea',
'ES':'Spain',
'ET':'Ethiopia',
'FI':'Finland',
'FJ':'Fiji',
'FK':'Falkland Islands (Malvinas)',
'FO':'Faroe Islands',
'FR':'France',
'GA':'Gabon',
'GB':'United Kingdom',
'UK':'United Kingdom',
'GD':'Grenada',
'GE':'Georgia',
'GF':'French Guiana',
'GG':'Guernsey',
'GH':'Ghana',
'GI':'Gibraltar',
'GL':'Greenland',
'GM':'Gambia',
'GN':'Guinea',
'GP':'Guadeloupe',
'GQ':'Equatorial Guinea',
'GR':'Greece',
'GS':'South Georgia and the South Sandwich Islands',
'GT':'Guatemala',
'GW':'Guinea-Bissau',
'GY':'Guyana',
'HM':'Heard Island and McDonald Islands',
'HN':'Honduras',
'HR':'Croatia',
'HT':'Haiti',
'HU':'Hungary',
'ID':'Indonesia',
'IE':'Ireland',
'IL':'Israel',
'IM':'Isle of Man',
'IN':'India',
'IO':'British Indian Ocean Territory',
'IQ':'Iraq',
'IR':'Iran, Islamic Republic of',
'IS':'Iceland',
'IT':'Italy',
'JE':'Jersey',
'JM':'Jamaica',
'JO':'Jordan',
'JP':'Japan',
'KE':'Kenya',
'KG':'Kyrgyzstan',
'KH':'Cambodia',
'KI':'Kiribati',
'KM':'Comoros',
'KN':'Saint Kitts and Nevis',
'KP':'Korea, Democratic Peoples Republic of',
'KR':'Korea, Republic of',
'KW':'Kuwait',
'KY':'Cayman Islands',
'KZ':'Kazakhstan',
'LA':'Lao Peoples Democratic Republic',
'LB':'Lebanon',
'LC':'Saint Lucia',
'LI':'Liechtenstein',
'LK':'Sri Lanka',
'LR':'Liberia',
'LS':'Lesotho',
'LT':'Lithuania',
'LU':'Luxembourg',
'LV':'Latvia',
'LY':'Libya',
'MA':'Morocco',
'MC':'Monaco',
'MD':'Moldova, Republic of',
'ME':'Montenegro',
'MF':'Saint Martin (French part)',
'MG':'Madagascar',
'MK':'Macedonia, the former Yugoslav Republic of',
'ML':'Mali',
'MM':'Myanmar',
'MN':'Mongolia',
'MO':'Macao',
'MQ':'Martinique',
'MR':'Mauritania',
'MS':'Montserrat',
'MT':'Malta',
'MU':'Mauritius',
'MV':'Maldives',
'MW':'Malawi',
'MX':'Mexico',
'MY':'Malaysia',
'MZ':'Mozambique',
'NA':'Namibia',
'NC':'New Caledonia',
'NE':'Niger',
'NF':'Norfolk Island',
'NG':'Nigeria',
'NI':'Nicaragua',
'NL':'Netherlands',
'NO':'Norway',
'NP':'Nepal',
'NR':'Nauru',
'NU':'Niue',
'NZ':'New Zealand',
'OM':'Oman',
'PA':'Panama',
'PE':'Peru',
'PF':'French Polynesia',
'PG':'Papua New Guinea',
'PH':'Philippines',
'PK':'Pakistan',
'PL':'Poland',
'PM':'Saint Pierre and Miquelon',
'PN':'Pitcairn',
'PS':'Palestine',
'PT':'Portugal',
'PY':'Paraguay',
'QA':'Qatar',
'RE':'Reunion',
'RO':'Romania',
'RS':'Serbia',
'RU':'Russian Federation',
'RW':'Rwanda',
'SA':'Saudi Arabia',
'SB':'Solomon Islands',
'SC':'Seychelles',
'SD':'Sudan',
'SE':'Sweden',
'SG':'Singapore',
'SH':'Saint Helena, Ascension and Tristan da Cunha',
'SI':'Slovenia',
'SJ':'Svalbard and Jan Mayen',
'SK':'Slovakia',
'SL':'Sierra Leone',
'SM':'San Marino',
'SN':'Senegal',
'SO':'Somalia',
'SR':'Suriname',
'SS':'South Sudan',
'ST':'Sao Tome and Principe',
'SV':'El Salvador',
'SX':'Sint Maarten (Dutch part)',
'SY':'Syrian Arab Republic',
'SZ':'Swaziland',
'TC':'Turks and Caicos Islands',
'TD':'Chad',
'TF':'French Southern Territories',
'TG':'Togo',
'TH':'Thailand',
'TJ':'Tajikistan',
'TK':'Tokelau',
'TL':'Timor-Leste',
'TM':'Turkmenistan',
'TN':'Tunisia',
'TO':'Tonga',
'TR':'Turkey',
'TT':'Trinidad and Tobago',
'TV':'Tuvalu',
'TW':'Taiwan',
'TZ':'Tanzania, United Republic of',
'UA':'Ukraine',
'UG':'Uganda',
'US':'United States',
'UY':'Uruguay',
'UZ':'Uzbekistan',
'VA':'Holy See (Vatican City State)',
'VC':'Saint Vincent and the Grenadines',
'VE':'Venezuela, Bolivarian Republic of',
'VG':'Virgin Islands, British',
'VN':'Vietnam',
'VU':'Vanuatu',
'WF':'Wallis and Futuna',
'WS':'Samoa',
'YE':'Yemen',
'YT':'Mayotte',
'ZA':'South Africa',
'ZM':'Zambia',
'ZW':'Zimbabwe',
'AND':'Andorra',
'ARE':'United Arab Emirates',
'AFG':'Afghanistan',
'ATG':'Antigua and Barbuda',
'AIA':'Anguilla',
'ALB':'Albania',
'ARM':'Armenia',
'AGO':'Angola',
'ATA':'Antarctica',
'ARG':'Argentina',
'AUT':'Austria',
'AUS':'Australia',
'ABW':'Aruba',
'ALA':'Aland Islands',
'AZE':'Azerbaijan',
'BIH':'Bosnia and Herzegovina',
'BRB':'Barbados',
'BGD':'Bangladesh',
'BEL':'Belgium',
'BFA':'Burkina Faso',
'BGR':'Bulgaria',
'BHR':'Bahrain',
'BDI':'Burundi',
'BEN':'Benin',
'BLM':'Saint Barthélemy',
'BMU':'Bermuda',
'BRN':'Brunei Darussalam',
'BOL':'Bolivia, Plurinational State of',
'BES':'Bonaire, Sint Eustatius and Saba',
'BRA':'Brazil',
'BHS':'Bahamas',
'BTN':'Bhutan',
'BVT':'Bouvet Island',
'BWA':'Botswana',
'BLR':'Belarus',
'BLZ':'Belize',
'CAN':'Canada',
'CCK':'Cocos (Keeling) Islands',
'COD':'Congo, the Democratic Republic of the',
'CAF':'Central African Republic',
'COG':'Congo',
'CHE':'Switzerland',
'CIV':"Cote d'Ivoire",
'COK':'Cook Islands',
'CHL':'Chile',
'CMR':'Cameroon',
'CHN':'China',
'COL':'Colombia',
'CRI':'Costa Rica',
'CUB':'Cuba',
'CPV':'Cape Verde',
'CUW':'Cura�ao',
'CXR':'Christmas Island',
'CYP':'Cyprus',
'CZE':'Czech Republic',
'DEU':'Germany',
'DJI':'Djibouti',
'DNK':'Denmark',
'DMA':'Dominica',
'DOM':'Dominican Republic',
'DZA':'Algeria',
'ECU':'Ecuador',
'EST':'Estonia',
'EGY':'Egypt',
'ESH':'Western Sahara',
'ERI':'Eritrea',
'ESP':'Spain',
'ETH':'Ethiopia',
'FIN':'Finland',
'FJI':'Fiji',
'FLK':'Falkland Islands (Malvinas)',
'FRO':'Faroe Islands',
'FRA':'France',
'GAB':'Gabon',
'GBR':'United Kingdom',
'GRD':'Grenada',
'GEO':'Georgia',
'GUF':'French Guiana',
'GGY':'Guernsey',
'GHA':'Ghana',
'GIB':'Gibraltar',
'GRL':'Greenland',
'GMB':'Gambia',
'GIN':'Guinea',
'GLP':'Guadeloupe',
'GNQ':'Equatorial Guinea',
'GRC':'Greece',
'SGS':'South Georgia and the South Sandwich Islands',
'GTM':'Guatemala',
'GNB':'Guinea-Bissau',
'GUY':'Guyana',
'HMD':'Heard Island and McDonald Islands',
'HND':'Honduras',
'HRV':'Croatia',
'HTI':'Haiti',
'HUN':'Hungary',
'IDN':'Indonesia',
'IRL':'Ireland',
'ISR':'Israel',
'IMN':'Isle of Man',
'IND':'India',
'IOT':'British Indian Ocean Territory',
'IRQ':'Iraq',
'IRN':'Iran, Islamic Republic of',
'ISL':'Iceland',
'ITA':'Italy',
'JEY':'Jersey',
'JAM':'Jamaica',
'JOR':'Jordan',
'JPN':'Japan',
'KEN':'Kenya',
'KGZ':'Kyrgyzstan',
'KHM':'Cambodia',
'KIR':'Kiribati',
'COM':'Comoros',
'KNA':'Saint Kitts and Nevis',
'PRK':'Korea, Democratic Peoples Republic of',
'KOR':'Korea, Republic of',
'KWT':'Kuwait',
'CYM':'Cayman Islands',
'KAZ':'Kazakhstan',
'LAO':'Lao Peoples Democratic Republic',
'LBN':'Lebanon',
'LCA':'Saint Lucia',
'LIE':'Liechtenstein',
'LKA':'Sri Lanka',
'LBR':'Liberia',
'LSO':'Lesotho',
'LTU':'Lithuania',
'LUX':'Luxembourg',
'LVA':'Latvia',
'LBY':'Libya',
'MAR':'Morocco',
'MCO':'Monaco',
'MDA':'Moldova, Republic of',
'MNE':'Montenegro',
'MAF':'Saint Martin (French part)',
'MDG':'Madagascar',
'MKD':'Macedonia, the former Yugoslav Republic of',
'MLI':'Mali',
'MMR':'Myanmar',
'MNG':'Mongolia',
'MAC':'Macao',
'MTQ':'Martinique',
'MRT':'Mauritania',
'MSR':'Montserrat',
'MLT':'Malta',
'MUS':'Mauritius',
'MDV':'Maldives',
'MWI':'Malawi',
'MEX':'Mexico',
'MYS':'Malaysia',
'MOZ':'Mozambique',
'NAM':'Namibia',
'NCL':'New Caledonia',
'NER':'Niger',
'NFK':'Norfolk Island',
'NGA':'Nigeria',
'NIC':'Nicaragua',
'NLD':'Netherlands',
'NOR':'Norway',
'NPL':'Nepal',
'NRU':'Nauru',
'NIU':'Niue',
'NZL':'New Zealand',
'OMN':'Oman',
'PAN':'Panama',
'PER':'Peru',
'PYF':'French Polynesia',
'PNG':'Papua New Guinea',
'PHL':'Philippines',
'PAK':'Pakistan',
'POL':'Poland',
'SPM':'Saint Pierre and Miquelon',
'PCN':'Pitcairn',
'PSE':'Palestine',
'PRT':'Portugal',
'PRY':'Paraguay',
'QAT':'Qatar',
'REU':'Reunion',
'ROU':'Romania',
'SRB':'Serbia',
'RUS':'Russian Federation',
'RWA':'Rwanda',
'SAU':'Saudi Arabia',
'SLB':'Solomon Islands',
'SYC':'Seychelles',
'SDN':'Sudan',
'SWE':'Sweden',
'SGP':'Singapore',
'SHN':'Saint Helena, Ascension and Tristan da Cunha',
'SVN':'Slovenia',
'SJM':'Svalbard and Jan Mayen',
'SVK':'Slovakia',
'SLE':'Sierra Leone',
'SMR':'San Marino',
'SEN':'Senegal',
'SOM':'Somalia',
'SUR':'Suriname',
'SSD':'South Sudan',
'STP':'Sao Tome and Principe',
'SLV':'El Salvador',
'SXM':'Sint Maarten (Dutch part)',
'SYR':'Syrian Arab Republic',
'SWZ':'Swaziland',
'TCA':'Turks and Caicos Islands',
'TCD':'Chad',
'ATF':'French Southern Territories',
'TGO':'Togo',
'THA':'Thailand',
'TJK':'Tajikistan',
'TKL':'Tokelau',
'TLS':'Timor-Leste',
'TKM':'Turkmenistan',
'TUN':'Tunisia',
'TON':'Tonga',
'TUR':'Turkey',
'TTO':'Trinidad and Tobago',
'TUV':'Tuvalu',
'TWN':'Taiwan',
'TZA':'Tanzania, United Republic of',
'UKR':'Ukraine',
'UGA':'Uganda',
'USA':'United States',
'URY':'Uruguay',
'UZB':'Uzbekistan',
'VAT':'Holy See (Vatican City State)',
'VCT':'Saint Vincent and the Grenadines',
'VEN':'Venezuela, Bolivarian Republic of',
'VGB':'Virgin Islands, British',
'VNM':'Vietnam',
'VUT':'Vanuatu',
'WLF':'Wallis and Futuna',
'WSM':'Samoa',
'YEM':'Yemen',
'MYT':'Mayotte',
'ZAF':'South Africa',
'ZMB':'Zambia',
'ZWE':'Zimbabwe',
'UNITED STATES OF AMERICA':'United States',
}
},
methods: {
loadSampleData: function() {
this.userData = // eslint-disable-next-line quotes
"Afghanistan, Albania, Algeria, American Samoa, Andorra, Angola, Anguilla, Antarctica, Antigua and Barbuda, Argentina, Armenia, Aruba, Australia, Austria, Azerbaijan, Bahamas, Bahrain, Bangladesh, Barbados, Belarus, Belgium, Belize, Benin, Bermuda, Bhutan, Bolivia, Bosnia and Herzegovina, Botswana, Bouvet Island, Brazil, British Indian Ocean Territory, Brunei Darussalam, Bulgaria, Burkina Faso, Burundi, Cambodia, Cameroon, Canada, Cape Verde, Cayman Islands, Central African Republic, Chad, Chile, China, Christmas Island, Cocos (Keeling) Islands, Colombia, Comoros, Congo, Congo, The Democratic Republic of The, Cook Islands, Costa Rica, Cote D'ivoire, Croatia, Cuba, Cyprus, Czech Republic, Denmark, Djibouti, Dominica, Dominican Republic, Ecuador, Egypt, El Salvador, Equatorial Guinea, Eritrea, Estonia, Ethiopia, Falkland Islands(Malvinas), Faroe Islands, Fiji, Finland, France, French Guiana, French Polynesia, French Southern Territories, Gabon, Gambia, Georgia, Germany, Ghana, Gibraltar, Greece, Greenland, Grenada, Guadeloupe, Guam, Guatemala, Guinea, Guinea- bissau, Guyana, Haiti, Heard Island and Mcdonald Islands, Holy See(Vatican City State), Honduras, Hong Kong, Hungary, Iceland, India, Indonesia, Iran, Islamic Republic of, Iraq, Ireland, Israel, Italy, Jamaica, Japan, Jordan, Kazakhstan, Kenya, Kiribati, Korea, Democratic People's Republic of, Korea, Republic of, Kuwait, Kyrgyzstan, Lao People's Democratic Republic, Latvia, Lebanon, Lesotho, Liberia, Libyan Arab Jamahiriya, Liechtenstein, Lithuania, Luxembourg, Macao, Macedonia, The Former Yugoslav Republic of, Madagascar, Malawi, Malaysia, Maldives, Mali, Malta, Marshall Islands, Martinique, Mauritania, Mauritius, Mayotte, Mexico, Micronesia, Federated States of, Moldova, Republic of, Monaco, Mongolia, Montserrat, Morocco, Mozambique, Myanmar, Namibia, Nauru, Nepal, Netherlands, Netherlands Antilles, New Caledonia, New Zealand, Nicaragua, Niger, Nigeria, Niue, Norfolk Island, Northern Mariana Islands, Norway, Oman, Pakistan, Palau, Palestinian Territory, Occupied, Panama, Papua New Guinea, Paraguay, Peru, Philippines, Pitcairn, Poland, Portugal, Puerto Rico, Qatar, Reunion, Romania, Russian Federation, Rwanda, Saint Helena, Saint Kitts and Nevis, Saint Lucia, Saint Pierre and Miquelon, Saint Vincent and The Grenadines, Samoa, San Marino, Sao Tome and Principe, Saudi Arabia, Senegal, Serbia and Montenegro, Seychelles, Sierra Leone, Singapore, Slovakia, Slovenia, Solomon Islands, Somalia, South Africa, South Georgia and The South Sandwich Islands, Spain, Sri Lanka, Sudan, Suriname, Svalbard and Jan Mayen, Swaziland, Sweden, Switzerland, Syrian Arab Republic, Taiwan, Province of China, Tajikistan, Tanzania, United Republic of, Thailand, Timor- leste, Togo, Tokelau, Tonga, Trinidad and Tobago, Tunisia, Turkey, Turkmenistan, Turks and Caicos Islands, Tuvalu, Uganda, Ukraine, United Arab Emirates, United Kingdom, United States, United States Minor Outlying Islands, Uruguay, Uzbekistan, Vanuatu, Venezuela, Viet Nam, Virgin Islands, British, Virgin Islands, U.S., Wallis and Futuna, Western Sahara, Yemen, Zambia, Zimbabwe";
},
chunkTheData: function() {
this.chunkedDataList = [];
this.dataChunkIndex = 0;
this.checkForCommaOrSemi();
var originalString = this.userData;
var chunk = "";
var subString = "";
var n = "";
this.displayCard = "stepTwo";
var num = this.selectedSplitSize;
var counter = 0;
if(this.additionalDebugToConsole){
console.log(typeof(num));
console.log(num);
}
while (originalString.length > 0) {
chunk = originalString.substring(0, num);
if (this.transformOption === "Semicolons to Commas (Pardot to SFDC)")
if (chunk.length >= num) {
n = chunk.lastIndexOf(",");
} else {
n = chunk.length;
}
if (this.transformOption === "Commas to Semicolons (SFDC to Pardot)")
if (chunk.length >= num) {
n = chunk.lastIndexOf(";");
} else {
n = chunk.length;
}
var chunkedString = originalString.substring(0, n);
if(this.additionalDebugToConsole){
console.log('chunkedString:', chunkedString)
}
this.chunkedDataList.push(chunkedString);
originalString = originalString
.substring(n)
.replace(/(^,)|(^;)|(;$)|(,$)/, "")
.trim();
counter++;
if (counter >= this.maxChunks || originalString.length === 0) {
break;
}
}
},
checkForData: function() {
if (!this.userData) {
this.formError = true;
this.errorMessage = "Silly human. No data. No data spliting";
} else if (!this.chunkSize) {
this.formError = true;
this.errorMessage = "Please select a charater limit value";
} else {
this.chunkTheData();
}
},
checkForCommaOrSemi: function() {
for (char of this.userData) {
if (char === ",") {
this.transformOption = "Semicolons to Commas (Pardot to SFDC)";
}
if (char === ";") {
this.transformOption = "Commas to Semicolons (SFDC to Pardot)";
}
}
},
addDelimiter: function(char) {
this.delimiterAdded = true;
// this.transformDataOptions.splice(0, 2);
this.userData = this.userData.replace(/(\r\n|\n|\r)/gm, `${char} `);
/* const txtValue = this.userData.split("")
console.log(txtValue)
let idx = txtValue.indexOf("\n")
console.log('idx', idx)
while (idx !== -1) {
if (txtValue[idx - 1] !== char) {
txtValue[idx] = char
} else {
txtValue.splice(idx, 1);
console.log("txt" + txtValue.indexOf("\n"))
}
console.log(txtValue.join())
this.userData = txtValue.join("")
idx = txtValue.indexOf("\n")
} */
},
changeSemicolonToComma: function() {
this.userData = this.userData.replace(/;/g, ",");
//this.semiToColon = true;
// this.displayCard = 'stepTwo';
},
changeCommaToSemicolon: function() {
this.userData = this.userData.replace(/,/g, ";");
//this.semiToColon = true;
//this.displayCard = 'stepTwo';
},
changeCodesToCountries: function() {
const txtValue = this.userData.split("\n")
console.log(txtValue)
txtValue.forEach(this.getCountryName)
this.userData = txtValue.join("\n")
},
getCountryName: function(value, index, array ) {
if (this.isoCountries.hasOwnProperty(value.toUpperCase())) {
console.log(this.isoCountries[value.toUpperCase()])
array[index] = this.isoCountries[value.toUpperCase()];
} else {
console.log(value, value.toUpperCase())
array[index] = value;
}
},
handleReset: function() {
this.displayCard = "stepOne";
this.chunkSize = "";
this.userData = "";
this.transformOption = "";
this.chunkedDataList = [];
this.dataChunkIndex = -1;
(this.dataChunk = ""),
(this.showAll = false),
(this.semiToColon = false),
(this.formError = false),
(this.errorMessage = []),
(this.textDisabled = []);
},
handleNext: function() {
if (this.dataChunkIndex < this.chunkedDataList.length - 1) {
this.dataChunkIndex += 1;
// this.textDisabled = [];
} else {
return;
}
},
handlePrev: function() {
if (this.dataChunkIndex > 0) {
this.dataChunkIndex -= 1;
//this.textDisabled = [];
} else {
return;
}
},
handleCopy: function(index) {
if (!this.showAll) {
var text = document.querySelector("#dataChunk");
text.setAttribute("type", "text");
text.select();
this.textDisabled.push(`dataChunk${index}`);
} else {
var text = document.querySelector(`#chunk${index}`);
text.setAttribute("type", "text");
text.select();
this.textDisabled.push(`chunk${index}`);
}
try {
var successful = document.execCommand("copy");
var msg = successful ? "successful" : "unsuccessful";
console.log("Testing code was copied " + msg);
} catch (err) {
console.log("Oops, unable to copy");
}
text.setAttribute("type", "hidden");
window.getSelection().removeAllRanges();
}
},
watch: {
chunkSize: function() {
if (this.chunkSize) {
this.formError = false;
this.selectedSplitSize = parseInt(this.chunkSize.slice(0, 4));
}
},
dataChunkIndex: function() {
this.dataChunk = this.chunkedDataList[this.dataChunkIndex];
},
transformOption: function() {
switch (this.transformOption) {
case "Line Breaks to Commas (SFDC)":
this.addDelimiter(",");
break;
case "Line Breaks to Semicolons (Pardot)":
this.addDelimiter(";");
break;
case "Commas to Semicolons (SFDC to Pardot)":
this.changeCommaToSemicolon();
break;
case "Semicolons to Commas (Pardot to SFDC)":
this.changeSemicolonToComma();
break;
case "Country Codes to Country Names":
this.changeCodesToCountries();
break;
default:
}
}
}
});
</script>
</body>
</html>