Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions collections/wikitree.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,37 @@ function parseWikiTree(htmlstring, familymembers, relation) {
return profiledata;
}

function parseWikiEvent(vitalstring) {
var data = [];
var vitalinfo = vitalstring.trim().replace("[location unknown]", "").replace("[date unknown]", "");
var datesplit = vitalinfo.split(" in ");
if (datesplit.length > 0) {
var dateval = datesplit[0].trim();
dateval = cleanDate(dateval);
if (dateval !== "") {
data.push({date: dateval});
}
if (datesplit.length > 1) {
var eventlocation = datesplit[1].trim();
if (eventlocation !== "") {
data.push({id: geoid, location: eventlocation});
geoid++;
}
}
function parseWikiEvent(eventString) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically - split into [... (at ... - optional) ... in ...]

// Return empty array if input is invalid
if (!eventString || typeof eventString !== 'string') {
return [];
}

const eventData = [];

// Clean and normalize the input string
const cleanedString = eventString
.trim()
.replace("[location unknown]", "")
.replace("[date unknown]", "");

// Split into date and location parts
const [datePart, ...locationParts] = cleanedString.split(/\s+in\s+/);

// Parse date if present
const cleanedDate = cleanDate(datePart.trim());
if (cleanedDate) {
// Split date into date and (" at age 100") parts
[cleanDatePart, ...otherCleanParts] = cleanedDate.split(/\s+at\s+/);
eventData.push({ date: cleanDatePart });
}
return data;

if (locationParts) {
eventData.push({
id: geoid++,
location: locationParts[0]
});
}

return eventData;
}