JSFiddle - React, Tailwind, and code Playground
by pmamode
HTML
<div class="members-wrapper"></div>
JavaScript
// define family array
var family = [];
// define Person class
var Person = function() {
this.id = 0;
this.firstName = "undefined";
this.firstNameReference = [];
this.middleName = "undefined";
this.middleNameReference = [];
this.lastName = "undefined";
this.lastNameReference = [];
this.firstName2 = "undefined";
this.firstName2Reference = [];
this.middleName2 = "undefined";
this.middleName2Reference = [];
this.last2Name = "undefined";
this.lastName2Reference = [];
this.firstName3 = "undefined";
this.firstName3Reference = [];
this.middleName3 = "undefined";
this.middleName3Reference = [];
this.last2Name = "undefined";
this.lastName2Reference = [];
this.gender = "undefined";
this.genderReference = [];
this.birthDay = 0;
this.birthDayReference = [];
this.birthMonth = 0;
this.birthMonthReference = [];
this.birthYear = 0;
this.birthYearReference = [];
this.birthAddressId = 0;
this.deathDay = 0;
this.deathDayReference = [];
this.deathMonth = 0;
this.deathMonthReference = [];
this.deathYear = 0;
this.deathYearReference = [];
this.deathAddressId = 0;
};
Person.prototype.setPerson = function(obj) {
this.firstName = obj.firstName;
this.firstNameReference = obj.firstNameReference;
return this;
};
Person.prototype.save = function() {
family.push(this);
console.log(
"saving " + this.firstName + " : " + this.firstNameReference
);
// save to database here...
return this;
};
Person.prototype.stringify = function() {
console.log(JSON.stringify(family));
return this;
};
new Person()
.setPerson({
firstName: "Bob",
firstNameReference: [1, "family search", 5]
})
.save()
new Person()
.setPerson({
firstName: "Tammy",
firstNameReference: [5, "ancestry", 8]
})
.save()
.stringify();
// define Address class
var Address = function() {
this.id = 0;
this.address1 = "undefined";
this.address1Reference = [];
this.address2 = "undefined";
...