-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpoem.php
More file actions
523 lines (494 loc) · 26.8 KB
/
Copy pathpoem.php
File metadata and controls
523 lines (494 loc) · 26.8 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
<?php
require_once '/home/raphi/config/mysql_config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/section.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/sql_queries.php';
// include, not require: the statistics panel is an extra. If this file
// is absent or a version behind, the poem must still render.
@include_once $_SERVER['DOCUMENT_ROOT'] . '/corpus.php';
// Create connection
$mysql = new mysqli($servername, $username, $password, $dbname);
$mysql->set_charset('utf8mb4');
// Check connection
if ($mysql->connect_error) {
die("Connection failed: " . $mysql->connect_error);
}
// $code goes into a BOUND parameter, never into the SQL text.
$code = (string)($_GET["poem"] ?? '');
$complete_poem = poem_sql($mysql, $code, $GENRE);
$poem = $complete_poem[0] ?? null;
if (!$poem) {
header('HTTP/1.0 404 Not Found');
readfile('vos.html');
exit();
}
$poet = poet_sql($mysql, (string)$poem['ogpoet']) ?? [];
$def_con = "One day, <em>beezras hashem</em>, there will be a <em>bisl (ober zayer gut geshribn)</em> background here!";
$def_bio = "Tomorrow, <em>keyn eyn ore</em>, I'll write <em>zayer a fayne</em> bio!";
$def_trans = "<em>Hot geduld!</em> We're working on it!";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=.5, maximum-scale=.5">
<script src="/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?= $SECTION_BASE ?>/style.css">
<link rel='shortcut icon' href='/favicon.png' type='image/x-icon' />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<title><?= e($poem['title_y']) ?></title>
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-X8X9FRW4HG"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-X8X9FRW4HG');
</script>
<body>
<?php include_once $_SERVER['DOCUMENT_ROOT'].'/header.php'; ?>
<div class="img_popup" id="the_img_popup"><img class="img_popup_cnt" id="the_pop_img">
<div id="img_popup_cap"></div>
<span class="close" >×</span>
</div>
<div class="poem_context">
<h3 class="poem_context_title">A <em>Bisl</em> Background<span class="poem_context_title yid" dir="rtl">אַ קלײנער פֿאָן</span></h3>
<img class="context" src="<?php echo e(media_url($poem['img'] ?? null ?: 'con_default.jpg', 'images')); ?>" data-tippy="<?php echo (is_null($poem['img']) ? "Illustration © Christophe Vorlet" : $poem['img_src']); ?>" data-src="<?php echo (is_null($poem['img']) ? "Illustration © Christophe Vorlet" : $poem['img_src']); ?>">
<p>
<?php echo (is_null($poem['context']) ? $def_con : nl2br($poem['context']));?>
</p>
</div>
<div class="poem_wrapper">
<div class="reading">
<?php
// Seven of the 21 recordings are .m4a or .wav, but every one of
// them used to be served as type="audio/mpeg". Derive it instead.
if (is_null($poem['reader']) || empty($poem['rec'])) {
echo '<img class="rec_img" src="/aleph.jpeg">';
} else {
$rec_mime = match (strtolower(pathinfo($poem['rec'], PATHINFO_EXTENSION))) {
'm4a' => 'audio/mp4',
'wav' => 'audio/wav',
'ogg' => 'audio/ogg',
'flac' => 'audio/flac',
default => 'audio/mpeg',
};
echo '<audio controls><source src="' . e(media_url($poem['rec'], 'readings'))
. '" type="' . e($rec_mime) . '">Your browser does not support the audio element. </audio>';
}
?>
<h4 class="reader"><em>Read by</em> <?php echo (is_null($poem['reader']) ? "no one yet ☹" : $poem['reader']); ?></h4>
</div>
<div class="lang_btns">
<!--
check what trans are available
add the trans
add the buttons
js swap button possition and tippy data
-->
<?php
include $_SERVER['DOCUMENT_ROOT'] . '/dates.php';
$trans_but = "";
$trans_text = "";
$trans_title = "";
$trans_trans = "";
$trans_date = "";
$trans_tippy = "";
$lang_labels = array("eng"=>"EN", "fr"=>"FR",
"heb"=>"עב", "esp"=>"ES", "ru"=>"RU", "slv"=>"SL");
foreach ($complete_poem as $trec) {
if (!empty($trec['text']) and !is_null($trec['text'])) {
if (empty($trans_but)) {
$trans_but = '<button class="lang_btn main ' . $trec['lang'] .'" id="' . $trec['lang'] . '_btn" data-lang="' . $trec['lang'] . '">' . $lang_labels[$trec['lang']] . '</button>';
} else {
$trans_tippy .= "<button class='lang_btn extra " . $trec['lang'] ."' id='" . $trec['lang'] . "_btn' data-lang='" . $trec['lang'] . "'>" . $lang_labels[$trec['lang']] . "</button> ";
}
// title
$trans_title .= '<div class="not_cur title_container ' . $trec['lang'] . '"><h2 class="title ' . $trec['lang'] . '"' . (is_null($trec['tsource']) ? "" : 'title="' . $trec['tsource'] . '" data-tippy="' . $trec['tsource'] . '"') . '>' . $trec['title'] . '</h2><h3 class="author ' . $trec['lang'] . '"><form action="poet.php" method="get"><button type="submit" class="clk_poet" name="poet" value="' . $poet['name_e'] . '">' . (is_null($trec['tpoet']) ? $poet['name_e'] : $trec['tpoet']) . '</button></form></h3></div>';
// translator
$trans_trans .= '<h3 class="not_cur translator ' . $trec['lang'] . '"><em>' . $translate_msg[$trec['lang']] . '</em> ' . $trec['ttranslator'] . '</h3>';
// text
$trans_text .= '<div class="not_cur poem_body ' . $trec['lang'] . '">' . str_replace(' ',' ', str_replace("\t",' ', nl2br($trec['text']))) . '</div>';
$trans_date .= '<div class="not_cur date ' . $trec['lang'] . '">' . $full_date[$trec['lang']] . '</div>';
}
}
if (empty($trans_but)) {
$trans_but = '<button class="not_cur lang_btn eng" id="eng_btn" data-lang="eng">AB</button>';
}
if (empty($trans_title)) {
$trans_title .= '<div class="not_cur title_container eng"><h2 class="title eng"' . (is_null($poem['tsource']) ? "" : 'title="' . $poem['tsource'] . '" data-tippy="' . $poem['tsource'] . '"') . '>' . $poem['title'] . '</h2><h3 class="author eng"><form action="poet.php" method="get"><button type="submit" class="clk_poet" name="poet" value="' . $poet['name_e'] . '">' . $poet['name_e'] . '</button></form></h3></div>';
}
if (empty($trans_trans)) {
$trans_trans = '<h3 class="not_cur translator eng"><em>translated by </em> nobody yet :(</h3>';
}
if (empty($trans_text)) {
$trans_text = '<div class="not_cur poem_body eng"> ' . $def_trans . '</div>';
}
//$trans_but = str_replace('data-tippy=""', 'data-tippy="' . $trans_tippy . '"', $trans_but);
echo $trans_but;
?>
<button class="lang_btn yid cur_lang_btn" id="yid_btn" data-lang="yid" dir="rtl">אב</button>
<div class="styles" >
<span class="dark_poem" data-tippy="Darken or Lighten Background" title="Darken or Lighten Background"></span>
<span class="expand_poem" data-tippy="<?= e($S['expand']) ?>" title="<?= e($S['expand']) ?>"></span>
<span class="font_poem" data-tippy="Change the Font" title="Change the Font"></span>
</div>
</div>
<!-- TITLE -->
<?php echo $trans_title; ?>
<div class="title_container yid">
<h2 class="title yid" dir="rtl" <?php echo (is_null($poem['ogsource']) ? "" : 'title="' . $poem['ogsource'] . '" data-tippy="' . $poem['ogsource'] . '"') ?>><?php echo $poem['title_y']; ?></h2>
<h3 class="author yid" dir="rtl"><form action="poet.php" method="get"><button type="submit" class="clk_poet" name="poet" value="<?php echo $poet['name_e']; ?>"><?php echo $poet['name_y']; ?></button></form></h3>
</div>
<!-- TRANSLATOR -->
<?php echo $trans_trans; ?>
<!-- POEM -->
<?php echo $trans_text; ?>
<div class="poem_body yid" id="yid_text" dir="rtl">
<?php echo str_replace(' ',' ', str_replace("\t",' ', nl2br($poem['text_y']))); ?>
</div>
<br>
<!-- DATE -->
<?php echo $trans_date; ?>
<div class="date yid" dir="rtl"><?php echo $full_date_y; ?></div>
</div>
<div class="author_blurb">
<h3 class="author_blurb_title"> <?= e($S['author_e']) ?><span class="yid author_blurb_title"><?= e($S['author_y']) ?></span></h3>
<img class="poet" src="<?php echo e(media_url($poet['img'] ?? null, 'images')); ?>" data-tippy="<?php echo (is_null($poet['img_src']) ? "" : $poet['img_src']); ?>" data-src="<?php echo (is_null($poet['img_src']) ? "" : $poet['img_src']); ?>">
<?php
// Name and dates, between the portrait and the biography.
//
// Years only. The database stores birth and death as YYYY-MM-DD
// with zeros for the parts nobody recorded, and for most of
// these poets only the year is known — printing "January 1, 1886"
// for a row that means "1886" would invent a precision the
// record does not have.
$yearOf = function (?string $d): string {
$y = (int)substr((string)$d, 0, 4);
return $y > 0 ? (string)$y : '';
};
$born = $yearOf($poet['birth'] ?? null);
$died = $yearOf($poet['death'] ?? null);
// An en dash with nothing after it reads as "still alive", which
// is a claim rather than an absence, so a lone birth year says so.
$span = '';
if ($born !== '' && $died !== '') { $span = $born . '–' . $died; }
elseif ($born !== '') { $span = 'b. ' . $born; }
elseif ($died !== '') { $span = 'd. ' . $died; }
?>
<p class="poet_ident">
<span class="poet_name_e"><?= e($poet['name_e'] ?? '') ?></span>
<?php if ($span !== ''): ?>
<span class="poet_dates"><?= e($span) ?></span>
<?php endif; ?>
</p>
<p>
<?php echo (is_null($poet['bio']) ? $def_bio : nl2br($poet['bio']));?>
</p>
</div>
<div class="resources">
<h3 class="resource_title">Resources</h3>
<?php
// Links are escaped on output. They used to be echoed raw, which
// was harmless while only you added them — but once the public
// form writes to the submission table, descr and link are
// stranger-supplied and would otherwise be an XSS hole.
$render_links = function (array $rows): void {
if (!$rows) {
echo "I swear I put a link here... ";
return;
}
foreach ($rows as $r) {
$url = (string)$r['link'];
// only http(s), so javascript: and data: cannot get in
if (!preg_match('#^https?://#i', $url)) {
continue;
}
echo '<a href="' . e($url) . '" rel="noopener noreferrer">'
. e($r['descr'] ?: $url) . '</a>; ';
}
};
?>
<span class="resource_subtitle"><?= e($S['more_author']) ?>  </span>
<?php $render_links(biolinks_sql($mysql, (string)($poet['name_e'] ?? ''))); ?>
<span class="resource_subtitle"><?= e($S['more_work']) ?>  </span>
<?php $render_links(poemlinks_sql($mysql, (string)$poem['poem'])); ?>
<span class="resource_subtitle">More on context:  </span>
<?php $render_links(contextlinks_sql($mysql, (string)$poem['poem'])); ?>
</div>
<?php
// Section wording, worked out once for the whole pane. The graph
// links used to say "poem" and "poet" outright, so the prose site
// offered to graph "all poems by poet" — the labels were wrong even
// though the data behind them was right.
$one = $S['work_one'] ?? 'poem';
$many = $S['works_many'] ?? 'poems';
$oneAuthor = $S['author_one'] ?? 'poet';
?>
<div class="tooltiptext " id="word_option" disabled>
<button class="tooltip_btn" id="close_tt">×</button>
<h3 class="lkup_word" dir="rtl">Tokens</h3>
<div class="tooltip_instructions">double-click, highlight or type a word from the <?= e($one) ?> to add it here</div>
<form action="#" method="" enctype="multipart/form-data">
1) <input class="token" type="text" name="token0"><br>
2) <input class="token" type="text" name="token1"><br>
3) <input class="token" type="text" name="token2"><br>
4) <input class="token" type="text" name="token3"><br>
5) <input class="token" type="text" name="token4"><br>
<input type="reset" class="clr_tokens" value="Clear">
<br>Check usage of the tokens...<br>
<a class="tooltip_btn" dir="ltr" data-og="/graph.php?func=0" href="">...by date (all <?= e($many) ?>)</a>
<br>
<a class="tooltip_btn" dir="ltr" data-og="/graph.php?func=1" href="">...by <?= e($oneAuthor) ?> (all <?= e($many) ?>)</a>
<br>
<a class="tooltip_btn" dir="ltr" data-og="/graph.php?func=2&tokens[]=<?php echo $code; ?>" href="">...in this <?= e($one) ?></a>
<br>
<a class="tooltip_btn" dir="ltr" data-og="/graph.php?func=3&tokens[]=<?php echo $code; ?>" href="">...by <?= e($one) ?> (this <?= e($oneAuthor) ?> only)</a>
<br>
<a class="tooltip_btn" dir="ltr" data-og="/graph.php?func=4&tokens[]=<?php echo $code; ?>" href="">...by date (this <?= e($oneAuthor) ?> only)</a>
</form>
<?php
// Load poem statistics from the save-time index. Guard each
// section independently so unavailable data never prevents the
// page and its scripts from loading; display whatever is available.
$stat = $rank = null;
$topAll = $topCont = [];
$statTry = function (callable $fn, string $what) {
try {
return $fn();
} catch (Throwable $e) {
error_log("poem stats: $what unavailable — " . $e->getMessage());
return null;
}
};
$stat = $statTry(
fn() => function_exists('corpusPoemStat')
? corpusPoemStat($mysql, $code) : null, 'counts');
if ($stat) {
$rank = $statTry(
fn() => function_exists('corpusSttrRank')
? corpusSttrRank($mysql, $code, $GENRE) : null,
'vocabulary richness');
$topAll = $statTry(
fn() => function_exists('corpusTopWords')
? corpusTopWords($mysql, $code, 6, false) : [],
'word frequencies') ?? [];
// If the filtered list fails, fall back to the unfiltered one
// rather than showing nothing.
$topCont = $statTry(
fn() => function_exists('corpusTopWords')
? corpusTopWords($mysql, $code, 6, true) : [],
'common-word filter') ?? $topAll;
}
if ($stat):
// $one, $many and $oneAuthor come from the top of this pane.
// Percentile needs an English ordinal suffix.
$pc = (int)($rank['percentile'] ?? 0);
$ord = ($pc % 100 >= 11 && $pc % 100 <= 13) ? 'th'
: ([1 => 'st', 2 => 'nd', 3 => 'rd'][$pc % 10] ?? 'th');
// One bar chart renderer for both word lists.
$wordRows = function (array $rows): string {
if (!$rows) {
return '<tr><td class="stat_none">Nothing left once the '
. 'common words are set aside.</td></tr>';
}
$max = max(array_column($rows, 'n')) ?: 1;
$html = '';
foreach ($rows as $w) {
$pct = max(2, (int)round(100 * $w['n'] / $max));
// The only inline style is the bar length, which is
// data. Everything else lives in style.css.
$html .= '<tr><th class="yid" dir="rtl">' . e($w['word'])
. '</th><td class="stat_wbar"><i style="width:'
. $pct . '%"></i></td><td class="stat_wn">'
. (int)$w['n'] . '</td></tr>';
}
return $html;
};
?>
<div class="poem_stats" dir="ltr">
<h3>This <?= ucfirst(e($one)) ?> in Numbers</h3>
<table class="stat_grid">
<tr>
<td><?= number_format((int)$stat['tokens']) ?></td>
<th><span class="stat_help" data-tippy-content="Every running
word in the <?= e($one) ?>, counted each time it appears.
Punctuation and numerals are not counted.">words</span></th>
</tr>
<tr>
<td><?= number_format((int)$stat['types']) ?></td>
<th><span class="stat_help" data-tippy-content="How many
distinct words those are. If a word appears twenty times
it is counted once here. Spellings of the same word are
counted together.">different
words</span></th>
</tr>
<tr>
<td><?= number_format((int)$stat['hapax']) ?></td>
<th><span class="stat_help" data-tippy-content="Words that
appear exactly once in this <?= e($one) ?> — not in the
poet's other work, and not in the corpus. A high share
usually means the writing keeps reaching for new words
rather than circling a few.">words used only once</span></th>
</tr>
<tr>
<td><?= number_format((int)$stat['lines_n']) ?></td>
<th><span class="stat_help" data-tippy-content="Lines of
verse. A blank line between stanzas is a separator, not
a line, so it is not counted — this is the number you
would get counting the <?= e($one) ?>
yourself.">lines</span></th>
</tr>
<?php if ((int)($stat['stanzas'] ?? 0) > 1): ?>
<tr>
<td><?= number_format((int)$stat['stanzas']) ?></td>
<th><span class="stat_help" data-tippy-content="Blocks of
lines separated by a blank line. Read from the layout of
the text, so it follows however the <?= e($one) ?> was
transcribed.">stanzas</span></th>
</tr>
<?php endif; ?>
</table>
<?php if ($rank): ?>
<div class="stat_rank">
<span class="stat_rank_label">
<span class="stat_help" data-tippy-content="The share of
words that are different, averaged over stretches of a
hundred words. Measuring it in fixed stretches is what
makes long and short poems comparable. 1.00 would mean no word is ever repeated.">Vocabulary Richness</span>
</span>
<span class="stat_rank_val"><?= number_format($rank['sttr'], 2) ?></span>
<div class="stat_bar">
<i class="stat_bar_me" style="left:<?= max(0, min(100, $pc)) ?>%"></i>
<i class="stat_bar_med"></i>
</div>
<span class="stat_note">
<span class="stat_help" data-tippy-content="Compared with
every other <?= e($one) ?> on the site that is long
enough to score — <?= (int)$rank['n'] ?> of them. The
notch on the bar is the middle of that
range."><?= $pc . $ord ?> percentile</span>
of <?= (int)$rank['n'] ?> · median <?= number_format($rank['median'], 2) ?>
</span>
</div>
<?php elseif ((int)$stat['tokens'] < 100): ?>
<p class="stat_note stat_dim">
Too short to score for vocabulary richness—under a hundred
words.
</p>
<?php endif; ?>
<?php if ($topAll): ?>
<h4>Most Frequent Words</h4>
<label class="stat_toggle">
<input type="checkbox" id="stat_skipstop" checked>
<span class="stat_help" data-tippy-content="Hides common words, like articles, prepositions, conjunctions and helping verbs: דאָס, און, האָבן.">ignore common
words</span>
</label>
<table class="stat_words" id="stat_words_content">
<?= $wordRows($topCont) ?>
</table>
<table class="stat_words stat_hidden" id="stat_words_all">
<?= $wordRows($topAll) ?>
</table>
<?php endif; ?>
<a class="stat_link" href="/concordance.php">Search the whole corpus →</a>
</div>
<?php endif; ?>
</div>
<button type="button" id="tokens_fab" class="tokens_fab"
aria-controls="word_option" aria-expanded="false"
aria-label="Word lookup, statistics and graphs"
data-tippy-content="Word lookup, statistics and graphs">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<circle cx="10.5" cy="10.5" r="6.5"/>
<line x1="15.5" y1="15.5" x2="21" y2="21"/>
<line x1="7" y1="8.6" x2="14" y2="8.6"/>
<line x1="7" y1="12.4" x2="11.5" y2="12.4"/>
</svg>
</button>
<?php
if (!empty($trans_tippy)){
echo '<div id="extra_langs" style="display: none;">' . $trans_tippy . '</div>';
echo '<div id="multilang" style="display:none;">';
}
?>
<script src="poem.js"></script>
<script src="https://unpkg.com/tippy.js@3/dist/tippy.all.min.js"></script>
<script>
tippy.setDefaults({
interactive: true,
interactiveBorder: 2,
theme: 'oytser',
animateFill: false,
placement: 'bottom',
arrow: true,
arrowType: 'round'
});
const langs = document.getElementById('extra_langs');
if (langs != null) {
tippy('.lang_btn.main', { content: langs });
langs.style.display = 'block';
}
// Explanations for the statistics. Not interactive, and placed
// above so they do not cover the number being explained.
tippy('.stat_help', {
interactive: false,
placement: 'top',
maxWidth: 260,
delay: [200, 0]
});
// The floating button that opens the tokens pane.
const fab = document.getElementById('tokens_fab');
if (fab != null) {
tippy('#tokens_fab', {
interactive: false,
placement: 'right',
delay: [300, 0]
});
// Read the live value rather than tracking state separately:
// the close button, the graph links and selecting a word all
// change visibility too, so a local flag would drift.
const setOpen = function (open) {
$('.tooltiptext').css('visibility', open ? 'visible' : 'hidden');
fab.setAttribute('aria-expanded', String(open));
fab.classList.toggle('is_open', open);
};
fab.addEventListener('click', function (ev) {
ev.preventDefault();
setOpen($('.tooltiptext').css('visibility') !== 'visible');
});
// Keep the button in step when the pane is closed another way.
$('#close_tt, .tooltip_btn').on('click', function () {
fab.setAttribute('aria-expanded', 'false');
fab.classList.remove('is_open');
});
$('.poem_body.yid').on('click', function () {
const open = $('.tooltiptext').css('visibility') === 'visible';
fab.setAttribute('aria-expanded', String(open));
fab.classList.toggle('is_open', open);
});
// Escape closes it, as with any panel.
document.addEventListener('keydown', function (ev) {
if (ev.key === 'Escape' &&
$('.tooltiptext').css('visibility') === 'visible') {
setOpen(false);
}
});
}
// Common-word toggle. Both lists are rendered server-side, so
// switching is instant and works without a round trip.
const skip = document.getElementById('stat_skipstop');
if (skip != null) {
const content = document.getElementById('stat_words_content');
const all = document.getElementById('stat_words_all');
skip.addEventListener('change', function () {
content.classList.toggle('stat_hidden', !skip.checked);
all.classList.toggle('stat_hidden', skip.checked);
});
}
</script>
<div id="license" style="float: right; font-size: xx-small; width: 150px; text-align: justify; margin:auto; padding: 10px; display: block;">
<a rel="license" ref="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="display: block; border-width:0; margin: 0 auto;" src="https://i.creativecommons.org/l/by-sa/4.0/80x15.png" /></a><br />Except where otherwise noted, content on this site is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.
</div>
</body>
</html>