forked from newsdev/ai2html
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ai2html-legacy.js
2508 lines (2264 loc) · 130 KB
/
ai2html-legacy.js
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
// ai2html-legacy.js
var scriptVersion = "0.64.0"; // Increment the final digit after future updates
var scriptEnvironment = "nyt";
// var scriptEnvironment = "";
// ai2html is a script for Adobe Illustrator that converts your Illustrator document into html and css.
// Copyright (c) 2011-2015 The New York Times Company
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this library except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =====================================
// How to install ai2html
// =====================================
// - Move the ai2html.js file into the Illustrator folder where scripts are located.
// - For example, on Mac OS X running Adobe Illustrator CC 2014, the path would be: // Adobe Illustrator CC 2014/Presets/en_US/Scripts/ai2html.jsx
// =====================================
// How to use ai2html
// =====================================
// - Create your Illustrator artwork.
// - Size the artboard to the dimensions that you want the div to appear on the web page.
// - Make sure your Document Color Mode is set to RGB.
// - Make sure your document is saved.
// - Use Arial or Georgia unless you have added your own fonts to the fonts array in the script.
// - Run the script by choosing: File > Scripts > ai2html
// - Go to the folder containing your Illustrator file. Inside will be a folder called ai2html-output.
// - Open the html files in your browser to preview your output.
// Adding [].indexOf to Illustrator JavaScript
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(elt /*, from*/) {
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0) ? Math.ceil(from) : Math.floor(from);
if (from < 0) from += len;
for (; from < len; from++) {
if (from in this && this[from] === elt) return from;
}
return -1;
};
}
// =====================================
// functions
// =====================================
// html entity substitution
// not used ==> ["\x22","""], ["\x3C","<"], ["\x3E",">"], ["\x26","&"],
var htmlCharacterCodes = [["\xA0"," "], ["\xA1","¡"], ["\xA2","¢"], ["\xA3","£"], ["\xA4","¤"], ["\xA5","¥"], ["\xA6","¦"], ["\xA7","§"], ["\xA8","¨"], ["\xA9","©"], ["\xAA","ª"], ["\xAB","«"], ["\xAC","¬"], ["\xAD","­"], ["\xAE","®"], ["\xAF","¯"], ["\xB0","°"], ["\xB1","±"], ["\xB2","²"], ["\xB3","³"], ["\xB4","´"], ["\xB5","µ"], ["\xB6","¶"], ["\xB7","·"], ["\xB8","¸"], ["\xB9","¹"], ["\xBA","º"], ["\xBB","»"], ["\xBC","¼"], ["\xBD","½"], ["\xBE","¾"], ["\xBF","¿"], ["\xD7","×"], ["\xF7","÷"], ["\u0192","ƒ"], ["\u02C6","ˆ"], ["\u02DC","˜"], ["\u2002"," "], ["\u2003"," "], ["\u2009"," "], ["\u200C","‌"], ["\u200D","‍"], ["\u200E","‎"], ["\u200F","‏"], ["\u2013","–"], ["\u2014","—"], ["\u2018","‘"], ["\u2019","’"], ["\u201A","‚"], ["\u201C","“"], ["\u201D","”"], ["\u201E","„"], ["\u2020","†"], ["\u2021","‡"], ["\u2022","•"], ["\u2026","…"], ["\u2030","‰"], ["\u2032","′"], ["\u2033","″"], ["\u2039","‹"], ["\u203A","›"], ["\u203E","‾"], ["\u2044","⁄"], ["\u20AC","€"], ["\u2111","ℑ"], ["\u2113",""], ["\u2116",""], ["\u2118","℘"], ["\u211C","ℜ"], ["\u2122","™"], ["\u2135","ℵ"], ["\u2190","←"], ["\u2191","↑"], ["\u2192","→"], ["\u2193","↓"], ["\u2194","↔"], ["\u21B5","↵"], ["\u21D0","⇐"], ["\u21D1","⇑"], ["\u21D2","⇒"], ["\u21D3","⇓"], ["\u21D4","⇔"], ["\u2200","∀"], ["\u2202","∂"], ["\u2203","∃"], ["\u2205","∅"], ["\u2207","∇"], ["\u2208","∈"], ["\u2209","∉"], ["\u220B","∋"], ["\u220F","∏"], ["\u2211","∑"], ["\u2212","−"], ["\u2217","∗"], ["\u221A","√"], ["\u221D","∝"], ["\u221E","∞"], ["\u2220","∠"], ["\u2227","∧"], ["\u2228","∨"], ["\u2229","∩"], ["\u222A","∪"], ["\u222B","∫"], ["\u2234","∴"], ["\u223C","∼"], ["\u2245","≅"], ["\u2248","≈"], ["\u2260","≠"], ["\u2261","≡"], ["\u2264","≤"], ["\u2265","≥"], ["\u2282","⊂"], ["\u2283","⊃"], ["\u2284","⊄"], ["\u2286","⊆"], ["\u2287","⊇"], ["\u2295","⊕"], ["\u2297","⊗"], ["\u22A5","⊥"], ["\u22C5","⋅"], ["\u2308","⌈"], ["\u2309","⌉"], ["\u230A","⌊"], ["\u230B","⌋"], ["\u2329","⟨"], ["\u232A","⟩"], ["\u25CA","◊"], ["\u2660","♠"], ["\u2663","♣"], ["\u2665","♥"], ["\u2666","♦"]];
// http://samuelmullen.com/2012/03/left-pad-zeroes-in-javascript/
var zeroPad = function(value, padding) {
var zeroes = "0";
for (var i = 0; i < padding; i++) { zeroes += "0"; }
return (zeroes + value).slice(padding * -1);
};
// multiple key sorting function from https://github.com/Teun/thenBy.js
// first by length of name, then by population, then by ID
// data.sort(
// firstBy(function (v1, v2) { return v1.name.length - v2.name.length; })
// .thenBy(function (v1, v2) { return v1.population - v2.population; })
// .thenBy(function (v1, v2) { return v1.id - v2.id; });
// );
var firstBy = (function() {
/* mixin for the `thenBy` property */
function extend(f) {
f.thenBy = tb;
return f;
}
/* adds a secondary compare function to the target function (`this` context)
which is applied in case the first one returns 0 (equal)
returns a new compare function, which has a `thenBy` method as well */
function tb(y) {
var x = this;
return extend(function(a, b) {
return x(a,b) || y(a,b);
});
}
return extend;
})();
Array.prototype.findUniqueValues = function() {
var o = {}, i, l = this.length, r = [];
for(i=0; i<l;i+=1) o[this[i]] = this[i];
for(i in o) r.push(o[i]);
return r;
};
var cleanText = function(text) {
for (var i=0; i < htmlCharacterCodes.length; i++) {
var charCode = htmlCharacterCodes[i];
text = text.replace( new RegExp(htmlCharacterCodes[i][0],'g'), htmlCharacterCodes[i][1] )
};
return text;
};
var straightenCurlyQuotesInsideAngleBrackets = function(text) {
// thanks to jashkenas
var tagFinder = /<[^\n]+?>/g;
var quoteFinder = /[“‘’”]([^\n]*?)[“‘’”]/g;
return text.replace(tagFinder, function(tag){
return tag.replace( /[“”]/g , '"' ).replace( /[‘’]/g , "'" );
});
};
var exportImageFiles = function(dest,width,height,formats,initialScaling,doubleres) {
// alert(formats);
// width and height are the artboard width and height and only used to determine whether or not to double res
// initialScaling is the proportion to scale the base image before considering whether to double res. Usually just 1.
// Exports current document to dest as a PNG8 file with specified
// options, dest contains the full path including the file name
// doubleres is "yes" or "no" whether you want to allow images to be double res
// if you want to force ai2html to use doubleres, use "always"
if (doubleres=="yes" || doubleres=="always") {
// if image is too big to use double-res, then just output single-res.
var pngImageScaling = 200 * initialScaling;
var jpgImageScaling = 200 * initialScaling;
if (doubleres == 'always' || ((width*height) < (3*1024*1024/4) || (width >= 945))) {
// <3
// feedback.push("The jpg and png images are double resolution.");
} else if ( (width*height) < (3*1024*1024) ) {
// .75-3
pngImageScaling = 100;
// feedback.push("The png image is single resolution.");
// feedback.push("The jpg image is double resolution.");
} else if ( (width*height) < (32*1024*1024/4) ) {
// 3-8
pngImageScaling = 100;
// warnings.push("The png image is single resolution, but is too large to display on first-generation iPhones.");
// feedback.push("The jpg image is double resolution.");
} else if ( (width*height) < (32*1024*1024) ) {
// 8-32
pngImageScaling = 100;
jpgImageScaling = 100;
// warnings.push("The png image is single resolution, but is too large to display on first-generation iPhones.");
// feedback.push("The jpg image is single resolution.");
} else {
// 32+
pngImageScaling = 100;
jpgImageScaling = 100;
// warnings.push("The jpg and png images are single resolution, but are too large to display on first-generation iPhones.");
};
} else {
var pngImageScaling = 100 * initialScaling;
var jpgImageScaling = 100 * initialScaling;
};
// alert("scaling\npngImageScaling = " + pngImageScaling + "\njpgImageScaling = " + jpgImageScaling);
for (var formatNumber = 0; formatNumber < formats.length; formatNumber++) {
var format = formats[formatNumber];
if (format=="png") {
var pngExportOptions = new ExportOptionsPNG8();
var pngType = ExportType.PNG8;
var pngFileSpec = new File(dest);
pngExportOptions.colorCount = docSettings.png_number_of_colors;
pngExportOptions.transparency = (docSettings.png_transparent==="no") ? false : true;
pngExportOptions.artBoardClipping = true;
pngExportOptions.antiAliasing = false;
pngExportOptions.horizontalScale = pngImageScaling;
pngExportOptions.verticalScale = pngImageScaling;
app.activeDocument.exportFile( pngFileSpec, pngType, pngExportOptions );
// feedback.push("pngExportOptions.png_number_of_colors = " + pngExportOptions.colorCount);
// feedback.push("pngExportOptions.transparency = " + pngExportOptions.transparency);
} else if (format=="png24") {
var pngExportOptions = new ExportOptionsPNG24();
var pngType = ExportType.PNG24;
var pngFileSpec = new File(dest);
pngExportOptions.transparency = (docSettings.png_transparent==="no") ? false : true;
pngExportOptions.artBoardClipping = true;
pngExportOptions.antiAliasing = false;
pngExportOptions.horizontalScale = pngImageScaling;
pngExportOptions.verticalScale = pngImageScaling;
app.activeDocument.exportFile( pngFileSpec, pngType, pngExportOptions );
} else if (format=="svg") {
var svgExportOptions = new ExportOptionsSVG();
var svgType = ExportType.SVG;
// alert("This will be the svg dest: " + dest);
var svgFileSpec = new File(dest);
svgExportOptions.embedAllFonts = false;
svgExportOptions.fontSubsetting = SVGFontSubsetting.None;
svgExportOptions.compressed = false;
svgExportOptions.documentEncoding = SVGDocumentEncoding.UTF8;
svgExportOptions.embedRasterImages = (docSettings.svg_embed_images==="yes") ? true : false;
// svgExportOptions.horizontalScale = initialScaling;
// svgExportOptions.verticalScale = initialScaling;
svgExportOptions.saveMultipleArtboards = false;
svgExportOptions.DTD = SVGDTDVersion.SVG1_1; // SVG1_0 SVGTINY1_1 <=default SVG1_1 SVGTINY1_1PLUS SVGBASIC1_1 SVGTINY1_2
svgExportOptions.cssProperties = SVGCSSPropertyLocation.STYLEATTRIBUTES; // ENTITIES STYLEATTRIBUTES <=default PRESENTATIONATTRIBUTES STYLEELEMENTS
app.activeDocument.exportFile( svgFileSpec, svgType, svgExportOptions );
} else if (format=="jpg") {
if (jpgImageScaling > maxJpgImageScaling) {
jpgImageScaling = maxJpgImageScaling;
var promoImageFileName = dest.split("/").slice(-1)[0];
feedback.push(promoImageFileName + ".jpg was output at a lower scaling than desired because of a limit on jpg exports in Illustrator. If the file needs to be larger, change the image format to png which does not appear to have limits.")
};
var jpgExportOptions = new ExportOptionsJPEG();
var jpgType = ExportType.JPEG;
var jpgFileSpec = new File(dest);
jpgExportOptions.artBoardClipping = true;
jpgExportOptions.antiAliasing = false;
jpgExportOptions.qualitySetting = docSettings.jpg_quality;
jpgExportOptions.horizontalScale = jpgImageScaling;
jpgExportOptions.verticalScale = jpgImageScaling;
app.activeDocument.exportFile( jpgFileSpec, jpgType, jpgExportOptions );
// feedback.push("jpgExportOptions.qualitySetting = " + jpgExportOptions.qualitySetting);
};
};
};
var isEmpty = function(str) {
return (!str || 0 === str.length);
};
var isBlank = function(str) {
return (!str || /^\s*$/.test(str));
};
var makeKeyword = function(text) {
// text = text.replace( /[^A-Za-z0-9_\-]/g , "_" ).toLowerCase();
text = text.replace( /[^A-Za-z0-9_\-]/g , "_" );
return text;
};
var unlockStuff = function(parentObj) {
if (parentObj.typename=="Layer" || parentObj.typename=="Document") {
for (var layerNo = 0; layerNo < parentObj.layers.length; layerNo++) {
var currentLayer = parentObj.layers[layerNo];
if (currentLayer.locked==true) {
currentLayer.locked = false;
lockedObjects.push(currentLayer);
};
if (currentLayer.visible==false) {
currentLayer.visible = true;
hiddenObjects.push(currentLayer);
};
unlockStuff(currentLayer);
};
};
for (var groupItemsNo = 0; groupItemsNo < parentObj.groupItems.length; groupItemsNo++) {
var currentGroupItem = parentObj.groupItems[groupItemsNo];
if (currentGroupItem.locked==true) {
currentGroupItem.locked = false;
lockedObjects.push(currentGroupItem);
};
unlockStuff(currentGroupItem);
};
for (var textFrameNo = 0; textFrameNo < parentObj.textFrames.length; textFrameNo++) {
var currentTextFrame = parentObj.textFrames[textFrameNo];
// this line is producing the MRAP error!!!
if (currentTextFrame.locked==true) {
currentTextFrame.locked = false;
lockedObjects.push(currentTextFrame);
};
};
};
var hideTextFrame = function(textFrame) {
textFramesToUnhide.push(textFrame);
textFrame.hidden = true;
};
var roundTo = function(numberToRound,decimalPlaces) {
var roundedNumber = Math.round(numberToRound * Math.pow(10,decimalPlaces)) / Math.pow(10,decimalPlaces);
return roundedNumber;
};
var createPromoImage = function(abNumber) {
doc.artboards.setActiveArtboardIndex(abNumber);
var activeArtboard = doc.artboards[abNumber];
activeArtboardRect = activeArtboard.artboardRect,
abX = activeArtboardRect[0],
abY = -activeArtboardRect[1],
abW = Math.round(activeArtboardRect[2]-abX),
abH = -activeArtboardRect[3]-abY,
artboardAspectRatio = abH/abW,
artboardName = makeKeyword(activeArtboard.name),
docArtboardName = makeKeyword(docSettings.project_name) + "-" + artboardName + "-" + abNumber,
imageDestination = docPath + docArtboardName + "-promo",
promoImageAspect = promoImageMinHeight/promoImageMinWidth,
promoScale = 1;
if (artboardAspectRatio>promoImageAspect) {
promoScale = promoImageMinWidth/abW;
if (abH * promoScale > promoImageMaxHeight) {
promoScale = promoImageMaxHeight/abH;
}
} else {
promoScale = promoImageMinHeight/abH;
if (abW * promoScale > promoImageMaxWidth) {
promoScale = promoImageMaxWidth/abW;
}
}
var promoW = abW * promoScale;
var promoH = abH * promoScale;
// feedback.push("promoImageAspect = " + promoImageAspect + "\r" +
// "abNumber = " + abNumber + "\r" +
// "artboardAspectRatio = " + artboardAspectRatio + "\r" +
// "promoScale = " + promoScale + "\r" +
// "abW = " + abW + "\r" +
// "abH = " + abH + "\r" +
// "promoW = " + promoW + "\r" +
// "promoH = " + promoH);
// alert("promoImageAspect = " + promoImageAspect + "\r" +
// "abNumber = " + abNumber + "\r" +
// "artboardAspectRatio = " + artboardAspectRatio + "\r" +
// "promoScale = " + promoScale + "\r" +
// "abW = " + abW + "\r" +
// "abH = " + abH + "\r" +
// "promoW = " + promoW + "\r" +
// "promoH = " + promoH);
// var promoImageFormat = [];
// if (docSettings.image_format[0]=="png" ||
// docSettings.image_format[0]=="png24" ||
// docSettings.image_format[0]=="svg")
// {
// promoImageFormat.push("png");
// } else {
// promoImageFormat.push(docSettings.image_format[0]);
// };
var promoImageFormats = [];
for (var formatNo = 0; formatNo < docSettings.image_format.length; formatNo++) {
var promoFormat = docSettings.image_format[formatNo];
if (promoFormat=="png" ||
promoFormat=="png24" ||
promoFormat=="svg")
{
promoImageFormats.push("png");
} else {
promoImageFormats.push(promoFormat);
};
};
pBar.setTitle(artboardName + ': Writing promo image...');
var tempPNGtransparency = docSettings.png_transparent;
docSettings.png_transparent = "no";
if (docSettings.write_image_files=="yes") {
exportImageFiles(imageDestination,promoW,promoH,promoImageFormats,promoScale,"no");
};
docSettings.png_transparent = tempPNGtransparency;
};
var applyTemplate = function(template,atObject) {
var newText = template;
for (var atKey in atObject) {
var mustachePattern = new RegExp("\\{\\{\\{? *" + atKey + " *\\}\\}\\}?","g");
var ejsPattern = new RegExp("\\<\\%[=]? *" + atKey + " *\\%\\>","g");
var replacePattern = atObject[atKey];
newText = newText.replace( mustachePattern , replacePattern );
newText = newText.replace( ejsPattern , replacePattern );
};
return newText;
};
var outputHtml = function(htmlText,fileDestination) {
var htmlFile = new File( fileDestination );
htmlFile.open( "w", "TEXT", "TEXT" );
htmlFile.lineFeed = "Unix";
htmlFile.encoding = "UTF-8";
htmlFile.writeln(htmlText);
htmlFile.close;
};
var readTextFileAndPutIntoAVariable = function(inputFile,starterText,linePrefix,lineSuffix) {
var outputText = starterText;
if ( inputFile.exists ) {
inputFile.open("r");
while(!inputFile.eof) {
outputText += linePrefix + inputFile.readln() + lineSuffix;
};
inputFile.close();
} else {
errors.push(inputFile + " could not be found.");
};
return outputText;
};
var checkForOutputFolder = function(folderPath, nickname) {
var outputFolder = new Folder( folderPath );
if (!outputFolder.exists) {
var outputFolderCreated = outputFolder.create();
if (outputFolderCreated) {
feedback.push("The " + nickname + " folder did not exist, so the folder was created.");
} else {
warnings.push("The " + nickname + " folder did not exist and could not be created.");
};
};
};
// ================================================
// Progress bar
// ================================================
function progressBar() {
this.win = null;
}
progressBar.prototype.init = function() {
var min=0, max=100;
var win = new Window("palette", "Ai2html progress", [150, 150, 600, 260]);
this.win = win;
win.pnl = win.add("panel", [10, 10, 440, 100], "Progress");
win.pnl.progBar = win.pnl.add("progressbar", [20, 35, 410, 60], min, max);
win.pnl.progBarLabel = win.pnl.add("statictext", [20, 20, 320, 35], min+"%");
win.show();
return true;
}
progressBar.prototype.setProgress = function(progress) {
var win = this.win;
var max = win.pnl.progBar.maxvalue,
min = win.pnl.progBar.minvalue;
// progress is always 0.0 to 1.0
var pct = progress * max;
win.pnl.progBar.value = pct;
this.setLabel();
win.update();
}
progressBar.prototype.getProgress = function() {
var win = this.win;
var max = win.pnl.progBar.maxvalue,
min = win.pnl.progBar.minvalue;
return this.win.pnl.progBar.value/max;
}
progressBar.prototype.setLabel = function() {
this.win.pnl.progBarLabel.text = Math.round(this.win.pnl.progBar.value) + "%";
}
progressBar.prototype.setTitle = function(title) {
this.win.pnl.text = title;
this.win.update();
}
progressBar.prototype.increment = function(amount) {
var amount = amount || 0.01;
var win = this.win;
this.setProgress(this.getProgress()+amount);
win.update();
}
progressBar.prototype.close = function() {
this.win.update();
this.win.close();
}
// ================================================
// ai2html and config settings
// ================================================
// Settings can be generated by making a copy of this Google Spreadsheet:
// https://docs.google.com/spreadsheets/d/13ESQ9ktfkdzFq78FkWLGaZr2s3lNbv2cN25F2pYf5XM/edit?usp=sharing
// Make a copy of the spreadsheet for yourself.
// Modify the settings to taste.
// Copy the contents from column Images and replace the settings statements:
if (scriptEnvironment=="nyt") {
var ai2htmlBaseSettings = {
ai2html_environment: {defaultValue: scriptEnvironment, includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
settings_version: {defaultValue: scriptVersion, includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
create_promo_image: {defaultValue: "yes", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
image_format: {defaultValue: ["png"], includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "array", possibleValues: "jpg, png, png24", notes: "Images will be generated in mulitple formats if multiple formats are listed, separated by commas. The first format will be used in the html. Sometimes this is useful to compare which format will have a smaller file size."},
write_image_files: {defaultValue: "yes", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: "Set this to “no” to skip writing the image files. Generally only use this after you have run the script once with this setting set to “yes.”"},
responsiveness: {defaultValue: "fixed", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "fixed, dynamic", notes: "Dynamic responsiveness means ai graphics will scale to fill the container they are placed in."},
max_width: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "integer", possibleValues: "", notes: "Blank or any positive number in pixels, but do not write “px” - blank means artboards will set max size, instead it is written to the config file so that the max width can be applied to the template’s container."},
output: {defaultValue: "one-file", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "one-file, multiple-files", notes: "One html file containing all the artboards or a separate html file for each artboard."},
project_name: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: "Use this to set a custom project name. The project name is being used in output filenames, class names, etc."},
html_output_path: {defaultValue: "../src/", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "folderPath", possibleValues: "", notes: "Allows user to change folder to write html files, path should be written relative to ai file location. This is ignored if the project_type in the yml is ai2html."},
html_output_extension: {defaultValue: ".html", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "fileExtension", possibleValues: "", notes: "This is ignored if the project_type in the yml is ai2html."},
image_output_path: {defaultValue: "../public/_assets/", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "folderPath", possibleValues: "", notes: "_assets/ for preview default. This is where the image files get written to locally and should be written as if the html_output location is the starting point."},
image_source_path: {defaultValue: null, includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "folderPath", possibleValues: "", notes: "Use this setting to specify from where the images are being loaded from the HTML file. Defaults to image_output_path"},
create_config_file: {defaultValue: "true", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: "This is ignored in env=nyt."},
config_file_path: {defaultValue: "../config.yml", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "filePath", possibleValues: "", notes: "This only gets used to write the config file. It’s not used in the nyt mode to read the config.yml. Path should written relative to the ai file location."},
local_preview_template: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "filePath", possibleValues: "", notes: ""},
png_transparent: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
png_number_of_colors: {defaultValue: 128, includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "integer", possibleValues: "2 to 256", notes: ""},
jpg_quality: {defaultValue: 60, includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "integer", possibleValues: "0 to 100", notes: ""},
center_html_output: {defaultValue: "true", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: "Adds “margin:0 auto;” to the div containing the ai2html output."},
use_2x_images_if_possible: {defaultValue: "yes", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
use_lazy_loader: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
include_resizer_css_js: {defaultValue: "yes", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
include_resizer_classes: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
include_resizer_widths: {defaultValue: "yes", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
include_resizer_script: {defaultValue: "yes", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
svg_embed_images: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
render_rotated_skewed_text_as: {defaultValue: "html", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "image, html", notes: ""},
show_completion_dialog_box: {defaultValue: "true", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: "Set this to false if you don't want to see the dialog box confirming completion of the script."},
clickable_link: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: "If you put a url in this field, an <a> tag will be added, wrapping around the output and pointing to that url."},
testing_mode: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
last_updated_text: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
headline: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
leadin: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
summary: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: "Summary field for Scoop assets"},
notes: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
sources: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
credit: {defaultValue: "By The New York Times", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
page_template: {defaultValue: "nyt5-article-embed", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
publish_system: {defaultValue: "scoop", includeInSettingsBlock: false, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
environment: {defaultValue: "production", includeInSettingsBlock: false, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
show_in_compatible_apps: {defaultValue: "yes", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "yesNo", possibleValues: "", notes: ""},
display_for_promotion_only: {defaultValue: "false", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: ""},
constrain_width_to_text_column: {defaultValue: "false", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: ""},
scoop_publish_fields: {defaultValue: "true", includeInSettingsBlock: false, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: ""},
scoop_asset_id: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
scoop_username: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
scoop_slug: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
scoop_external_edit_key: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""}
};
} else {
var ai2htmlBaseSettings = {
ai2html_environment: {defaultValue: scriptEnvironment, includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
settings_version: {defaultValue: scriptVersion, includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
create_promo_image: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
image_format: {defaultValue: ["png"], includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "array", possibleValues: "jpg, png, png24", notes: "Images will be generated in mulitple formats if multiple formats are listed, separated by commas. The first format will be used in the html. Sometimes this is useful to compare which format will have a smaller file size."},
write_image_files: {defaultValue: "yes", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: "Set this to “no” to skip writing the image files. Generally only use this after you have run the script once with this setting set to “yes.”"},
responsiveness: {defaultValue: "fixed", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "fixed, dynamic", notes: "Dynamic responsiveness means ai graphics will scale to fill the container they are placed in."},
max_width: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "integer", possibleValues: "", notes: "Blank or any positive number in pixels, but do not write “px” - blank means artboards will set max size, the max width is not included in the html stub, instead it is written to the config file so that the max width can be applied to the template’s container."},
output: {defaultValue: "one-file", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "one-file, multiple-files", notes: "One html file containing all the artboards or a separate html file for each artboard."},
project_name: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: "Use this to set a custom project name. The project name is being used in output filenames, class names, etc."},
html_output_path: {defaultValue: "/ai2html-output/", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "folderPath", possibleValues: "", notes: "Allows user to change folder to write html files, path should be written relative to ai file location. This is ignored if the project_type in the yml is ai2html."},
html_output_extension: {defaultValue: ".html", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "fileExtension", possibleValues: "", notes: "This is ignored if the project_type in the yml is ai2html."},
image_output_path: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "folderPath", possibleValues: "", notes: "This is where the image files get written to locally and should be written as if the html_output is the starting point."},
image_source_path: {defaultValue: null, includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "folderPath", possibleValues: "", notes: "Use this setting to specify from where the images are being loaded from the HTML file. Defaults to image_output_path"},
create_config_file: {defaultValue: "false", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: "This is ignored in env=nyt."},
config_file_path: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "filePath", possibleValues: "", notes: "This only gets used to write the config file. It’s not used in the nyt mode to read the config.yml. Path should written relative to the ai file location."},
local_preview_template: {defaultValue: "", includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "filePath", possibleValues: "", notes: ""},
png_transparent: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
png_number_of_colors: {defaultValue: 128, includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "integer", possibleValues: "2 to 256", notes: ""},
jpg_quality: {defaultValue: 60, includeInSettingsBlock: true, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "integer", possibleValues: "0 to 100", notes: ""},
center_html_output: {defaultValue: "true", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: "Adds “margin:0 auto;” to the div containing the ai2html output."},
use_2x_images_if_possible: {defaultValue: "yes", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
use_lazy_loader: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
include_resizer_css_js: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
include_resizer_classes: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
include_resizer_widths: {defaultValue: "yes", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: "If set to “yes”, ai2html adds data-min-width and data-max-width attributes to each artboard"},
include_resizer_script: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
svg_embed_images: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
render_rotated_skewed_text_as: {defaultValue: "html", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "image, html", notes: ""},
show_completion_dialog_box: {defaultValue: "yes", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: "Set this to “no” if you don't want to see the dialog box confirming completion of the script."},
clickable_link: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: "If you put a url in this field, an <a> tag will be added, wrapping around the output and pointing to that url."},
testing_mode: {defaultValue: "no", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "yesNo", possibleValues: "", notes: ""},
last_updated_text: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
headline: {defaultValue: "Ai Graphic Headline", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
leadin: {defaultValue: "Introductory text here.", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
summary: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: "Summary field for Scoop assets"},
notes: {defaultValue: "Notes: Text goes here.", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
sources: {defaultValue: "Source: Name goes here.", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
credit: {defaultValue: "By ai2html", includeInSettingsBlock: true, includeInConfigFile: true, useQuoteMarksInConfigFile: true, inputType: "text", possibleValues: "", notes: ""},
page_template: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
publish_system: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
environment: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
show_in_compatible_apps: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: true, inputType: "yesNo", possibleValues: "", notes: ""},
display_for_promotion_only: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: ""},
constrain_width_to_text_column: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: ""},
scoop_publish_fields: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "trueFalse", possibleValues: "", notes: ""},
scoop_asset_id: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
scoop_username: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
scoop_slug: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""},
scoop_external_edit_key: {defaultValue: "", includeInSettingsBlock: false, includeInConfigFile: false, useQuoteMarksInConfigFile: false, inputType: "text", possibleValues: "", notes: ""}
};
};
// End of ai2htmlBaseSettings block copied from Google Spreadsheet.
// ================================================
// constants
// ================================================
// Add to the fonts array to make the script work with your own custom fonts.
// To make it easier to add to this array, use the "fonts" worksheet of this Google Spreadsheet:
// https://docs.google.com/spreadsheets/d/13ESQ9ktfkdzFq78FkWLGaZr2s3lNbv2cN25F2pYf5XM/edit?usp=sharing
// Make a copy of the spreadsheet for yourself.
// Modify the settings to taste.
var fonts = [
{"aifont":"ArialMT","family":"arial,helvetica,sans-serif","weight":"","style":""},
{"aifont":"Arial-BoldMT","family":"arial,helvetica,sans-serif","weight":"bold","style":""},
{"aifont":"Arial-ItalicMT","family":"arial,helvetica,sans-serif","weight":"","style":"italic"},
{"aifont":"Arial-BoldItalicMT","family":"arial,helvetica,sans-serif","weight":"bold","style":"italic"},
{"aifont":"Georgia","family":"georgia,'times new roman',times,serif","weight":"","style":""},
{"aifont":"Georgia-Bold","family":"georgia,'times new roman',times,serif","weight":"bold","style":""},
{"aifont":"Georgia-Italic","family":"georgia,'times new roman',times,serif","weight":"","style":"italic"},
{"aifont":"Georgia-BoldItalic","family":"georgia,'times new roman',times,serif","weight":"bold","style":"italic"},
{"aifont":"NYTFranklin-Light","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"300","style":""},
{"aifont":"NYTFranklin-Medium","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"500","style":""},
{"aifont":"NYTFranklin-SemiBold","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"600","style":""},
{"aifont":"NYTFranklin-Semibold","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"600","style":""},
{"aifont":"NYTFranklinSemiBold-Regular","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"600","style":""},
{"aifont":"NYTFranklin-SemiboldItalic","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"600","style":"italic"},
{"aifont":"NYTFranklin-Bold","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"700","style":""},
{"aifont":"NYTFranklin-LightItalic","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"300","style":"italic"},
{"aifont":"NYTFranklin-MediumItalic","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"500","style":"italic"},
{"aifont":"NYTFranklin-BoldItalic","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"700","style":"italic"},
{"aifont":"NYTFranklin-ExtraBold","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"800","style":""},
{"aifont":"NYTFranklin-ExtraBoldItalic","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"800","style":"italic"},
{"aifont":"NYTFranklin-Headline","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"bold","style":""},
{"aifont":"NYTFranklin-HeadlineItalic","family":"nyt-franklin,arial,helvetica,sans-serif","weight":"bold","style":"italic"},
{"aifont":"NYTCheltenham-ExtraLight","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"200","style":""},
{"aifont":"NYTCheltenhamExtLt-Regular","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"200","style":""},
{"aifont":"NYTCheltenham-Light","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"300","style":""},
{"aifont":"NYTCheltenhamLt-Regular","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"300","style":""},
{"aifont":"NYTCheltenham-LightSC","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"300","style":""},
{"aifont":"NYTCheltenham-Book","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"400","style":""},
{"aifont":"NYTCheltenhamBook-Regular","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"400","style":""},
{"aifont":"NYTCheltenham-Wide","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"","style":""},
{"aifont":"NYTCheltenhamMedium-Regular","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"500","style":""},
{"aifont":"NYTCheltenham-Medium","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"500","style":""},
{"aifont":"NYTCheltenham-Bold","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"700","style":""},
{"aifont":"NYTCheltenham-BoldCond","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"bold","style":""},
{"aifont":"NYTCheltenham-BoldExtraCond","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"bold","style":""},
{"aifont":"NYTCheltenham-ExtraBold","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"bold","style":""},
{"aifont":"NYTCheltenham-ExtraLightIt","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"","style":"italic"},
{"aifont":"NYTCheltenham-ExtraLightItal","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"","style":"italic"},
{"aifont":"NYTCheltenham-LightItalic","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"","style":"italic"},
{"aifont":"NYTCheltenham-BookItalic","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"","style":"italic"},
{"aifont":"NYTCheltenham-WideItalic","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"","style":"italic"},
{"aifont":"NYTCheltenham-MediumItalic","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"","style":"italic"},
{"aifont":"NYTCheltenham-BoldItalic","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"700","style":"italic"},
{"aifont":"NYTCheltenham-ExtraBoldItal","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"bold","style":"italic"},
{"aifont":"NYTCheltenham-ExtraBoldItalic","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"bold","style":"italic"},
{"aifont":"NYTCheltenhamSH-Regular","family":"nyt-cheltenham-sh,nyt-cheltenham,georgia,'times new roman',times,serif","weight":"400","style":""},
{"aifont":"NYTCheltenhamSH-Italic","family":"nyt-cheltenham-sh,nyt-cheltenham,georgia,'times new roman',times,serif","weight":"400","style":"italic"},
{"aifont":"NYTCheltenhamSH-Bold","family":"nyt-cheltenham-sh,nyt-cheltenham,georgia,'times new roman',times,serif","weight":"700","style":""},
{"aifont":"NYTCheltenhamSH-BoldItalic","family":"nyt-cheltenham-sh,nyt-cheltenham,georgia,'times new roman',times,serif","weight":"700","style":"italic"},
{"aifont":"NYTCheltenhamWide-Regular","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"500","style":""},
{"aifont":"NYTCheltenhamWide-Italic","family":"nyt-cheltenham,georgia,'times new roman',times,serif","weight":"500","style":"italic"},
{"aifont":"NYTKarnakText-Regular","family":"nyt-karnak-display-130124,georgia,'times new roman',times,serif","weight":"400","style":""},
{"aifont":"NYTKarnakDisplay-Regular","family":"nyt-karnak-display-130124,georgia,'times new roman',times,serif","weight":"400","style":""},
{"aifont":"NYTStymieLight-Regular","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"300","style":""},
{"aifont":"NYTStymieMedium-Regular","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"500","style":""},
{"aifont":"StymieNYT-Light","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"300","style":""},
{"aifont":"StymieNYT-LightPhoenetic","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"300","style":""},
{"aifont":"StymieNYT-Lightitalic","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"300","style":"italic"},
{"aifont":"StymieNYT-Medium","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"500","style":""},
{"aifont":"StymieNYT-MediumItalic","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"500","style":"italic"},
{"aifont":"StymieNYT-Bold","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"700","style":""},
{"aifont":"StymieNYT-BoldItalic","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"700","style":"italic"},
{"aifont":"StymieNYT-ExtraBold","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"700","style":""},
{"aifont":"StymieNYT-ExtraBoldText","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"700","style":""},
{"aifont":"StymieNYT-ExtraBoldTextItal","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"700","style":"italic"},
{"aifont":"StymieNYTBlack-Regular","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"700","style":""},
{"aifont":"StymieBT-ExtraBold","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"700","style":""},
{"aifont":"Stymie-Thin","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"300","style":""},
{"aifont":"Stymie-UltraLight","family":"nyt-stymie,arial,helvetica,sans-serif","weight":"300","style":""},
{"aifont":"NYTMagSans-Regular","family":"'nyt-mag-sans',arial,helvetica,sans-serif","weight":"500","style":""},
{"aifont":"NYTMagSans-Bold","family":"'nyt-mag-sans',arial,helvetica,sans-serif","weight":"700","style":""}
];
var caps = [
{"ai":"FontCapsOption.NORMALCAPS","html":""},
{"ai":"FontCapsOption.ALLCAPS","html":"uppercase"},
{"ai":"FontCapsOption.SMALLCAPS","html":"uppercase"}
];
var align = [
{"ai":"Justification.LEFT","html":""},
{"ai":"Justification.RIGHT","html":"right"},
{"ai":"Justification.CENTER","html":"center"},
{"ai":"Justification.FULLJUSTIFY","html":"justify"},
{"ai":"Justification.FULLJUSTIFYLASTLINELEFT","html":"justify"},
{"ai":"Justification.FULLJUSTIFYLASTLINECENTER","html":"justify"},
{"ai":"Justification.FULLJUSTIFYLASTLINERIGHT","html":"justify"}
];
var pStyleKeyTags = [
"aifont",
"size",
"capitalization",
"r",
"g",
"b",
"tracking",
"leading",
"spacebefore",
"spaceafter",
"justification",
"opacity"
];
// ================================================
// declarations
// ================================================
var d = new Date();
var currYear = d.getFullYear();
var currDate = zeroPad(d.getDate(),2);
var currMonth = zeroPad(d.getMonth() + 1,2); //Months are zero based
var currHour = zeroPad(d.getHours(),2);
var currMin = zeroPad(d.getMinutes(),2);
var dateTimeStamp = currYear + "-" + currMonth + "-" + currDate + " - " + currHour + ":" + currMin;
// user inputs, settings, etc
var defaultFamily = "nyt-franklin,arial,helvetica,sans-serif";
var defaultWeight = "";
var defaultStyle = "";
var defaultSize = 13;
var defaultLeading = 18;
var nameSpace = "g-";
var imageScale = 200;
var maxJpgImageScaling = 776.19; // This is specified in the Javascript Object Reference under ExportOptionsJPEG.
var pctPrecision = 4;
var outputType = "pct"; // "abs" or "pct"
// var promoImageMinWidth = 768+40; // should be at least 768x507 AFTER being cropped, so we're making it extra large to get around this error
// var promoImageMinHeight = 507+40;
var promoImageMinWidth = 3000; // should be at least 768x507 AFTER being cropped, so we're making it extra large to get around Scoop error
var promoImageMinHeight = promoImageMinWidth*2/3;
var promoImageMaxWidth = 6000; // need to set a max width because ai jpg export fails if it's too large
var promoImageMaxHeight = promoImageMaxWidth*2/3;
// var settingsArrays = ["image_format"] // put hash keys here for settings that are arrays -- in the illustrator file, the setting should be in the format "key: value,value,value"
var settingsFrames = [];
var docSettings = {};
// vars to hold warnings and informational messages at the end
var feedback = [];
var warnings = [];
var errors = [];
// flags
// var docHasYml = false;
var docHadSettingsBlock = false;
var aiFileInPreviewProject = false;
var doc = app.activeDocument;
var docPath = doc.path + "/";
// var origFilename = doc.name;
var origFile = new File (docPath + doc.name);
var parentFolder = docPath.toString().match( /[^\/]+\/$/ );
var publicFolder = new Folder( docPath + "../public/" );
var srcFolder = new Folder( docPath + "../src/" );
var ymlFile = new File( docPath + "../config.yml" );
var gitConfigFile = new File( docPath + "../.git/config");
var alertText = "";
if (scriptEnvironment=="nyt") {
var alertHed = "Actually, that’s not half bad.";
} else {
var alertHed = "Nice work!";
}
var textFramesToUnhide = [];
var lockedObjects = [];
var hiddenObjects = [];
var largestArtboardIndex;
var largestArtboardArea = 0;
var largestArtboardWidth = 0;
var rgbBlackThreshold = 36; // value between 0 and 255 lower than which if all three RGB values are below then force the RGB to #000 so it is a pure black
var pBar = new progressBar();
pBar.init();
// work on inlining responsive js and css
// var responsiveCssFile = new File( docPath + "../public/assets/resizerStyle.css");
// var responsiveJsFile = new File( docPath + "../public/assets/resizerScript.js");
// var responsiveJs = "\t<script>\n";
// responiveJs
// inputFile,starterText,linePrefix,lineSuffix
// readTextFileAndPutIntoAVariable
// loop thru all layers, groups and textframes to find locked objects and unlock them
unlockStuff(doc);
//unhide layers that where hidded so objects inside could be locked
for (var i = hiddenObjects.length-1; i>=0; i--) {
hiddenObjects[i].visible = false;
};
// ================================================
// read .git/config file to get preview slug
// ================================================
if ( gitConfigFile.exists && scriptEnvironment=="nyt" ) {
gitConfigFile.open("r");
while(!gitConfigFile.eof) {
var line = gitConfigFile.readln();
var lineArray = line.split("=");
if (lineArray.length>1) {
var gitConfigKey = lineArray[0].replace( /^\s+/ , "" ).replace( /\s+$/ , "" );
var gitConfigValue = lineArray[1].replace( /^\s+/ , "" ).replace( /\s+$/ , "" );
if ( gitConfigKey=="url" ) {
docSettings.preview_slug = gitConfigValue.replace( /^[^:]+:/ , "" ).replace( /\.git$/ , "");
// feedback.push("preview slug = " + docSettings.preview_slug);
};
};
};
gitConfigFile.close();
};
// ================================================
// read yml file if it exists to determine what type of project this is
// ================================================
var previewProjectType = "";
if ( ymlFile.exists && scriptEnvironment=="nyt" ) {
ymlFile.open("r");
while(!ymlFile.eof) {
var line = ymlFile.readln();
var lineArray = line.split(":");
if (lineArray.length>1) {
var ymlKey = lineArray[0].replace( /^\s+/ , "" ).replace( /\s+$/ , "" );
var ymlValue = lineArray[1].replace( /^\s+/ , "" ).replace( /\s+$/ , "" );
if ( ymlKey=="project_type" && ymlValue=="ai2html") {
previewProjectType = ymlValue;
};
if ( ymlKey=="scoop_slug" ) {
docSettings.scoop_slug_from_config_yml = ymlValue;
};
};
};
ymlFile.close();
} else {
// if a config.yml file does not exist, then yml
previewProjectType = "config.yml is missing";
};
// ================================================
// Transfer default values into docSettings object.
// Generate text for ai2html settings block and determine length.
// ================================================
var defaultSettingsText = "ai2html-settings";
var ai2htmlSettingsLength = 0;
// var ymlSettings = {};
for (setting in ai2htmlBaseSettings) {
if (ai2htmlBaseSettings[setting].includeInSettingsBlock) {
defaultSettingsText += "\r" + setting + ': ' + ai2htmlBaseSettings[setting].defaultValue;
ai2htmlSettingsLength += 1;
};
// if (ai2htmlBaseSettings[setting].includeInConfigFile) {
// ymlSettings[setting] = ai2htmlBaseSettings[setting].defaultValue;
// };
docSettings[setting] = ai2htmlBaseSettings[setting].defaultValue;
};
if (docSettings.project_name == "") {
docSettings.project_name = doc.name.replace(/(.+)\.[aieps]+$/,"$1").replace(/ /g,"-");
} else {
docSettings.project_name = makeKeyword(docSettings.project_name);
}
// ================================================
// determine which artboards get which show classes
// ================================================
var nyt5Breakpoints = [
{ name:"xsmall" , lowerLimit: 0, upperLimit: 180, artboards:[] },
{ name:"small" , lowerLimit: 180, upperLimit: 300, artboards:[] },
{ name:"smallplus" , lowerLimit: 300, upperLimit: 460, artboards:[] },
{ name:"submedium" , lowerLimit: 460, upperLimit: 600, artboards:[] },
{ name:"medium" , lowerLimit: 600, upperLimit: 720, artboards:[] },
{ name:"large" , lowerLimit: 720, upperLimit: 945, artboards:[] },
{ name:"xlarge" , lowerLimit: 945, upperLimit:1050, artboards:[] },
{ name:"xxlarge" , lowerLimit:1050, upperLimit:1600, artboards:[] }
];
var breakpoints = {};
breakpoints.min = "";
breakpoints.max = "";
var artboardsToProcess = [];
var artboardsMaxMins = [];
var artboardsLefts = [];
var artboardsTops = [];
var largestNyt5Breakpoint = 0;
for (var bpNumber = 0; bpNumber < nyt5Breakpoints.length; bpNumber++) {
if (nyt5Breakpoints[bpNumber].upperLimit>largestNyt5Breakpoint) {
largestNyt5Breakpoint = nyt5Breakpoints[bpNumber].upperLimit;
};
};
// loop thru artboards and determine which ones to process.
// to manually force an artboard to appear at a specific pixel width,
// append the width to the end of the artboard name with a colon and then the number, eg. "Artboard name:720"
// old way of doing this: name that artboard with a "ai2html-" followed by the upperlimit of the breakpoint, eg. ai2html-720
pBar.setTitle('Determining artboards to process...')
for (var abNumber = 0; abNumber < doc.artboards.length; abNumber++) {
if (doc.artboards[abNumber].name.search(/^-/)==-1) {
artboardsToProcess.push(true);
var artboardWidthMatch = false;
var currentArtboard = doc.artboards[abNumber];
var currentArtboardWidth = 0;
// calculate artboard width for purposes of determining viewport -- need to make this into a function
if (doc.artboards[abNumber].name.search(/^.+:\d+$/)!=-1) {
currentArtboardWidth = (doc.artboards[abNumber].name.replace( /^.+:(\d+)$/ , "$1" ));
} else if (doc.artboards[abNumber].name.search(/^ai2html-\d+$/)!=-1) {
// this is the old way, supported for backward compatibility
currentArtboardWidth = (doc.artboards[abNumber].name.replace( /^ai2html-(\d+)$/ , "$1" ));
} else {
currentArtboardWidth = Math.round(currentArtboard.artboardRect[2]-currentArtboard.artboardRect[0]);
};
// alert(abNumber + " = " + currentArtboardWidth);
artboardsLefts.push(currentArtboard.artboardRect[0]);
artboardsTops.push(currentArtboard.artboardRect[1]);
for (var bpNumber = 0; bpNumber < nyt5Breakpoints.length; bpNumber++) {
var currentBreakpointWidth = nyt5Breakpoints[bpNumber].upperLimit;
if (currentBreakpointWidth==currentArtboardWidth) {
artboardWidthMatch = true;
};
};
if (!artboardWidthMatch && docSettings.include_resizer_classes=="yes" && docSettings.ai2html_environment=="nyt") {
// warnings.push('The width of the artboard named "' + currentArtboard.name + '" (#' + (abNumber+1) + ") does not match any of the NYT5 breakpoints and may produce unexpected results on your web page. OurYou probably want to adjust the width of this artboard so that it is exactly the width of a breakpoint.");
warnings.push('The width of the artboard named "' + currentArtboard.name + '" (#' + (abNumber+1) + ") does not match any of the NYT5 breakpoints and may produce unexpected results on your web page. The new script should be able to accommodate this, but please double check just in case.");
}
} else {
artboardsToProcess.push(false);
};
};
// figure out where is the top left of all artboards to place settings text block
artboardsLefts.sort(function(a,b){return a-b});
artboardsTops.sort(function(a,b){return a-b});
var artboardsLeft = artboardsLefts[0];
var artboardsTop = artboardsTops[artboardsTops.length-1];
// assign artboards to their corresponding breakpoints -- can have more than one artboard per breakpoint.
// also figure out the min and max breakpoints that have artboards.
var breakpointsWithNoNativeArtboard = [];
var overrideArtboardWidth = false;
var maxArtboardWidth = 0;
pBar.setTitle('Assigning artboards to breakpoints...')
for (var bpNumber = 0; bpNumber < nyt5Breakpoints.length; bpNumber++) {
var currentBreakpoint = nyt5Breakpoints[bpNumber];
for (var abNumber = 0; abNumber < doc.artboards.length; abNumber++) {
if (artboardsToProcess[abNumber]) {
var currentArtboard = doc.artboards[abNumber];
// calculate artboard width for purposes of determining viewport -- need to make this into a function
// need to figure out what to do here if responsiveness==fixed
// calculate artboard width for purposes of determining viewport -- need to make this into a function
if (doc.artboards[abNumber].name.search(/^.+:\d+$/)!=-1) {
currentArtboardWidth = (doc.artboards[abNumber].name.replace( /^.+:(\d+)$/ , "$1" ));
} else if (doc.artboards[abNumber].name.search(/^ai2html-\d+$/)!=-1) {
// this is the old way, supported for backward compatibility
currentArtboardWidth = (doc.artboards[abNumber].name.replace( /^ai2html-(\d+)$/ , "$1" ));
} else {
currentArtboardWidth = Math.round(currentArtboard.artboardRect[2]-currentArtboard.artboardRect[0]);
};
if (currentArtboardWidth>maxArtboardWidth) {
maxArtboardWidth = currentArtboardWidth;
};
if (currentArtboardWidth<=currentBreakpoint.upperLimit&¤tArtboardWidth>currentBreakpoint.lowerLimit) {
currentBreakpoint.artboards.push(abNumber);
};
};
};
if (currentBreakpoint.artboards.length==0) {
breakpointsWithNoNativeArtboard.push(currentBreakpoint.name);
} else {
if (breakpoints.min=="") {
breakpoints.min = currentBreakpoint.upperLimit;
};
if (overrideArtboardWidth==false) {
breakpoints.max = currentBreakpoint.upperLimit;
} else {
breakpoints.max = nyt5Breakpoints[nyt5Breakpoints.length-1].upperLimit;
};
};
};
var noNativeArtboardWarning = "These breakpoints have no native artboard: ";
for (var bpNumber = 0; bpNumber < breakpointsWithNoNativeArtboard.length; bpNumber++) {
noNativeArtboardWarning += breakpointsWithNoNativeArtboard[bpNumber];
if (bpNumber<breakpointsWithNoNativeArtboard.length-1) {
noNativeArtboardWarning += ", ";
};
};
// error message for breakpoints that have more than one native artboard
for (var bpNumber = 0; bpNumber < nyt5Breakpoints.length; bpNumber++) {
var nyt5Breakpoint = nyt5Breakpoints[bpNumber];
if (nyt5Breakpoint.artboards.length>1&&docSettings.ai2html_environment=="nyt") {
warnings.push('The ' + nyt5Breakpoint.upperLimit + "px breakpoint has " + nyt5Breakpoint.artboards.length + " artboards. You probably want only one artboard per breakpoint.")
}
};
//put artboard in for breakpoints with no artboard starting from smallest to largest, leaving lower end empty if nothing at the bottom end.
var breakpointsWithNoArtboard = [];
var noArtboard = false;
for (var bpNumber = 0; bpNumber < nyt5Breakpoints.length; bpNumber++) {
var currentBreakpoint = nyt5Breakpoints[bpNumber];
var previousArtboards = [];
if (bpNumber>0) {
previousArtboards = nyt5Breakpoints[bpNumber-1].artboards;
};