mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-07-30 15:41:47 +00:00
Display photos in details panel (#100)
This commit is contained in:
@@ -118,7 +118,8 @@ function calcDateDifferenceInYears(
|
||||
const startYear = firstDateObject.getUTCFullYear();
|
||||
|
||||
let yearDiff = secondDateObject.getUTCFullYear() - startYear;
|
||||
let monthDiff = secondDateObject.getUTCMonth() - firstDateObject.getUTCMonth();
|
||||
let monthDiff =
|
||||
secondDateObject.getUTCMonth() - firstDateObject.getUTCMonth();
|
||||
if (monthDiff < 0) {
|
||||
yearDiff--;
|
||||
monthDiff += 12;
|
||||
|
||||
@@ -192,10 +192,10 @@ export function normalizeGedcom(gedcom: JsonGedcomData): JsonGedcomData {
|
||||
return sortSpouses(sortChildren(gedcom));
|
||||
}
|
||||
|
||||
const IMAGE_EXTENSIONS = ['.jpg', '.png', '.gif'];
|
||||
const IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif'];
|
||||
|
||||
/** Returns true if the given file name has a known image extension. */
|
||||
function isImageFile(fileName: string): boolean {
|
||||
export function isImageFile(fileName: string): boolean {
|
||||
const lowerName = fileName.toLowerCase();
|
||||
return IMAGE_EXTENSIONS.some((ext) => lowerName.endsWith(ext));
|
||||
}
|
||||
@@ -282,3 +282,12 @@ export function getName(person: GedcomEntry): string | undefined {
|
||||
const name = notMarriedName || names[0];
|
||||
return name?.data.replace(/\//g, '');
|
||||
}
|
||||
|
||||
export function getFileName(fileEntry: GedcomEntry): string | undefined {
|
||||
const fileTitle = fileEntry?.tree.find((entry) => entry.tag === 'TITL')?.data;
|
||||
|
||||
const fileExtension = fileEntry?.tree.find((entry) => entry.tag === 'FORM')
|
||||
?.data;
|
||||
|
||||
return fileTitle && fileExtension && fileTitle + '.' + fileExtension;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user