new GedCom( file [, options] )
GedCom class parsing a gedcom file and create individuals and families.
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file |
string|Object|GedCom.Create | Path of parsed GEDCOM file, content of GEDCOM file or content as a specific Object, create a new GEDCOM when argument is GedCom.Create
Properties
|
|||||||||||||||||||||||||||||||||
options |
Object|DoneCallback |
<optional> |
Overridden options or Success callback function
Properties
|
- Version:
-
- 1.4.30
- Copyright:
-
- Dávid Imre 2016. See full of rights.
Examples:
new GedCom(GedCom.Create, {
start: function(){
//Started
},
done: function(){
//Done
}
});
new GedCom(<filepath>, {
start: function(){
//Started
},
done: function(){
//Done
}
});
new GedCom({
name: <filename>,
content: <content>
}, {
start: function(){
//Started
},
done: function(){
//Done
}
});
new GedCom(<content>, {
start: function(){
//Started
},
done: function(){
//Done
}
});
Members
-
(private) content :Object|Array
-
Content of GedCom file.
Type:
- Object|Array
-
doneCallback :DoneCallback
-
Success callback executed if parsing is completed.
Type:
-
errorCallback :ErrorCallback
-
Error callback executed if parsing is not completed.
Type:
-
(private) fams :Object
-
GedCom families.
Type:
- Object
-
(private) file :string
-
Path of GedCom file
Type:
- string
-
(private) generationLevels :Object
-
Generation levels of GedCom.
Type:
- Object
-
(private) generations :Object
-
GedCom generations.
Type:
- Object
-
(private) header :Object
-
GedCom header.
Type:
- Object
-
(private) indis :Object
-
GedCom individuals.
Type:
- Object
-
(private) openedData :Object
-
Helper Object to store lines while parser is running.
Type:
- Object
-
(private) parserData :Object
-
Currently parsing data while parser is running.
Type:
- Object
-
(private) preLoadedFiles :Array
-
Required files to load before GedCom Parser is initialized.
Type:
- Array
-
progressCallback :ProgressCallback
-
Progress callback executed while parsing.
Type:
-
(private) requiredFiles :Array
-
Required files to GedCom Parser functionality.
Type:
- Array
-
(readonly) responseCodes :string
-
Possible response codes of GedCom#loadFile.
Type:
- string
Properties:
Name Type Default Description Loaded
string 200 Created
string 201 Local
string 202 -
startCallback :StartCallback
-
Start callback executed if parsing is started.
Type:
-
(private) use :Object.<boolean>
-
Used tools set.
Type:
- Object.<boolean>
-
(private) version :string
-
GedCom Parser Version
Type:
- string
Methods
-
(private) addFam( famData ) → {boolean}
-
Parameters:
Name Type Description famData
Array Family line data contains level, type of Data and value Returns:
-
{boolean} type - True if family line is parsed, false if not
-
-
(private) addHead( headData ) → {boolean}
-
Parameters:
Name Type Description headData
Array Header line data contains level, type of Data and value Returns:
-
{boolean} type - True if header line is parsed, false if not
-
-
(private) addIndi( indiData ) → {boolean}
-
Adds an individual data.
Parameters:
Name Type Description indiData
Array Individual line data contains level, type of Data and value Returns:
-
{boolean} type - True if individual line is parsed, false if not
-
-
(private) addIndiOrFam( data , type ) → {boolean}
-
Parameters:
Name Type Description data
Array Line data contains level, type of Data and value type
string Type of line Returns:
-
{boolean} type - True if line is pared, false if not
-
-
(private) allow( ) → {GedCom}
-
Turns on a used tool.
Parameters:
Type Description string Tool name Returns:
-
{GedCom} - Self instance
-
-
(private) clearDebugger( )
-
Clears console methods if running is silent.
-
(private) closeLine( )
-
Closes the opened line.
-
(private) create( ) → {GedCom}
-
Creates full of parser class.
Returns:
-
{GedCom} - Self instance
-
-
(private) disallow( ) → {GedCom}
-
Turns off a used tool.
Parameters:
Type Description string Tool name Returns:
-
{GedCom} - Self instance
-
-
(private) getBinding( args ) → {Array}
-
Get the arguments of a method.
Parameters:
Name Type Description args
Arguments Arguments of the method Returns:
-
{Array} - Binded arguments
-
-
(private) getErrorMessage( [type] ) → {mixed}
-
Get error message by type.
Parameters:
Name Type Argument Description type
string <optional>
Type of error Returns:
-
{mixed} - The error message
-
-
getFamilies( id )
-
Get the families.
Parameters:
Name Type Description id
FamList FamList instance -
getFams( )
-
Synonym of GedCom#getFamilies.
-
(private) getGenerations( ) → {Object}
-
Get generation levels of GedCom.
Returns:
-
{Object} - Generation levels
-
-
getHeader( )
-
Get the Header.
Parameters:
Type Description Header Header instance -
getHomeIndividual( )
-
Get the home individual.
Parameters:
Type Description Indi First individual of the GedCom -
getIndis( )
-
Synonym of GedCom#getIndividuals.
-
getIndividuals( id )
-
Get the individuals.
Parameters:
Name Type Description id
IndiList IndiList instance -
getRelation( )
-
Get the Relation.
Parameters:
Type Description Relation Relation instance -
init( file ) → {GedCom}
-
Initializes GedCom parser.
Parameters:
Name Type Description file
string|Object|GedCom.Create Path of parsed GEDCOM file, content of GEDCOM file or content as a specific Object, create a new GEDCOM when argument is GedCom.Create Properties
Name Type Argument Description name
string <optional>
GedCom file name content
string <optional>
GedCom file content Returns:
-
{GedCom} - Self instance
-
-
isGedComContent( content ) → {boolean}
-
Check the content is GedCom strucure.
Parameters:
Name Type Description content
string The content Returns:
-
{boolean} - When true, the content is GedCom structure, false otherwise
-
-
isGenerationStarted( ) → {Boolean}
-
Check the creating of generation levels is started.
Returns:
-
{Boolean} - True if creating of generation levels is started, false if not
-
-
isParsed( ) → {Boolean}
-
Check the parsing is completed.
Returns:
-
{Boolean} - True if parsing is completed, false if not
-
-
(private) loadCommon( doneCallback , errorCallback ) → {GedCom}
-
Loads the common functions.
Parameters:
Name Type Description doneCallback
function Success callback errorCallback
function Error callback Returns:
-
{GedCom} - Self instance
-
-
(private) loadFile( file ) → {Number}
-
Loads the GedCom file.
Parameters:
Name Type Description file
string|Object Path of parsed GEDCOM file, content of GEDCOM file or content as a specific Object, create a new GEDCOM when argument is GedCom.Create Properties
Name Type Argument Description name
string <optional>
GedCom file name content
string <optional>
GedCom file content Returns:
-
{Number} - Response code
-
-
(private) loadRequiredFiles( doneCallback , errorCallback ) → {boolean}
-
Loads required files.
Parameters:
Name Type Description doneCallback
function Success callback errorCallback
function Error callback Returns:
-
{boolean} - True if all files are required, false if not
-
-
(private) openLine( lineData , type )
-
Opens a line.
Parameters:
Name Type Description lineData
Array Line data contains level, type of Data and value type
string Type of line -
(private) parseContent( doneCallback , readDoneCallback , errorCallback )
-
Parses file content asynchronously.
Parameters:
Name Type Description doneCallback
function Callback if parsing is completed readDoneCallback
function Callback if reading from LocalStorage is completed errorCallback
function Callback if parsing is not completed -
(private) parseLine( line ) → {boolean}
-
Parses a line.
Parameters:
Name Type Description line
string Line Returns:
-
{boolean} - True if line is parsed, false if not
-
-
(private) readLocalStorage( name ) → {mixed}
-
Read the parsed datas from LocalStorage.
Parameters:
Name Type Description name
string Item name Returns:
-
{mixed} - Item
-
-
(private) setGenerationRelativesOf( homeIndi )
-
Set home individual of GedCom.
Parameters:
Name Type Description homeIndi
Indi Home individual -
(private) setGenerations( generation )
-
Set generation levels of GedCom by all individuals.
Parameters:
Name Type Description generation
string|Number Generation level -
(private) setUsing( using , value ) → {GedCom}
-
Set used tools set.
Parameters:
Name Type Description using
string Tool name value
boolen When true, the tool will be turned on, when false, the tool will be turned off Returns:
-
{GedCom} - Self instance
-
-
toGedCom( ) → {string}
-
Returns:
-
{string} - GEDCOM structure string
Example:
new GedCom(<filepath>, { start: function(){ //Started }, done: function(){ //Done } });
-
-
(private) writeLocalStorage( name , obj )
-
Writes the parsed datas to LocalStorage.
Parameters:
Name Type Description name
string Item name obj
mixed Item value
Type Definitions
-
Create
-
Creation option for constructor.
Type:
- string