-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A requested feature. It checks for the same birth and death date and 'Unknown' or 'Unnamed' in the First Name fields. It then sets the First Name and Preferred Name to 'Unnamed Infant', checks the 'No spouses' and 'No children' boxes, and adds a Died Young sticker.
- Loading branch information
1 parent
9a3cea9
commit d98d8bc
Showing
5 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
Created By: Ian Beacall (Beacall-6) | ||
*/ | ||
import $ from "jquery"; | ||
import { showCopyMessage } from "../access_keys/access_keys"; | ||
import { isProfileEdit, isProfileAddRelative, isAddUnrelatedPerson } from "../../core/pageType"; | ||
import { shouldInitializeFeature, getFeatureOptions } from "../../core/options/options_storage"; | ||
|
||
shouldInitializeFeature("unnamedInfant").then((result) => { | ||
if (result) { | ||
import("./unnamed_infant.css"); | ||
initUnnamedInfant(); | ||
} | ||
}); | ||
|
||
function doUnnamedInfant() { | ||
const firstName = $("#mFirstName").val(); | ||
const birthDate = $("#mBirthDate").val(); | ||
const deathDate = $("#mDeathDate").val(); | ||
const standardName = "Unnamed Infant"; | ||
const diedYoung = "{{Died Young}}"; | ||
const diedYoungWithoutEnd = "{{Died Young"; | ||
|
||
if (firstName.match(/unnamed|unknown/i) && birthDate == deathDate && birthDate != "") { | ||
let message = ""; | ||
if (firstName != standardName) { | ||
$("#mFirstName,#mRealName").val(standardName); | ||
message = "First name changed to 'Unnamed Infant'"; | ||
} | ||
if (isProfileEdit) { | ||
$("input[name='mStatus_Spouse'],input[name='mNoChildren']").each(function () { | ||
if ($(this).prop("checked") == false) { | ||
$(this).trigger("click"); | ||
if ($(this).parent().text().includes("spouses")) { | ||
message += "<br>'No spouses' checked"; | ||
} else { | ||
message += "<br>'No children' checked"; | ||
} | ||
} | ||
}); | ||
|
||
let enhanced = false; | ||
const enhancedEditorButton = $("#toggleMarkupColor"); | ||
if (enhancedEditorButton.attr("value") == "Turn Off Enhanced Editor") { | ||
enhancedEditorButton.trigger("click"); | ||
enhanced = true; | ||
} | ||
const bioBox = $("#wpTextbox1"); | ||
const bio = bioBox.val(); | ||
// Search Biography for Died Young sticker | ||
if (!bio.includes(diedYoungWithoutEnd)) { | ||
// Find /== ?Biography ?==/ and insert Died Young sticker after it. | ||
const bioIndex = bio.search(/== ?Biography ?==/); | ||
if (bioIndex != -1) { | ||
const bioStart = bio.slice(0, bioIndex + 15); | ||
const bioEnd = bio.slice(bioIndex + 15); | ||
bioBox.val(bioStart + "\n" + diedYoung + "\n" + bioEnd); | ||
message += "<br>Died Young sticker added to Biography"; | ||
} | ||
} | ||
if (enhanced) { | ||
enhancedEditorButton.trigger("click"); | ||
} | ||
} | ||
// Show message | ||
if (message != "") { | ||
showCopyMessage(message, true); | ||
} | ||
} | ||
} | ||
|
||
function initUnnamedInfant() { | ||
$("#addNewPersonButton,#dismissMatchesButton,#enterBasicDataButton,#wpSaveDraft,#wpSave").on( | ||
"mouseenter", | ||
function () { | ||
doUnnamedInfant(); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { options } from "yargs"; | ||
import { registerFeature, OptionType } from "../../core/options/options_registry"; | ||
import { isProfileEdit, isProfileAddRelative, isAddUnrelatedPerson } from "../../core/pageType"; | ||
|
||
registerFeature({ | ||
name: "Unnamed Infant", | ||
id: "unnamedInfant", | ||
description: "Standardizes the naming of unnamed infants and adds a Died Young sticker to the profile.", | ||
category: "Editing", | ||
creators: [{ name: "Ian Beacall", wikitreeid: "Beacall-6" }], | ||
contributors: [], | ||
defaultValue: true, | ||
pages: [isProfileEdit, isProfileAddRelative, isAddUnrelatedPerson], | ||
options: [ | ||
{ | ||
id: "diedYoung", | ||
type: OptionType.CHECKBOX, | ||
label: "Add Died Young sticker for people who died aged 16 or younger", | ||
defaultValue: false, | ||
}, | ||
{ | ||
id: "diedYoungImage", | ||
type: OptionType.SELECT, | ||
label: "Died Young sticker image", | ||
values: [ | ||
{ | ||
value: "Default", | ||
text: "Default", | ||
}, | ||
{ | ||
value: "Ribbon", | ||
text: "Ribbon", | ||
}, | ||
{ | ||
value: "Cradle", | ||
text: "Cradle", | ||
}, | ||
{ | ||
value: "Swing", | ||
text: "Swing", | ||
}, | ||
{ | ||
value: "Candle", | ||
text: "Candle", | ||
}, | ||
{ | ||
value: "Babyfeet", | ||
text: "Babyfeet", | ||
}, | ||
{ | ||
value: "Butterfly1", | ||
text: "Butterfly1", | ||
}, | ||
{ | ||
value: "Butterfly2", | ||
text: "Butterfly2", | ||
}, | ||
{ | ||
value: "Marigold", | ||
text: "Marigold", | ||
}, | ||
{ | ||
value: "Bluebirds", | ||
text: "Bluebirds", | ||
}, | ||
{ | ||
value: "Feethands", | ||
text: "Feethands", | ||
}, | ||
{ | ||
value: "Lotusbutterfly", | ||
text: "Lotusbutterfly", | ||
}, | ||
], | ||
defaultValue: "Default", | ||
}, | ||
], | ||
}); |