示例#1
0
function getFact(data, type, dateFunc, placeFunc){
  var date = dateFunc(data),
      place = placeFunc(data),
      fact;
  if(date === '-'){
    date = undefined;
  }
  if(place === '-'){
    place = undefined;
  }
  if(date || place){
    fact = GedcomX.Fact({
      type: type
    });
    if(date){
      fact.setDate({
        original: date
      });
    }
    if(place){
      fact.setPlace({
        original: place
      });
    }
    return fact;
  }
}
示例#2
0
 facts.forEach(function(factInfo){
   
   var row = factInfo.row,
       label = factInfo.label,
       dateCell = row.children[1],
       placeCell = row.children[2];
   
   switch(label){
     
     case 'Name':
       primaryPerson.addSimpleName(dateCell.textContent.trim());
       break;
       
     case 'Gender':
       switch(dateCell.textContent.trim()){
         case 'Male':
           primaryPerson.setGender({
             type: 'http://gedcomx.org/Male'
           });
           break;
         case 'Female':
           primaryPerson.setGender({
             type: 'http://gedcomx.org/Female'
           });
           break;
       }
       break;
     
     // Most facts will have a date and a place
     default:
       if(row.children.length === 3){
         var type = factTypes[label],
             date = dateCell.textContent,
             place = utils.maybe(placeCell.querySelector('span.wr-infotable-place')).textContent,
             value = utils.maybe(placeCell.querySelector('span.wr-infotable-desc')).textContent;
         if(type){
           var fact = GedcomX.Fact({
             type: type
           });
           if(date){
             fact.setDate({
               original: date
             });
           }
           if(place){
             fact.setPlace({
               original: place
             });
           }
           if(value){
             fact.setValue(value);
           }
           primaryPerson.addFact(fact);
         }
       }
   }
   
 });
示例#3
0
function getHouseholdPerson(data){
  var person = GedcomX.Person({
    id: getRecordId(data['']),
    identifiers: {
      'genscrape': getRecordIdentifier(data[''])
    }
  });
  person.addNameFromParts({
    'http://gedcomx.org/Given': data['first name(s)'],
    'http://gedcomx.org/Surname': data['last name']
  });
  person.setGender(getGender(data['sex'] || data['gender']));
  if(data['birth year'] || data['birth place']){
    var birth = GedcomX.Fact({
      type: 'http://gedcomx.org/Birth'
    });
    if(data['birth year']){
      birth.setDate({
        original: data['birth year']
      });
    }
    if(data['birth place']){
      birth.setPlace({
        original: data['birth place']
      });
    }
  }
  if(data['occupation']){
    person.addFact({
      type: 'http://gedcomx.org/Occupation',
      value: data['occupation']
    });
  }
  if(data['marital status']){
    person.addFact({
      type: 'http://gedcomx.org/MaritalStatus',
      value: data['marital status']
    });
  }
  return person;
}