-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1816 lines (1601 loc) · 99.6 KB
/
index.html
File metadata and controls
1816 lines (1601 loc) · 99.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Content Buddy - Caltech Library</title>
<!-- Pico CSS Framework -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css">
<!-- SpringShare External Stylesheets for Preview -->
<link rel="stylesheet" href="https://static-assets-us.libguides.com/web/css3.23.3/lg-public-no-bs.min.css">
<link rel="stylesheet" href="https://libapps.s3.amazonaws.com/sites/64/include/libguides.css">
<!-- iCal.js for ICS file parsing -->
<script src="https://cdn.jsdelivr.net/npm/ical.js@1.5.0/build/ical.min.js"></script>
<!-- SheetJS for CSV/Excel parsing -->
<script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script>
<style>
/* Global focus indicator */
:focus-visible { outline: 2px solid #19747d !important; outline-offset: 2px; box-shadow: none !important; }
.ext-link-icon { display: inline-block; vertical-align: middle; margin-left: 3px; }
/* App-specific layout */
body { background: #f0f0f0; }
.app-container { max-width: 900px; margin: 0 auto; padding: 2rem; background: white; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.app-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid #e2e2e2; }
.app-header .wordmark { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.app-header .wordmark .blog { color: #19747d; }
.app-header .wordmark .buddy { color: #f06d0d; }
.app-header nav { display: flex; align-items: center; gap: 1rem; }
.app-header nav a:link, .app-header nav a:visited { color: #bd4b00; text-decoration: none; font-size: 0.95rem; }
.app-header nav a:hover { color: #111; }
.app-header h1 { margin: 0; font-size: inherit; font-weight: inherit; }
/* Form inputs */
input, textarea, select { background: white; }
input::placeholder, textarea::placeholder { color: #aaa; }
input:focus, textarea:focus, select:focus { --pico-border-color: #19747d; border-color: #19747d; }
/* Buttons */
button, [type="submit"], [type="button"] { --pico-primary-background: #19747d; --pico-primary-border: #19747d; --pico-primary-hover-background: #156068; --pico-primary-hover-border: #156068; padding: 0.5rem 1rem; font-size: 0.9rem; }
.file-upload-btn { display: inline-block; background: #19747d; color: white; padding: 0.5rem 1rem; font-size: 0.9rem; border-radius: var(--pico-border-radius); cursor: pointer; }
.file-upload-btn:hover { background: #156068; }
/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--pico-muted-border-color); margin-bottom: 1rem; }
.tab { padding: 0.75rem 1.5rem; background: none; border: none; border-bottom: 4px solid transparent; cursor: pointer; margin: 0; color: #555; outline: none; box-shadow: none; }
.tab:hover { background: #f5f5f5; color: #111; outline: none; box-shadow: none; }
.tab:focus-visible { outline: 2px solid #19747d; outline-offset: 2px; box-shadow: none; }
.tab.active { border-bottom-color: #f87924; color: #111; background: #f5f5f5; outline: none; box-shadow: none; }
.tab-content { display: none; }
.tab-content.active { display: block; }
/* Form layout helpers */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.button-group { margin: 1.5rem 0; text-align: center; }
.button-group button { margin: 0 0.5rem; }
/* Status messages */
.status { display: none; padding: 1rem; border-radius: var(--pico-border-radius); margin: 1rem 0; }
.status.success { display: block; background: #d4edda; color: #155724; }
.status.error { display: block; background: #f8d7da; color: #721c24; }
/* Sections */
.step-box { border: none; padding: 1rem; margin-bottom: 0; background: white; }
.step-box + .step-box { border-top: 2px solid #eee; }
.step-header { margin-bottom: 0.5rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1rem; font-size: 1.1rem; }
/* Toggle button group (segmented control style) */
.toggle-group { display: inline-flex; border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); overflow: hidden; }
.toggle-btn { cursor: pointer; margin: 0; }
.toggle-btn input { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
.toggle-btn input:focus-visible + span { outline: 2px solid #19747d; outline-offset: 2px; }
.toggle-btn span { display: block; padding: 0.5rem 1rem; background: white; border-right: 1px solid var(--pico-muted-border-color); font-size: 0.9rem; }
.toggle-btn:last-child span { border-right: none; }
.toggle-btn input:checked + span { background: #19747d; color: white; }
.toggle-btn:hover span { background: white; }
.toggle-btn input:checked:hover + span { background: #156068; }
.grey-toggle .toggle-btn input:checked + span { background: var(--pico-secondary-background); color: var(--pico-secondary-inverse); }
.grey-toggle .toggle-btn input:checked:hover + span { background: var(--pico-secondary-hover-background); }
/* Content box - light grey box with grey outline */
.content-box { padding: 1rem; background: #f7f9fb; border: 1px solid #ddd; border-radius: var(--pico-border-radius); margin-bottom: 1rem; }
.content-box h4 { margin-top: 0; margin-bottom: 0.75rem; color: #555; font-size: 0.95rem; border-bottom: 1px solid #eee; padding-bottom: 0.5rem; }
/* Link/Book entries */
.link-entry { padding: 1rem; background: white; border: 1px solid #ddd; border-radius: var(--pico-border-radius); margin-bottom: 1rem; position: relative; }
.link-entry h4 { margin-top: 0; margin-bottom: 0.75rem; color: #555; font-size: 0.95rem; border-bottom: 1px solid #eee; padding-bottom: 0.5rem; }
.books-import-container { padding: 1rem; background: #dee9f4; border: 1px solid #ddd; border-radius: var(--pico-border-radius); margin-bottom: 1rem; }
.books-import-container h4 { margin-top: 0; margin-bottom: 0.75rem; color: #555; font-size: 0.95rem; border-bottom: 1px solid #eee; padding-bottom: 0.5rem; }
.import-toggle-btn { padding: 0.45rem 1.1rem; font-size: 0.95rem; margin: 0.75rem 0; }
.add-link-btn { background: none; border: none; color: #b54500; padding: 0; font-weight: bold; }
.add-link-btn:hover { text-decoration: underline; background: none; }
.remove-link-btn { position: absolute; top: 0.5rem; right: 0.5rem; padding: 0.25rem 0.75rem; font-size: 0.8rem; }
#url-import-section h2, #ics-import-section h2, #isbn-fetch-section h2 { font-size: 1.25rem; }
h2.card-number { font-size: 1.5rem; }
/* Preview section */
.preview-section { display: none; margin: 2rem 0; padding: 1.5rem; border: 3px solid #19747d; border-radius: var(--pico-border-radius); background: white; }
.preview-section.show { display: block; }
.preview-container { max-height: 600px; overflow-y: auto; padding: 1rem; background: white; }
/* Code textarea */
textarea.code { font-family: monospace; font-size: 0.85rem; }
/* Preview content styles (for generated HTML output) */
.preview-container .book-item { padding: 20px; margin-bottom: 25px; border-bottom: 1px solid #e0e0e0; background-color: #ffffff; clear: both; }
.preview-container .book-item p { margin: 10px 0; }
.preview-container .book-item-odd { background-color: #f9f9f9; }
.preview-container .book-item-even { background-color: #ffffff; }
.preview-container .book-content { display: flex; gap: 20px; align-items: flex-start; }
.preview-container .book-cover { flex-shrink: 0; }
.preview-container .book-cover-img { width: 120px; height: auto; border-radius: 4px; box-shadow: 2px 2px 8px rgba(0,0,0,0.2); }
.preview-container .book-info { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.preview-container .book-main { display: flex; flex-direction: column; gap: 8px; }
.preview-container .book-title { font-size: 1.3rem; font-weight: bold; color: #333; line-height: 1.3; }
.preview-container .book-author { color: #333; font-size: 1rem; }
.preview-container .book-description { font-size: 0.95rem; color: #555; line-height: 1.6; margin-top: 4px; }
.preview-container .book-meta { display: flex; flex-direction: column; gap: 10px; }
.preview-container .book-details { color: #555; font-size: 0.95rem; line-height: 1.6; }
.preview-container .book-view-btn { display: inline-block; background-color: #19747d; color: white !important; padding: 10px 20px; border-radius: 4px; text-decoration: none; font-weight: bold; font-size: 0.95rem; transition: background-color 0.3s; width: fit-content; }
.preview-container .book-view-btn:hover { background-color: #156068; color: white; text-decoration: underline; }
.preview-container .event-item { display: flex; gap: 20px; padding: 20px; margin-bottom: 20px; background-color: #ffffff; border: 1px solid #e0e0e0; border-radius: 5px; }
.preview-container .event-date-box { flex-shrink: 0; width: 80px; height: 80px; background: #19747d; border-radius: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: white; }
.preview-container .event-day { font-size: 2rem; font-weight: bold; line-height: 1; }
.preview-container .event-month { font-size: 0.9rem; text-transform: uppercase; margin-top: 4px; letter-spacing: 1px; }
.preview-container .event-content { flex: 1; }
.preview-container .event-title { font-size: 1.4rem; font-weight: bold; color: #333; margin-bottom: 8px; }
.preview-container .event-meta { color: #333; font-size: 0.95rem; margin-bottom: 12px; line-height: 1.6; }
.preview-container .event-meta-item { margin-bottom: 4px; }
.preview-container .event-meta strong { color: #555; margin-right: 5px; }
.preview-container .event-description { line-height: 1.6; margin-bottom: 15px; color: #555; }
.preview-container .event-link { color: #bd4b00 !important; text-decoration: none; font-weight: bold; }
.preview-container .event-link:hover { color: #bd4b00; text-decoration: underline; }
.preview-container .link-section { margin-bottom: 30px; }
.preview-container .link-section-title { font-size: 1.3rem; font-weight: bold; color: #333; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid #e0e0e0; }
.preview-container .link-item { padding: 15px; margin-bottom: 12px; border: 1px solid #e0e0e0; border-radius: 5px; background-color: #ffffff; transition: all 0.3s; }
.preview-container .link-item:hover { border-color: #ccc; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.preview-container .link-title { font-size: 1.1rem; font-weight: bold; margin-bottom: 10px; }
.preview-container .link-title a { color: #bd4b00; text-decoration: none; }
.preview-container .link-title::before { content: "🔗 "; margin-right: 8px; }
.preview-container .link-title a:hover { text-decoration: underline; }
.preview-container .link-description { color: #555; line-height: 1.5; }
.preview-container .book-grid { display: flex; flex-wrap: wrap; gap: 25px; justify-content: flex-start; }
.preview-container .book-grid-item { width: 150px; text-align: center; }
.preview-container .book-grid-cover { margin-bottom: 10px; }
.preview-container .book-grid-cover img { width: 120px; height: auto; border-radius: 4px; box-shadow: 2px 2px 8px rgba(0,0,0,0.2); transition: transform 0.2s, box-shadow 0.2s; }
.preview-container .book-grid-cover img:hover { transform: translateY(-3px); box-shadow: 4px 4px 12px rgba(0,0,0,0.3); }
.preview-container .book-grid-cover a { display: block; }
.preview-container .book-grid-title { font-weight: bold; font-size: 0.95rem; color: #333; margin-bottom: 5px; line-height: 1.3; }
.preview-container .book-grid-title a { color: #bd4b00; text-decoration: none; font-weight: bold; }
.preview-container .book-grid-title a:hover { text-decoration: underline; }
.preview-container .book-grid-author { font-size: 0.85rem; color: #555; margin-bottom: 8px; }
</style>
</head>
<body>
<main class="container">
<div class="app-container">
<div class="app-header">
<h1><a href="index.html" class="wordmark" style="text-decoration: none;"><span class="blog">Content</span> <span class="buddy">Buddy</span></a></h1>
<nav>
<a href="help.html">Help</a>
<a href="https://forms.gle/GVPLeQuCNcU524z5A" target="_blank" rel="noopener noreferrer">Contact<svg class="ext-link-icon" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="opens in new tab"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a>
<a href="https://forms.gle/Q8qvoLaSTp8s44Gx7" target="_blank" rel="noopener noreferrer">Report Bug<svg class="ext-link-icon" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="opens in new tab"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg></a>
</nav>
</div>
<!-- Tab Navigation -->
<div class="tabs" role="tablist">
<button class="tab active" role="tab" aria-selected="true" aria-controls="books-tab" id="tab-books" onclick="switchTab('books')">📚 Booklist</button>
<button class="tab" role="tab" aria-selected="false" aria-controls="event-tab" id="tab-event" onclick="switchTab('event')">📅 Event</button>
<button class="tab" role="tab" aria-selected="false" aria-controls="links-tab" id="tab-links" onclick="switchTab('links')">🔗 Links</button>
<button class="tab" role="tab" aria-selected="false" aria-controls="cards-tab" id="tab-cards" onclick="switchTab('cards')">🃏 Card Layout</button>
</div>
<!-- Books Tab -->
<div id="books-tab" class="tab-content active" role="tabpanel" aria-labelledby="tab-books" tabindex="0">
<div class="step-box">
<div class="step-header"><strong>Step 1:</strong> Enter Book Details</div><br>
<div class="content-box">
<div>
<!-- <h4 style="margin: 0;">Build Your Booklist</h4> -->
<button class="secondary import-toggle-btn" onclick="toggleISBNFetch()">Import Details</button>
</div>
<div id="isbn-fetch-section" style="display: none;">
<div class="books-import-container">
<h2 id="book-import-text-area">ISBN Import</h2>
<div id="books-upload-status" class="status"></div>
<textarea aria-labelledby="book-import-text-area" id="isbn-input" style="min-height: 100px;" placeholder="Enter ISBNs separated by commas or line breaks"></textarea>
<div class="button-group">
<button onclick="fetchBooksFromISBNs()">Import Book Details</button>
</div>
</div>
</div>
<div id="books-container">
<div class="link-entry" data-book-index="0">
<h3>Book 1</h3>
<button class="remove-link-btn" onclick="removeBookEntry(this)">Remove</button>
<div class="form-group">
<label for="book-title-0">Title:*</label>
<input type="text" class="book-title-input" placeholder="Book title" id="book-title-0">
</div>
<div class="form-row">
<div class="form-group">
<label for="book-author-0">Author:</label>
<input type="text" class="book-author-input" placeholder="Author name" id="book-author-0">
</div>
<div class="form-group">
<label for="book-isbn-0">ISBN:</label>
<input type="text" class="book-isbn-input" placeholder="ISBN" id="book-isbn-0">
</div>
</div>
<div class="form-group">
<label for="book-description-0">Description:</label>
<textarea class="book-desc-input" style="min-height: 80px;" placeholder="Brief description of the book..." id="book-description-0"></textarea>
</div>
<div class="form-group">
<label for="book-cover-image-0">Cover Image URL:</label>
<input type="url" class="book-cover-input" placeholder="https://covers.openlibrary.org/b/isbn/..." id="book-cover-image-0">
</div>
<div class="form-group">
<label for="book-cover-alt-text-0">Cover Alt Text:</label>
<input type="text" class="book-alt-input" placeholder="e.g., Book cover of [Title] by [Author]" id="book-cover-alt-text-0">
</div>
<div class="form-group">
<label for="book-call-number-0">Call Number (optional):</label>
<input type="text" class="book-callnumber-input" placeholder="Call number" id="book-call-number-0">
</div>
<div class="form-group">
<label for="book-permalink-0">URL/Permalink (optional):</label>
<input type="url" class="book-url-input" placeholder="https://..." id="book-permalink-0">
</div>
</div>
</div>
<div class="button-group">
<button onclick="addBookEntry()">+ Add Another Book</button>
<button class="secondary" onclick="clearBooks()">Clear All</button>
</div>
</div>
</div>
<div class="step-box">
<div class="step-header"><strong>Step 2:</strong> Format Your Booklist</div><br>
<div class="content-box">
<h4>How should your booklist stack?</h4>
<fieldset>
<legend class="visually-hidden">How should your booklist stack?</legend>
<div class="toggle-group grey-toggle">
<label for="book-layout-vertical" class="toggle-btn"><input type="radio" name="book-layout" value="vertical" checked id="book-layout-vertical"><span>Vertical List</span></label>
<label for="book-layout-horizontal" class="toggle-btn"><input type="radio" name="book-layout" value="horizontal" id="book-layout-horizontal"><span>Horizontal Grid</span></label>
</div>
</fieldset>
<br>
<div class="button-group">
<button onclick="formatBooks()">Format Book List</button>
</div>
</div>
<div id="books-status" class="status"></div>
</div>
<div class="step-box">
<div class="step-header"><strong>Step 3:</strong> Preview & Copy Formatted HTML</div><br>
<div class="content-box">
<h4 id="book-formatted-html">Copy and paste HTML into source tab:</h4>
<textarea aria-labelledby="book-formatted-html" id="books-output" class="code" placeholder="Formatted HTML will appear here..." readonly></textarea>
<div class="button-group">
<button onclick="previewBooks()">Preview Styled HTML</button>
<button class="secondary" onclick="copyBooks()">Copy to Clipboard</button>
</div>
</div>
<div id="books-preview" class="preview-section">
<h2>Live Preview</h2>
<p>This is how your book list will look on the blog:</p>
<div id="books-preview-container" class="preview-container"></div>
</div>
</div>
</div>
<!-- Event Tab -->
<div id="event-tab" class="tab-content" role="tabpanel" aria-labelledby="tab-event" tabindex="0">
<div class="step-box">
<div class="step-header"><strong>Step 1:</strong> Enter Event Details</div><br>
<div class="content-box">
<div>
<button class="secondary import-toggle-btn" onclick="toggleICSImport()">Import Details</button>
</div>
<div id="ics-import-section" style="display: none;">
<div class="books-import-container">
<h2>Quick Fill from .ics</h2>
<div id="ics-status" class="status"></div>
<label for="ics-file-input" class="file-upload-btn">
<input type="file" id="ics-file-input" accept=".ics" onchange="handleICSUpload(event)" hidden>
<span>Upload File</span>
</label>
</div>
</div>
<div id="events-container">
<div class="link-entry" data-event-index="0">
<h3>Event 1</h3>
<button class="remove-link-btn" onclick="removeEventEntry(this)">Remove</button>
<div class="form-group">
<label for="event-title-0">Title:*</label>
<input type="text" class="event-title-input" placeholder="e.g., Author Reading & Q&A" id="event-title-0">
</div>
<div class="form-row">
<div class="form-group">
<label for="event-date-0">Date:*</label>
<input type="date" class="event-date-input" id="event-date-0">
</div>
<div class="form-group">
<label for="event-time-0">Time:</label>
<input type="time" class="event-time-input" id="event-time-0">
</div>
</div>
<div class="form-group">
<label for="event-location-0">Location:</label>
<input type="text" class="event-location-input" placeholder="e.g., Sherman Fairchild Library" id="event-location-0">
</div>
<div class="form-group">
<label for="event-description-0">Description:*</label>
<textarea class="event-description-input" style="min-height: 120px;" placeholder="Describe the event..." id="event-description-0"></textarea>
</div>
<div class="form-group">
<label for="event-link-url-0">Link (optional):</label>
<input type="url" class="event-link-input" placeholder="https://..." id="event-link-url-0">
</div>
<div class="form-group">
<label for="event-link-text-0">Link Text (if link provided):</label>
<input type="text" class="event-link-text-input" placeholder="e.g., Register Now, Learn More" id="event-link-text-0">
</div>
</div>
</div>
<div class="button-group">
<button onclick="addEventEntry()">+ Add Event Manually</button>
<button class="secondary" onclick="clearEvent()">Clear All</button>
</div>
</div>
</div>
<div class="step-box">
<div class="step-header"><strong>Step 2:</strong> Format Your Event</div><br>
<div class="content-box">
<div class="button-group">
<button onclick="formatEvent()">Format Event</button>
</div>
</div>
<div id="event-status" class="status"></div>
</div>
<div class="step-box">
<div class="step-header"><strong>Step 3:</strong> Preview & Copy Formatted HTML</div><br>
<div class="content-box">
<h4 id="event-formatted-html">Copy and paste HTML into source tab:</h4>
<textarea aria-labelledby="event-formatted-html" id="event-output" class="code" placeholder="Formatted HTML will appear here..." readonly></textarea>
<div class="button-group">
<button onclick="previewEvent()">Preview Styled HTML</button>
<button class="secondary" onclick="copyEvent()">Copy to Clipboard</button>
</div>
</div>
<div id="event-preview" class="preview-section">
<h2>Live Preview</h2>
<p>This is how your event will look on the blog:</p>
<div id="event-preview-container" class="preview-container"></div>
</div>
</div>
</div>
<!-- Links Tab -->
<div id="links-tab" class="tab-content" role="tabpanel" aria-labelledby="tab-links" tabindex="0">
<div class="step-box">
<div class="step-header"><strong>Step 1:</strong> Enter Link Details</div><br>
<div class="content-box">
<div>
<button class="secondary import-toggle-btn" onclick="toggleURLImport()">Import Details</button>
</div>
<div id="url-import-section" style="display: none;">
<div class="books-import-container">
<h2 id="link-import-text-area">Import Link Details</h2>
<div id="links-upload-status" class="status"></div>
<textarea aria-labelledby="link-import-text-area" id="url-input" style="min-height: 80px;" placeholder="Enter URLs, one per line"></textarea>
<div class="button-group">
<button onclick="fetchLinksFromURLs()">Import Link Details</button>
</div>
</div>
</div>
<div class="form-group">
<label for="links-section-title">Section Title (optional):</label>
<input type="text" id="links-section-title" placeholder="e.g., Related Resources, Further Reading">
</div>
<div id="links-container">
<div class="link-entry" data-link-index="0">
<h3>Link 1</h3>
<button class="remove-link-btn" onclick="removeLinkEntry(this)" aria-label="link-remove-button">Remove</button>
<div class="form-group">
<label for="link-title-0">Link Title:*</label>
<input type="text" class="link-title-input" placeholder="e.g., ACM Digital Library" id="link-title-0">
</div>
<div class="form-group">
<label for="link-url-0">URL:*</label>
<input type="url" class="link-url-input" placeholder="https://..." id="link-url-0">
</div>
<div class="form-group">
<label for="link-description-0">Description:</label>
<textarea class="link-desc-input" style="min-height: 80px;" placeholder="Brief description of this resource..." id="link-description-0"></textarea>
</div>
</div>
</div>
<div class="button-group">
<button onclick="addLinkEntry()">+ Add Another Link</button>
<button class="secondary" onclick="clearLinks()">Clear All</button>
</div>
</div>
</div>
<div class="step-box">
<div class="step-header"><strong>Step 2:</strong> Format Your Links</div><br>
<div class="content-box">
<div class="button-group">
<button onclick="formatLinks()">Format Links</button>
</div>
<div id="links-status" class="status"></div>
</div>
</div>
<div class="step-box">
<div class="step-header"><strong>Step 3:</strong> Preview & Copy Formatted HTML</div><br>
<div class="content-box">
<h4 id="link-formatted-html">Formatted HTML:</h4>
<textarea id="links-output" aria-labelledby="link-formatted-html" class="code" placeholder="Formatted HTML will appear here..." readonly></textarea>
<div class="button-group">
<button onclick="previewLinks()">Preview Styled Output</button>
<button class="secondary" onclick="copyLinks()">Copy to Clipboard</button>
</div>
<div id="links-preview" class="preview-section">
<h2>Live Preview</h2>
<p>This is how your links will look on the blog:</p>
<div id="links-preview-container" class="preview-container"></div>
</div>
</div>
</div>
</div>
<!-- Cards Tab -->
<div id="cards-tab" class="tab-content" role="tabpanel" aria-labelledby="tab-cards" tabindex="0">
<div class="step-box">
<div class="step-header"><strong>Step 1:</strong> Enter Card Details</div><br>
<div id="card-forms-container"></div>
<div class="button-group">
<button onclick="addCardEntry()">+ Add Another Card</button>
<button class="secondary" onclick="clearCards()">Clear All</button>
</div>
</div>
<div class="step-box">
<div class="step-header"><strong>Step 2:</strong> Format Your Cards</div><br>
<div class="content-box">
<h2>How should your cards display?</h2>
<fieldset>
<legend class="visually-hidden">How should your cards display</legend>
<div class="toggle-group grey-toggle">
<label class="toggle-btn" for="card-layout-horizontal"><input type="radio" name="card-layout" value="horizontal" checked id="card-layout-horizontal"><span>Horizontal Row</span></label>
<label class="toggle-btn" for="card-layout-vertical"><input type="radio" name="card-layout" value="vertical" id="card-layout-vertical"><span>Vertical Stack</span></label>
</div>
</fieldset>
<div class="button-group">
<button onclick="formatCards()">Format Cards</button>
</div>
<div id="cards-status" class="status"></div>
</div>
</div>
<div class="step-box">
<div class="step-header"><strong>Step 3:</strong> Preview & Copy Formatted HTML</div><br>
<div class="content-box">
<h3 id="card-formatted-component">Copy and paste HTML into source tab:</h3>
<textarea aria-labelledby="card-formatted-component" id="cards-output" class="code" placeholder="Formatted HTML will appear here..." readonly></textarea>
<div class="button-group">
<button onclick="previewCards()">Preview Styled HTML</button>
<button class="secondary" onclick="copyCards()">Copy to Clipboard</button>
</div>
</div>
<div id="cards-preview" class="preview-section">
<h2>Live Preview</h2>
<p>This is how your card layout will look on the blog:</p>
<div id="cards-preview-container" class="preview-container"></div>
</div>
</div>
</div>
</div>
</main>
<script>
let linkCounter = 1;
let bookCounter = 1;
let eventCounter = 1;
// Tab Switching
function switchTab(tabName) {
document.querySelectorAll('.tab-content').forEach(panel => {
panel.classList.remove('active');
});
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active');
tab.setAttribute('aria-selected', 'false');
});
document.getElementById(tabName + '-tab').classList.add('active');
event.target.classList.add('active');
event.target.setAttribute('aria-selected', 'true');
}
// ===== SHARED HELPERS =====
const EXT_LINK_ICON = `<svg class="ext-link-icon" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="opens in new tab"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>`;
function fetchWithTimeout(url, ms = 10000) {
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), ms);
return fetch(url, { signal: controller.signal })
.finally(() => clearTimeout(timer));
}
// ===== BOOKS TAB FUNCTIONS =====
function toggleISBNFetch() {
const section = document.getElementById('isbn-fetch-section');
const btn = event.currentTarget;
const isHidden = section.style.display === 'none';
section.style.display = isHidden ? 'block' : 'none';
btn.textContent = isHidden ? 'Close Import' : 'Import Details';
}
function addBookEntry() {
bookCounter++;
const container = document.getElementById('books-container');
const newEntry = document.createElement('div');
newEntry.className = 'link-entry';
newEntry.setAttribute('data-book-index', bookCounter);
newEntry.innerHTML = `
<h4>Book ${bookCounter}</h4>
<button class="remove-link-btn" onclick="removeBookEntry(this)">Remove</button>
<div class="form-group">
<label for="book-title-${bookCounter}">Title:*</label>
<input type="text" class="book-title-input" placeholder="Book title" id="book-title-${bookCounter}">
</div>
<div class="form-row">
<div class="form-group">
<label for="book-author-${bookCounter}">Author:</label>
<input type="text" class="book-author-input" placeholder="Author name" id="book-author-${bookCounter}">
</div>
<div class="form-group">
<label for="book-isbn-${bookCounter}">ISBN:</label>
<input type="text" class="book-isbn-input" placeholder="ISBN" id="book-isbn-${bookCounter}">
</div>
</div>
<div class="form-group">
<label for="book-description-${bookCounter}">Description:</label>
<textarea class="book-desc-input" style="min-height: 80px;" placeholder="Brief description of the book..." id="book-description-${bookCounter}"></textarea>
</div>
<div class="form-group">
<label for="book-cover-image-${bookCounter}">Cover Image URL:</label>
<input type="url" class="book-cover-input" placeholder="https://covers.openlibrary.org/b/isbn/..." id="book-cover-image-${bookCounter}">
</div>
<div class="form-group">
<label for="book-cover-alt-text-${bookCounter}">Cover Alt Text:</label>
<input type="text" class="book-alt-input" placeholder="e.g., Book cover of [Title] by [Author]" id="book-cover-alt-text-${bookCounter}">
</div>
<div class="form-group">
<label for="book-call-number-${bookCounter}">Call Number (optional):</label>
<input type="text" class="book-callnumber-input" placeholder="Call number" id="book-call-number-${bookCounter}">
</div>
<div class="form-group">
<label for="book-permalink-${bookCounter}">URL/Permalink:</label>
<input type="url" class="book-url-input" placeholder="https://..." id="book-permalink-${bookCounter}">
</div>
`;
container.appendChild(newEntry);
}
function removeBookEntry(button) {
button.parentElement.remove();
}
async function fetchBooksFromISBNs() {
const input = document.getElementById('isbn-input').value.trim();
const statusDiv = document.getElementById('books-upload-status');
if (!input) {
statusDiv.textContent = 'Please enter at least one ISBN.';
statusDiv.className = 'status error';
return;
}
// Parse ISBNs - split by comma, newline, or space
const isbns = input.split(/[\s,]+/).map(isbn => isbn.trim()).filter(isbn => isbn.length > 0);
if (isbns.length === 0) {
statusDiv.textContent = 'No valid ISBNs found.';
statusDiv.className = 'status error';
return;
}
statusDiv.innerHTML = `Importing details for ${isbns.length} book(s)...`;
statusDiv.className = 'status success';
statusDiv.style.display = 'block';
// Clear existing books
const container = document.getElementById('books-container');
container.innerHTML = '';
bookCounter = 0;
let successCount = 0;
let failCount = 0;
// Fetch book data for each ISBN
for (let i = 0; i < isbns.length; i++) {
const isbn = isbns[i];
statusDiv.innerHTML = `Book ${i + 1} of ${isbns.length}: fimporting from ISBN ${isbn}...`;
try {
// Fetch from Open Library API — data and details in parallel
const [dataResponse, detailsResponse] = await Promise.all([
fetchWithTimeout(`https://openlibrary.org/api/books?bibkeys=ISBN:${isbn}&format=json&jscmd=data`),
fetchWithTimeout(`https://openlibrary.org/api/books?bibkeys=ISBN:${isbn}&format=json&jscmd=details`)
]);
const [data, detailsData] = await Promise.all([dataResponse.json(), detailsResponse.json()]);
const bookData = data[`ISBN:${isbn}`];
const bookDetails = detailsData[`ISBN:${isbn}`];
let title = '';
let author = '';
let coverUrl = '';
let url = '';
let description = '';
if (bookData) {
title = bookData.title || '';
author = bookData.authors ? bookData.authors.map(a => a.name).join(', ') : '';
coverUrl = bookData.cover ? bookData.cover.large || bookData.cover.medium || bookData.cover.small || '' : '';
// If no cover from API, use colorful placeholder
if (!coverUrl) {
coverUrl = 'data:image/svg+xml,' + encodeURIComponent('<svg width="120" height="180" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="180" fill="#0e9383"/><rect x="10" y="15" width="100" height="150" fill="#0c8073" opacity="0.3"/><text x="60" y="100" font-family="Arial,sans-serif" font-size="48" fill="white" text-anchor="middle" opacity="0.8">📚</text></svg>');
}
// Leave URL blank - librarians will add their own links
url = '';
// Try edition-level description first
const rawEditionDesc = bookDetails?.details?.description;
if (rawEditionDesc) {
description = typeof rawEditionDesc === 'string' ? rawEditionDesc : (rawEditionDesc.value || '');
}
// If no edition description, fetch from the Work record
if (!description) {
const workKey = bookDetails?.details?.works?.[0]?.key;
if (workKey) {
try {
const workResponse = await fetchWithTimeout(`https://openlibrary.org${workKey}.json`);
const workData = await workResponse.json();
const rawWorkDesc = workData.description;
if (rawWorkDesc) {
description = typeof rawWorkDesc === 'string' ? rawWorkDesc : (rawWorkDesc.value || '');
}
} catch (e) {
// Work description unavailable — leave blank
}
}
}
successCount++;
} else {
// Book not found, but still create an entry with ISBN
title = `Book not found (ISBN: ${isbn})`;
coverUrl = 'data:image/svg+xml,' + encodeURIComponent('<svg width="120" height="180" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="180" fill="#0e9383"/><rect x="10" y="15" width="100" height="150" fill="#0c8073" opacity="0.3"/><text x="60" y="100" font-family="Arial,sans-serif" font-size="48" fill="white" text-anchor="middle" opacity="0.8">📚</text></svg>');
failCount++;
}
// Create book entry
const entry = document.createElement('div');
entry.className = 'link-entry';
entry.setAttribute('data-book-index', i);
const removeBtn = '<button class="remove-link-btn" onclick="removeBookEntry(this)">Remove</button>';
// Generate default alt text
const altText = title && author ? `Book cover of ${title} by ${author}` : (title ? `Book cover of ${title}` : '');
entry.innerHTML = `
<h4>Book ${i + 1}</h4>
${removeBtn}
<div class="form-group">
<label for="book-title-${i}">Title:*</label>
<input type="text" class="book-title-input" placeholder="Book title" id="book-title-${i}" value="${title.replace(/"/g, '"')}">
</div>
<div class="form-row">
<div class="form-group">
<label for="book-author-${i}">Author:</label>
<input type="text" class="book-author-input" placeholder="Author name" id="book-author-${i}" value="${author.replace(/"/g, '"')}">
</div>
<div class="form-group">
<label for="book-isbn-${i}">ISBN:</label>
<input type="text" class="book-isbn-input" placeholder="ISBN" id="book-isbn-${i}" value="${isbn}">
</div>
</div>
<div class="form-group">
<label for="book-description-${i}">Description:</label>
<textarea class="book-desc-input" style="min-height: 80px;" placeholder="Brief description of the book..." id="book-description-${i}">${description.replace(/</g, '<').replace(/>/g, '>')}</textarea>
</div>
<div class="form-group">
<label for="book-cover-image-${i}">Cover Image URL:</label>
<input type="url" class="book-cover-input" placeholder="https://covers.openlibrary.org/b/isbn/..." id="book-cover-image-${i}" value="${coverUrl}">
</div>
<div class="form-group">
<label for="book-cover-alt-text-${i}">Cover Alt Text:</label>
<input type="text" class="book-alt-input" placeholder="e.g., Book cover of [Title] by [Author]" id="book-cover-alt-text-${i}" value="${altText.replace(/"/g, '"')}">
</div>
<div class="form-group">
<label for="book-call-number-${i}">Call Number (optional):</label>
<input type="text" class="book-callnumber-input" placeholder="Call number" id="book-call-number-${i}" value="">
</div>
<div class="form-group">
<label for="book-permalink-${i}">URL/Permalink:</label>
<input type="url" class="book-url-input" placeholder="https://..." id="book-permalink-${i}" value="${url}">
</div>
`;
container.appendChild(entry);
bookCounter = i;
statusDiv.innerHTML = `Book ${i + 1} of ${isbns.length}: ✓ ${title || isbn}`;
} catch (error) {
console.error(`Error fetching ISBN ${isbn}:`, error);
failCount++;
const reason = error.name === 'AbortError' ? 'timed out' : 'failed';
statusDiv.className = 'status error';
statusDiv.innerHTML = `Book ${i + 1} of ${isbns.length}: ISBN ${isbn} ${reason} — entry created for manual editing`;
// Still create an entry even if import fails
const entry = document.createElement('div');
entry.className = 'link-entry';
entry.setAttribute('data-book-index', i);
const removeBtn = '<button class="remove-link-btn" onclick="removeBookEntry(this)">Remove</button>';
entry.innerHTML = `
<h4>Book ${i + 1}</h4>
${removeBtn}
<div class="form-group">
<label for="book-title-${i}">Title:*</label>
<input type="text" class="book-title-input" placeholder="Book title" id="book-title-${i}" value="Error importing ISBN: ${isbn}">
</div>
<div class="form-row">
<div class="form-group">
<label for="book-author-${i}">Author:</label>
<input type="text" class="book-author-input" placeholder="Author name" id="book-author-${i}" value="">
</div>
<div class="form-group">
<label for="book-isbn-${i}">ISBN:</label>
<input type="text" class="book-isbn-input" placeholder="ISBN" id="book-isbn-${i}" value="${isbn}">
</div>
</div>
<div class="form-group">
<label for="book-description-${i}">Description:</label>
<textarea class="book-desc-input" style="min-height: 80px;" placeholder="Brief description of the book..." id="book-description-${i}"></textarea>
</div>
<div class="form-group">
<label for="book-cover-image-${i}">Cover Image URL:</label>
<input type="url" class="book-cover-input" placeholder="https://covers.openlibrary.org/b/isbn/..." id="book-cover-image-${i}" value="${'data:image/svg+xml,' + encodeURIComponent('<svg width="120" height="180" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="180" fill="#0e9383"/><rect x="10" y="15" width="100" height="150" fill="#0c8073" opacity="0.3"/><text x="60" y="100" font-family="Arial,sans-serif" font-size="48" fill="white" text-anchor="middle" opacity="0.8">📚</text></svg>')}">
</div>
<div class="form-group">
<label for="book-cover-alt-text-${i}">Cover Alt Text:</label>
<input type="text" class="book-alt-input" placeholder="e.g., Book cover of [Title] by [Author]" id="book-cover-alt-text-${i}" value="">
</div>
<div class="form-group">
<label for="book-call-number-${i}">Call Number (optional):</label>
<input type="text" class="book-callnumber-input" placeholder="Call number" id="book-call-number-${i}" value="">
</div>
<div class="form-group">
<label for="book-permalink-${i}">URL/Permalink:</label>
<input type="url" class="book-url-input" placeholder="https://..." id="book-permalink-${i}" value="">
</div>
`;
container.appendChild(entry);
bookCounter = i;
}
}
if (successCount > 0) {
statusDiv.innerHTML = `Done: ${successCount} book(s) imported successfully.${failCount > 0 ? ` ${failCount} could not be imported but you can add the details manually.` : ''} Review and edit the details below.`;
statusDiv.className = 'status success';
} else {
statusDiv.textContent = `Failed to import book data. Blank records were created so you can add the details manually. However, the API can fail intermittenly. Please try again.`;
statusDiv.className = 'status error';
}
}
function formatBooks() {
const bookEntries = document.querySelectorAll('#books-container .link-entry');
const books = [];
let hasErrors = false;
// Get selected layout
const layout = document.querySelector('input[name="book-layout"]:checked').value;
bookEntries.forEach((entry, index) => {
const title = entry.querySelector('.book-title-input').value.trim();
const author = entry.querySelector('.book-author-input').value.trim();
const isbn = entry.querySelector('.book-isbn-input').value.trim();
const description = entry.querySelector('.book-desc-input').value.trim();
const coverUrl = entry.querySelector('.book-cover-input').value.trim();
const altText = entry.querySelector('.book-alt-input').value.trim();
const callNumber = entry.querySelector('.book-callnumber-input').value.trim();
const url = entry.querySelector('.book-url-input').value.trim();
if (title) {
books.push({ title, author, isbn, description, coverUrl, altText, callNumber, url });
} else {
hasErrors = true;
}
});
if (books.length === 0) {
showStatus('books', 'Please add at least one book with a title.', 'error');
return;
}
if (hasErrors) {
showStatus('books', 'Some books are missing titles. Each book needs at least a title.', 'error');
return;
}
let output;
if (layout === 'horizontal') {
// Generate horizontal grid layout
output = formatBooksHorizontal(books);
} else {
// Generate vertical list layout (default)
output = formatBooksVertical(books);
}
document.getElementById('books-output').value = output;
showStatus('books', `Success! Formatted ${books.length} book(s) in ${layout} layout.`, 'success');
}
function formatBooksVertical(books) {
const formattedBooks = books.map((book, index) => {
const oddEvenClass = (index % 2 === 0) ? 'book-item-odd' : 'book-item-even';
let bookHTML = `<div class="book-item ${oddEvenClass}">
<div class="book-content">`;
// Add cover image if provided
if (book.coverUrl) {
const imgAlt = book.altText || `Cover of ${book.title}`;
bookHTML += `
<div class="book-cover">
<img src="${book.coverUrl}" alt="${imgAlt}" class="book-cover-img">
</div>`;
}
bookHTML += `
<div class="book-info">
<div class="book-main">
<div class="book-title">${book.title}</div>`;
// Add author with link styling
if (book.author) {
bookHTML += `
<div class="book-author">${book.author}</div>`;
}
if (book.description) {
bookHTML += `
<div class="book-description">${book.description}</div>`;
}
bookHTML += `
</div>
<div class="book-meta">`;
// Add book details
const details = [];
if (book.isbn) details.push(`ISBN: ${book.isbn}`);
if (book.callNumber) details.push(`Call Number: ${book.callNumber}`);
if (details.length > 0) {
bookHTML += `
<div class="book-details">${details.join(' | ')}</div>`;
}
// Add View Book button if URL exists
if (book.url) {
bookHTML += `
<a href="${book.url}" target="_blank" rel="noopener noreferrer" class="book-view-btn">View Book${EXT_LINK_ICON}</a>`;
}
bookHTML += `
</div>
</div>
</div>
</div>`;
return bookHTML;
});
return `<!---------- BEGIN BOOK LIST (VERTICAL) ---------->\n${formattedBooks.join('\n\n')}\n<!---------- END BOOK LIST ---------->`;
}
function formatBooksHorizontal(books) {
const formattedBooks = books.map((book) => {
let bookHTML = ` <div class="book-grid-item">`;
// Cover with optional link wrapper
if (book.coverUrl) {
const imgAlt = book.altText || `Cover of ${book.title}`;
if (book.url) {
bookHTML += `
<div class="book-grid-cover">
<a href="${book.url}" target="_blank" rel="noopener noreferrer">
<img src="${book.coverUrl}" alt="${imgAlt}">
</a>
</div>`;
} else {
bookHTML += `
<div class="book-grid-cover">
<img src="${book.coverUrl}" alt="${imgAlt}">
</div>`;
}
}
// Title with optional link
if (book.url) {
bookHTML += `
<div class="book-grid-title"><a href="${book.url}" target="_blank" rel="noopener noreferrer">${book.title}${EXT_LINK_ICON}</a></div>`;
} else {
bookHTML += `
<div class="book-grid-title">${book.title}</div>`;
}
// Author
if (book.author) {
bookHTML += `
<div class="book-grid-author">${book.author}</div>`;
}
if (book.description) {
bookHTML += `
<div class="book-description">${book.description}</div>`;
}
bookHTML += `
</div>`;
return bookHTML;
});
return `<!---------- BEGIN BOOK LIST (HORIZONTAL) ---------->
<div class="book-grid">
${formattedBooks.join('\n')}
</div>
<!---------- END BOOK LIST ---------->`;
}
function previewBooks() {
const output = document.getElementById('books-output').value;
const previewSection = document.getElementById('books-preview');
const previewContainer = document.getElementById('books-preview-container');
if (!output) {
showStatus('books', 'Please format your book list first.', 'error');
previewSection.classList.remove('show');
return;
}
previewContainer.innerHTML = output;
previewSection.classList.add('show');