1d70512abSGreg Roach<?php 2d70512abSGreg Roach 3054771e9SGreg Roachuse Fisharebest\Webtrees\Age; 4054771e9SGreg Roachuse Fisharebest\Webtrees\Fact; 554c1ab5eSGreg Roachuse Fisharebest\Webtrees\Family; 654c1ab5eSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsPrint; 754c1ab5eSGreg Roachuse Fisharebest\Webtrees\I18N; 8d70512abSGreg Roachuse Fisharebest\Webtrees\Individual; 9d70512abSGreg Roach 102cebb4b4SGreg Roach/** 112cebb4b4SGreg Roach * @var int $baseyear 122cebb4b4SGreg Roach * @var int $bheight 132cebb4b4SGreg Roach * @var int $scale 142cebb4b4SGreg Roach * @var int $topyear 152cebb4b4SGreg Roach * @var array<Fact> $indifacts 162cebb4b4SGreg Roach * @var array<Individual> $individuals 172cebb4b4SGreg Roach */ 182cebb4b4SGreg Roach 19d70512abSGreg Roach?> 20eca4a663SGreg Roach 21eca4a663SGreg Roach<script> 222cebb4b4SGreg Roach let bottomy = <?= json_encode(($topyear - $baseyear) * $scale - 5) ?>; 232cebb4b4SGreg Roach let topy = 0; 242cebb4b4SGreg Roach let baseyear = <?= $baseyear - 25 / $scale ?>; 252cebb4b4SGreg Roach let birthyears = []; 262cebb4b4SGreg Roach let birthmonths = []; 272cebb4b4SGreg Roach let birthdays = []; 2854c1ab5eSGreg Roach <?php foreach ($individuals as $c => $indi) : ?> 2954c1ab5eSGreg Roach birthyears [<?= json_encode($c) ?>] = <?= json_encode($birthyears[$indi->xref()] ?? null) ?>; 3054c1ab5eSGreg Roach birthmonths[<?= json_encode($c) ?>] = <?= json_encode($birthmonths[$indi->xref()] ?? null) ?>; 3154c1ab5eSGreg Roach birthdays [<?= json_encode($c) ?>] = <?= json_encode($birthdays[$indi->xref()] ?? null) ?>; 3254c1ab5eSGreg Roach <?php endforeach ?> 33eca4a663SGreg Roach 342cebb4b4SGreg Roach let bheight = <?= json_encode($bheight) ?>; 352cebb4b4SGreg Roach let scale = <?= json_encode($scale) ?>; 36eca4a663SGreg Roach 37eca4a663SGreg Roach timeline_chart_div = document.getElementById("timeline_chart"); 3854c1ab5eSGreg Roach timeline_chart_div.style.height = '<?= json_encode(0 + ($topyear - $baseyear) * $scale * 1.1) ?>px'; 39eca4a663SGreg Roach 40eca4a663SGreg Roach /** 41eca4a663SGreg Roach * Find the position of an event, relative to an element. 42eca4a663SGreg Roach * 43eca4a663SGreg Roach * @param event 44eca4a663SGreg Roach * @param element 45eca4a663SGreg Roach */ 46eca4a663SGreg Roach function clickPosition(event, element) { 472cebb4b4SGreg Roach let xpos = event.pageX; 482cebb4b4SGreg Roach let ypos = event.pageY; 49eca4a663SGreg Roach 50eca4a663SGreg Roach if (element.offsetParent) { 51eca4a663SGreg Roach do { 52eca4a663SGreg Roach xpos -= element.offsetLeft; 53eca4a663SGreg Roach ypos -= element.offsetTop; 54eca4a663SGreg Roach } while (element = element.offsetParent); 55eca4a663SGreg Roach } 56eca4a663SGreg Roach 57eca4a663SGreg Roach return {x: xpos, y: ypos} 58eca4a663SGreg Roach } 59eca4a663SGreg Roach 602cebb4b4SGreg Roach let ob = null; 612cebb4b4SGreg Roach let Y = 0; 622cebb4b4SGreg Roach let X = 0; 632cebb4b4SGreg Roach let oldx = 0; 642cebb4b4SGreg Roach let oldlinew = 0; 652cebb4b4SGreg Roach let personnum = 0; 662cebb4b4SGreg Roach let type = 0; 672cebb4b4SGreg Roach let boxmean = 0; 68eca4a663SGreg Roach 69eca4a663SGreg Roach function ageCursorMouseDown(divbox, num) { 70eca4a663SGreg Roach ob = divbox; 71eca4a663SGreg Roach personnum = num; 72eca4a663SGreg Roach type = 0; 73eca4a663SGreg Roach X = ob.offsetLeft; 74eca4a663SGreg Roach Y = ob.offsetTop; 75eca4a663SGreg Roach } 76eca4a663SGreg Roach 77eca4a663SGreg Roach function factMouseDown(divbox, num, mean) { 78eca4a663SGreg Roach ob = divbox; 79eca4a663SGreg Roach personnum = num; 80eca4a663SGreg Roach boxmean = mean; 81eca4a663SGreg Roach type = 1; 82eca4a663SGreg Roach oldx = ob.offsetLeft; 83eca4a663SGreg Roach oldlinew = 0; 84eca4a663SGreg Roach } 85eca4a663SGreg Roach 86eca4a663SGreg Roach document.onmousemove = function (e) { 872cebb4b4SGreg Roach let textDirection = document.documentElement.dir; 88eca4a663SGreg Roach 89eca4a663SGreg Roach if (ob === null) { 90eca4a663SGreg Roach return true; 91eca4a663SGreg Roach } 922cebb4b4SGreg Roach let newx = 0; 932cebb4b4SGreg Roach let newy = 0; 94eca4a663SGreg Roach if (type === 0) { 95eca4a663SGreg Roach // age boxes 96eca4a663SGreg Roach newPosition = clickPosition(e, document.getElementById("timeline_chart")); 97eca4a663SGreg Roach newx = newPosition.x; 98eca4a663SGreg Roach newy = newPosition.y; 99eca4a663SGreg Roach 100eca4a663SGreg Roach if (oldx === 0) { 101eca4a663SGreg Roach oldx = newx; 102eca4a663SGreg Roach } 103eca4a663SGreg Roach if (newy < topy - bheight / 2) { 104eca4a663SGreg Roach newy = topy - bheight / 2; 105eca4a663SGreg Roach } 106eca4a663SGreg Roach if (newy > bottomy) { 107eca4a663SGreg Roach newy = bottomy - 1; 108eca4a663SGreg Roach } 109eca4a663SGreg Roach ob.style.top = newy + "px"; 1102cebb4b4SGreg Roach let tyear = (newy + bheight - 4 - topy + scale) / scale + baseyear; 1112cebb4b4SGreg Roach let year = Math.floor(tyear); 1122cebb4b4SGreg Roach let month = Math.floor(tyear * 12 - year * 12); 1132cebb4b4SGreg Roach let day = Math.floor(tyear * 365 - year * 365 - month * 30); 1142cebb4b4SGreg Roach let mstamp = year * 365 + month * 30 + day; 1152cebb4b4SGreg Roach let bdstamp = birthyears[personnum] * 365 + birthmonths[personnum] * 30 + birthdays[personnum]; 1162cebb4b4SGreg Roach let daydiff = mstamp - bdstamp; 1172cebb4b4SGreg Roach let ba = 1; 118eca4a663SGreg Roach if (daydiff < 0) { 119eca4a663SGreg Roach ba = -1; 120eca4a663SGreg Roach daydiff = (bdstamp - mstamp); 121eca4a663SGreg Roach } 1222cebb4b4SGreg Roach let yage = Math.floor(daydiff / 365); 1232cebb4b4SGreg Roach let mage = Math.floor((daydiff - yage * 365) / 30); 1242cebb4b4SGreg Roach let dage = Math.floor(daydiff - yage * 365 - mage * 30); 125eca4a663SGreg Roach if (dage < 0) { 126eca4a663SGreg Roach mage = mage - 1; 127eca4a663SGreg Roach } 128eca4a663SGreg Roach if (dage < -30) { 129eca4a663SGreg Roach dage = 30 + dage; 130eca4a663SGreg Roach } 131eca4a663SGreg Roach if (mage < 0) { 132eca4a663SGreg Roach yage = yage - 1; 133eca4a663SGreg Roach } 134eca4a663SGreg Roach if (mage < -11) { 135eca4a663SGreg Roach mage = 12 + mage; 136eca4a663SGreg Roach } 1372cebb4b4SGreg Roach let yearform = document.getElementById('yearform' + personnum); 1382cebb4b4SGreg Roach let ageform = document.getElementById('ageform' + personnum); 139eca4a663SGreg Roach yearform.innerHTML = year + " " + month + " <?= mb_substr(I18N::translate('Month:'), 0, 1) ?> " + day + " <?= mb_substr(I18N::translate('Day:'), 0, 1) ?>"; 140eca4a663SGreg Roach if (ba * yage > 1 || ba * yage < -1 || ba * yage === 0) { 141eca4a663SGreg Roach ageform.innerHTML = (ba * yage) + " <?= mb_substr(I18N::translate('years'), 0, 1) ?> " + (ba * mage) + " <?= mb_substr(I18N::translate('Month:'), 0, 1) ?> " + (ba * dage) + " <?= mb_substr(I18N::translate('Day:'), 0, 1) ?>"; 142eca4a663SGreg Roach } else { 143eca4a663SGreg Roach ageform.innerHTML = (ba * yage) + " <?= mb_substr(I18N::translate('Year:'), 0, 1) ?> " + (ba * mage) + " <?= mb_substr(I18N::translate('Month:'), 0, 1) ?> " + (ba * dage) + " <?= mb_substr(I18N::translate('Day:'), 0, 1) ?>"; 144eca4a663SGreg Roach } 1452cebb4b4SGreg Roach let line = document.getElementById('ageline' + personnum); 1462cebb4b4SGreg Roach let temp = newx - oldx; 147eca4a663SGreg Roach 148eca4a663SGreg Roach if (textDirection === 'rtl') { 149eca4a663SGreg Roach temp = temp * -1; 150eca4a663SGreg Roach } 151eca4a663SGreg Roach line.style.width = (line.width + temp) + "px"; 152eca4a663SGreg Roach oldx = newx; 153eca4a663SGreg Roach return false; 154eca4a663SGreg Roach } else { 155eca4a663SGreg Roach // fact boxes 1562cebb4b4SGreg Roach let linewidth; 157eca4a663SGreg Roach newPosition = clickPosition(e, document.getElementById("timeline_chart")); 158eca4a663SGreg Roach newx = newPosition.x; 159eca4a663SGreg Roach newy = newPosition.y; 160eca4a663SGreg Roach if (oldx === 0) { 161eca4a663SGreg Roach oldx = newx; 162eca4a663SGreg Roach } 163eca4a663SGreg Roach linewidth = e.pageX; 164eca4a663SGreg Roach 165eca4a663SGreg Roach // get diagnal line box 1662cebb4b4SGreg Roach let dbox = document.getElementById('dbox' + personnum); 1672cebb4b4SGreg Roach let etopy; 1682cebb4b4SGreg Roach let ebottomy; 169eca4a663SGreg Roach // set up limits 170eca4a663SGreg Roach if (boxmean - 175 < topy) { 171eca4a663SGreg Roach etopy = topy; 172eca4a663SGreg Roach } else { 173eca4a663SGreg Roach etopy = boxmean - 175; 174eca4a663SGreg Roach } 175eca4a663SGreg Roach if (boxmean + 175 > bottomy) { 176eca4a663SGreg Roach ebottomy = bottomy; 177eca4a663SGreg Roach } else { 178eca4a663SGreg Roach ebottomy = boxmean + 175; 179eca4a663SGreg Roach } 180eca4a663SGreg Roach // check if in the bounds of the limits 181eca4a663SGreg Roach if (newy < etopy) { 182eca4a663SGreg Roach newy = etopy; 183eca4a663SGreg Roach } 184eca4a663SGreg Roach if (newy > ebottomy) { 185eca4a663SGreg Roach newy = ebottomy; 186eca4a663SGreg Roach } 187eca4a663SGreg Roach // calculate the change in Y position 1882cebb4b4SGreg Roach let dy = newy - ob.offsetTop; 189eca4a663SGreg Roach // check if we are above the starting point and switch the background image 190eca4a663SGreg Roach 191eca4a663SGreg Roach if (newy < boxmean) { 192eca4a663SGreg Roach if (textDirection === 'rtl') { 193e837ff07SGreg Roach dbox.style.backgroundImage = "url('<?= asset('css/images/dline2.png') ?>')"; 194eca4a663SGreg Roach dbox.style.backgroundPosition = "0% 0%"; 195eca4a663SGreg Roach } else { 196e837ff07SGreg Roach dbox.style.backgroundImage = "url('<?= asset('css/images/dline.png') ?>')"; 197eca4a663SGreg Roach dbox.style.backgroundPosition = "0% 100%"; 198eca4a663SGreg Roach } 199eca4a663SGreg Roach dy = -dy; 200eca4a663SGreg Roach dbox.style.top = (newy + bheight / 3) + "px"; 201eca4a663SGreg Roach } else { 202eca4a663SGreg Roach if (textDirection === 'rtl') { 203e837ff07SGreg Roach dbox.style.backgroundImage = "url('<?= asset('css/images/dline.png') ?>')"; 204eca4a663SGreg Roach dbox.style.backgroundPosition = "0% 100%"; 205eca4a663SGreg Roach } else { 206e837ff07SGreg Roach dbox.style.backgroundImage = "url('<?= asset('css/images/dline2.png') ?>')"; 207eca4a663SGreg Roach dbox.style.backgroundPosition = "0% 0%"; 208eca4a663SGreg Roach } 209eca4a663SGreg Roach 210eca4a663SGreg Roach dbox.style.top = (boxmean + bheight / 3) + "px"; 211eca4a663SGreg Roach } 212eca4a663SGreg Roach // the new X posistion moves the same as the y position 213eca4a663SGreg Roach if (textDirection === 'rtl') { 214eca4a663SGreg Roach newx = dbox.offsetRight + Math.abs(newy - boxmean); 215eca4a663SGreg Roach } else { 216eca4a663SGreg Roach newx = dbox.offsetLeft + Math.abs(newy - boxmean); 217eca4a663SGreg Roach } 218eca4a663SGreg Roach // set the X position of the box 219eca4a663SGreg Roach if (textDirection === 'rtl') { 220eca4a663SGreg Roach ob.style.right = newx + "px"; 221eca4a663SGreg Roach } else { 222eca4a663SGreg Roach ob.style.left = newx + "px"; 223eca4a663SGreg Roach } 224eca4a663SGreg Roach // set new top positions 225eca4a663SGreg Roach ob.style.top = newy + "px"; 226eca4a663SGreg Roach // get the width for the diagnal box 2272cebb4b4SGreg Roach let newwidth = (ob.offsetLeft - dbox.offsetLeft); 228eca4a663SGreg Roach // set the width 229eca4a663SGreg Roach dbox.style.width = newwidth + "px"; 230eca4a663SGreg Roach if (textDirection === 'rtl') { 231eca4a663SGreg Roach dbox.style.right = (dbox.offsetRight - newwidth) + 'px'; 232eca4a663SGreg Roach } 233eca4a663SGreg Roach dbox.style.height = newwidth + "px"; 234eca4a663SGreg Roach // change the line width to the change in the mouse X position 235eca4a663SGreg Roach line = document.getElementById('boxline' + personnum); 236eca4a663SGreg Roach if (oldlinew !== 0) { 237eca4a663SGreg Roach line.width = line.width + (linewidth - oldlinew); 238eca4a663SGreg Roach } 239eca4a663SGreg Roach oldlinew = linewidth; 240eca4a663SGreg Roach oldx = newx; 241eca4a663SGreg Roach return false; 242eca4a663SGreg Roach } 243eca4a663SGreg Roach }; 244eca4a663SGreg Roach 245eca4a663SGreg Roach document.onmouseup = function () { 246eca4a663SGreg Roach ob = null; 247eca4a663SGreg Roach oldx = 0; 248eca4a663SGreg Roach } 249eca4a663SGreg Roach</script> 250eca4a663SGreg Roach 251eca4a663SGreg Roach<div id="timeline_chart"> 252eca4a663SGreg Roach <!-- print the timeline line image --> 253eca4a663SGreg Roach <div id="line" style="position:absolute; <?= I18N::direction() === 'ltr' ? 'left:22px;' : 'right:22px;' ?> top:0;"> 2542cebb4b4SGreg Roach <img src="<?= e(asset('css/images/vline.png')) ?>" width="3" 2552cebb4b4SGreg Roach height="<?= 0 + ($topyear - $baseyear) * $scale ?>"> 256eca4a663SGreg Roach </div> 257eca4a663SGreg Roach 258eca4a663SGreg Roach <!-- print divs for the grid --> 2592cebb4b4SGreg Roach <div id="scale<?= e($baseyear) ?>" 2602cebb4b4SGreg Roach style="position:absolute; <?= I18N::direction() === 'ltr' ? 'left' : 'right' ?>:0; top:-5px; font-size: 7pt; text-align: <?= I18N::direction() === 'ltr' ? 'left' : 'right' ?>;"> 261eca4a663SGreg Roach <?= $baseyear ?> 262eca4a663SGreg Roach </div> 263eca4a663SGreg Roach <?php 264eca4a663SGreg Roach // at a scale of 25 or higher, show every year 265eca4a663SGreg Roach $mod = 25 / $scale; 266eca4a663SGreg Roach if ($mod < 1) { 267eca4a663SGreg Roach $mod = 1; 268eca4a663SGreg Roach } 269eca4a663SGreg Roach for ($i = $baseyear + 1; $i < $topyear; $i++) { 270eca4a663SGreg Roach if ($i % $mod === 0) { 271eca4a663SGreg Roach echo '<div id="scale' . $i . '" style="position:absolute; ' . (I18N::direction() === 'ltr' ? 'left:0;' : 'right:0;') . ' top:' . ((($i - $baseyear) * $scale) - $scale / 2) . 'px; font-size: 7pt; text-align:' . (I18N::direction() === 'ltr' ? 'left' : 'right') . ';">'; 272eca4a663SGreg Roach echo $i; 273eca4a663SGreg Roach echo '</div>'; 274eca4a663SGreg Roach } 275eca4a663SGreg Roach } 276eca4a663SGreg Roach echo ''; 277eca4a663SGreg Roach ?> 2782cebb4b4SGreg Roach <div id="scale<?= e($topyear) ?>" 2792cebb4b4SGreg Roach style="position:absolute; <?= I18N::direction() === 'ltr' ? 'left' : 'right' ?>:0; top:<?= ($topyear - $baseyear) * $scale ?>px; font-size: 7pt; text-align:<?= I18N::direction() === 'ltr' ? 'left' : 'right' ?>;"> 280eca4a663SGreg Roach <?= e($topyear) ?> 281eca4a663SGreg Roach </div> 282eca4a663SGreg Roach 283eca4a663SGreg Roach <?php foreach ($indifacts as $factcount => $event) : ?> 284eca4a663SGreg Roach <?php 285eca4a663SGreg Roach $desc = $event->value(); 286eca4a663SGreg Roach $gdate = $event->date(); 287eca4a663SGreg Roach $date = $gdate->minimumDate(); 288eca4a663SGreg Roach $date = $date->convertToCalendar('gregorian'); 289eca4a663SGreg Roach $year = $date->year(); 290eca4a663SGreg Roach $month = max(1, $date->month()); 291eca4a663SGreg Roach $day = max(1, $date->day()); 292eca4a663SGreg Roach $xoffset = 0 + 22; 2932cebb4b4SGreg Roach $yoffset = 0 + ($year - $baseyear) * $scale - $scale; 2942cebb4b4SGreg Roach $yoffset = $yoffset + $month / 12 * $scale; 2952cebb4b4SGreg Roach $yoffset = $yoffset + $day / 30 * ($scale / 12); 296261d6e48SGreg Roach $yoffset = (int) $yoffset; 297eca4a663SGreg Roach $place = (int) ($yoffset / $bheight); 298eca4a663SGreg Roach $i = 1; 299eca4a663SGreg Roach $j = 0; 300eca4a663SGreg Roach $tyoffset = 0; 301eca4a663SGreg Roach while (isset($placements[$place])) { 302eca4a663SGreg Roach if ($i === $j) { 303eca4a663SGreg Roach $tyoffset = $bheight * $i; 304eca4a663SGreg Roach $i++; 305eca4a663SGreg Roach } else { 306eca4a663SGreg Roach $tyoffset = -1 * $bheight * $j; 307eca4a663SGreg Roach $j++; 308eca4a663SGreg Roach } 309eca4a663SGreg Roach $place = (int) (($yoffset + $tyoffset) / $bheight); 310eca4a663SGreg Roach } 311eca4a663SGreg Roach $yoffset += $tyoffset; 312eca4a663SGreg Roach $xoffset += abs($tyoffset); 313eca4a663SGreg Roach $placements[$place] = $yoffset; 314eca4a663SGreg Roach 315261d6e48SGreg Roach echo "<div id=\"fact$factcount\" style=\"position:absolute; " . (I18N::direction() === 'ltr' ? 'left: ' . $xoffset : 'right: ' . $xoffset) . 'px; top:' . $yoffset . 'px; font-size: 8pt; height: ' . $bheight . "px;\" onmousedown=\"factMouseDown(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ');">'; 316ca8f62c9SGreg Roach echo '<table cellspacing="0" cellpadding="0" border="0" style="cursor: grab;"><tr><td>'; 317f220ef57SGreg Roach echo '<img src="' . e(asset('css/images/hline.png')) . '" id="boxline' . $factcount . '" height="3" width="10" style="padding-'; 318eca4a663SGreg Roach if (I18N::direction() === 'ltr') { 319eca4a663SGreg Roach echo 'left: 3px;">'; 320eca4a663SGreg Roach } else { 321eca4a663SGreg Roach echo 'right: 3px;">'; 322eca4a663SGreg Roach } 323eca4a663SGreg Roach 32422d65e5aSGreg Roach $col = array_search($event->record(), $individuals, true); 325eca4a663SGreg Roach if ($col === false) { 326eca4a663SGreg Roach // Marriage event - use the color of the husband 32722d65e5aSGreg Roach $col = array_search($event->record()->husband(), $individuals, true); 328eca4a663SGreg Roach } 329eca4a663SGreg Roach if ($col === false) { 330eca4a663SGreg Roach // Marriage event - use the color of the wife 33122d65e5aSGreg Roach $col = array_search($event->record()->wife(), $individuals, true); 332eca4a663SGreg Roach } 3332cebb4b4SGreg Roach $col %= 6; 334eca4a663SGreg Roach echo '</td><td class="person' . $col . '">'; 335eca4a663SGreg Roach if (count($individuals) > 6) { 336eca4a663SGreg Roach // We only have six colours, so show naes if more than this number 33739ca88baSGreg Roach echo $event->record()->fullName() . ' — '; 338eca4a663SGreg Roach } 339eca4a663SGreg Roach $record = $event->record(); 340eca4a663SGreg Roach echo $event->label(); 341eca4a663SGreg Roach echo ' — '; 342eca4a663SGreg Roach if ($record instanceof Individual) { 343eca4a663SGreg Roach echo FunctionsPrint::formatFactDate($event, $record, false, false); 344eca4a663SGreg Roach } elseif ($record instanceof Family) { 345eca4a663SGreg Roach echo $gdate->display(); 346054771e9SGreg Roach 347054771e9SGreg Roach foreach ($record->spouses() as $spouse) { 348054771e9SGreg Roach if ($spouse->getBirthDate()->isOK()) { 349*a5fd6d7cSGreg Roach $age = (string) new Age($spouse->getBirthDate(), $gdate); 350054771e9SGreg Roach if ($spouse->sex() === 'F') { 351*a5fd6d7cSGreg Roach echo '<span class="age"> ', I18N::translate('Wife’s age'), ' ', $age, '</span>'; 352eca4a663SGreg Roach } else { 353*a5fd6d7cSGreg Roach echo '<span class="age"> ', I18N::translate('Husband’s age'), ' ', $age, '</span>'; 354eca4a663SGreg Roach } 355eca4a663SGreg Roach } 356eca4a663SGreg Roach } 357eca4a663SGreg Roach } 358eca4a663SGreg Roach echo ' ' . e($desc); 35929e68993SGreg Roach if ($event->place()->gedcomName() !== '') { 360392561bbSGreg Roach echo ' — ' . $event->place()->shortName(); 361eca4a663SGreg Roach } 362eca4a663SGreg Roach // Print spouses names for family events 363eca4a663SGreg Roach if ($event->record() instanceof Family) { 36439ca88baSGreg Roach echo ' — <a href="', e($event->record()->url()), '">', $event->record()->fullName(), '</a>'; 365eca4a663SGreg Roach } 366eca4a663SGreg Roach echo '</td></tr></table>'; 367eca4a663SGreg Roach echo '</div>'; 368eca4a663SGreg Roach if (I18N::direction() === 'ltr') { 369e837ff07SGreg Roach $img = asset('css/images/dline2.png'); 370eca4a663SGreg Roach $ypos = '0%'; 371eca4a663SGreg Roach } else { 372e837ff07SGreg Roach $img = asset('css/images/dline.png'); 373eca4a663SGreg Roach $ypos = '100%'; 374eca4a663SGreg Roach } 375eca4a663SGreg Roach $dyoffset = ($yoffset - $tyoffset) + $bheight / 3; 376eca4a663SGreg Roach if ($tyoffset < 0) { 377eca4a663SGreg Roach $dyoffset = $yoffset + $bheight / 3; 378eca4a663SGreg Roach if (I18N::direction() === 'ltr') { 379e837ff07SGreg Roach $img = asset('css/images/dline.png'); 380eca4a663SGreg Roach $ypos = '100%'; 381eca4a663SGreg Roach } else { 382e837ff07SGreg Roach $img = asset('css/images/dline2.png'); 383eca4a663SGreg Roach $ypos = '0%'; 384eca4a663SGreg Roach } 385eca4a663SGreg Roach } 386eca4a663SGreg Roach ?> 387eca4a663SGreg Roach 388eca4a663SGreg Roach <!-- diagonal line --> 389e837ff07SGreg Roach <div id="dbox<?= $factcount ?>" style="position:absolute; <?= (I18N::direction() === 'ltr' ? 'left: ' . (0 + 25) : 'right: ' . (0 + 25)) ?>px; top:<?= ($dyoffset) ?>px; font-size: 8pt; height: <?= abs($tyoffset) ?>px; width: <?= abs($tyoffset) ?>px; background-image: url('<?= e($img) ?>'); background-position: 0% <?= $ypos ?>;"> 390eca4a663SGreg Roach </div> 391eca4a663SGreg Roach <?php endforeach ?> 392eca4a663SGreg Roach 393eca4a663SGreg Roach <!-- age cursors --> 394eca4a663SGreg Roach <?php foreach ($individuals as $p => $indi) : ?> 395eca4a663SGreg Roach <?php $ageyoffset = 0 + ($bheight * $p); ?> 396eca4a663SGreg Roach <div id="agebox<?= $p ?>" style="cursor:move; position:absolute; <?= I18N::direction() === 'ltr' ? 'left:20px;' : 'right:20px;' ?> top:<?= $ageyoffset ?>px; height:<?= $bheight ?>px; display:none;" onmousedown="ageCursorMouseDown(this, <?= $p ?>);"> 397eca4a663SGreg Roach <table cellspacing="0" cellpadding="0"> 398eca4a663SGreg Roach <tr> 399eca4a663SGreg Roach <td> 400f220ef57SGreg Roach <img src="<?= e(asset('css/images/hline.png')) ?>" id="ageline<?= $p ?>" width="25" height="3"> 401eca4a663SGreg Roach </td> 402eca4a663SGreg Roach <td> 403eca4a663SGreg Roach <?php if (!empty($birthyears[$indi->xref()])) : ?> 404eca4a663SGreg Roach <?php $tyear = round(($ageyoffset + ($bheight / 2)) / $scale) + $baseyear; ?> 405ca8f62c9SGreg Roach <table class="person<?= $p % 6 ?>" style="cursor: grab;"> 406eca4a663SGreg Roach <tr> 407eca4a663SGreg Roach <td> 408eca4a663SGreg Roach <?= I18N::translate('Year:') ?> 409eca4a663SGreg Roach <span id="yearform<?= $p ?>" class="field"> 410eca4a663SGreg Roach <?= $tyear ?> 411eca4a663SGreg Roach </span> 412eca4a663SGreg Roach </td> 413eca4a663SGreg Roach <td> 4142cebb4b4SGreg Roach (<?= I18N::translate('Age') ?> 4152cebb4b4SGreg Roach <span id="ageform<?= $p ?>" class="field"><?= $tyear - $birthyears[$indi->xref()] ?></span>) 416eca4a663SGreg Roach </td> 417eca4a663SGreg Roach </tr> 418eca4a663SGreg Roach </table> 419eca4a663SGreg Roach <?php endif ?> 420eca4a663SGreg Roach </td> 421eca4a663SGreg Roach </tr> 422eca4a663SGreg Roach </table> 423eca4a663SGreg Roach <br> 424eca4a663SGreg Roach <br> 425eca4a663SGreg Roach <br> 426eca4a663SGreg Roach </div> 427eca4a663SGreg Roach <br> 428eca4a663SGreg Roach <br> 429eca4a663SGreg Roach <br> 430eca4a663SGreg Roach <br> 431eca4a663SGreg Roach <?php endforeach ?> 432eca4a663SGreg Roach</div> 433