app/static/scripts/globalScripts.js
// builds html elements and assigns css order values to organize visuals
builds html elements and assigns css order values to organize visuals
builds html elements and assigns css order values to organize visuals
function build_tree(selected_person) {
    let person_buffer = []; 
    selected_person.branchLevel = 1;
    selected_person.cardNumber = 1;
    person_buffer.push(selected_person);
    while (person_buffer.length > 0) {
        let person_to_build = person_buffer[0];
        let branch_object = person_to_build.create_branch(person_to_build.branchLevel);
        let their_card = person_to_build.create_card();
        let their_leaf_number = Math.round(person_to_build.cardNumber / 2);
        let their_leaf = branch_object.leaves[their_leaf_number -1];
        their_leaf.appendChild(their_card);
        their_card.style.order = person_to_build.cardNumber;
        for( let sibling of person_to_build.siblings ) {
            let sib_icon = sibling.sibling_icon();
            person_to_build.sibling_div.insertBefore(sib_icon, person_to_build.sibling_div.firstElementChild);
        }
        for( let n = 0; n < person_to_build.parents.length; n++ ) {
            let parent = person_to_build.parents[n];
            parent.branchLevel = person_to_build.branchLevel + 1;
            parent.cardNumber = (person_to_build.cardNumber * 2) - parent.gender;
            person_buffer.push(parent);
        }
        person_buffer.splice(0, 1);
    }
    var branches = document.getElementsByClassName('branch');
    var branch_width = parseInt(branches[0].style.width);
    var tree_width = tree_container.offsetWidth;
    var center_pos = (branch_width - tree_width) / 2;
    tree_container.scrollLeft = center_pos;
    build_paths();
}
function build_tree ( selected_person ) { let person_buffer = [ ] ; selected_person . branchLevel = 1 ; selected_person . cardNumber = 1 ; person_buffer . push ( selected_person ) ; while ( person_buffer . length > 0 ) { let person_to_build = person_buffer [ 0 ] ; let branch_object = person_to_build . create_branch ( person_to_build . branchLevel ) ; let their_card = person_to_build . create_card ( ) ; let their_leaf_number = Math . round ( person_to_build . cardNumber / 2 ) ; let their_leaf = branch_object . leaves [ their_leaf_number - 1 ] ; their_leaf . appendChild ( their_card ) ; their_card . style . order = person_to_build . cardNumber ; for ( let sibling of person_to_build . siblings ) { let sib_icon = sibling . sibling_icon ( ) ; person_to_build . sibling_div . insertBefore ( sib_icon , person_to_build . sibling_div . firstElementChild ) ; } for ( let n = 0 ; n < person_to_build . parents . length ; n ++ ) { let parent = person_to_build . parents [ n ] ; parent . branchLevel = person_to_build . branchLevel + 1 ; parent . cardNumber = ( person_to_build . cardNumber * 2 ) - parent . gender ; person_buffer . push ( parent ) ; } person_buffer . splice ( 0 , 1 ) ; } var branches = document . getElementsByClassName ( 'branch' ) ; var branch_width = parseInt ( branches [ 0 ] . style . width ) ; var tree_width = tree_container . offsetWidth ; var center_pos = ( branch_width - tree_width ) / 2 ; tree_container . scrollLeft = center_pos ; build_paths ( ) ; }
builds html elements and assigns css order values to organize visuals
builds html elements and assigns css order values to organize visuals
// empty buffer // gonna set the branchLevel of the root person outside of the loop // card number locates left to right within branch // put the root person into the buffer to be processed first // use array.length to determine if their are still people in the buffer // choose the person from the buffer // make the card and possibly the branch. append card to branch // theres a leaf present to place them in // divide by 2 and round to get the leaf number/ index // minues one makes up for array index start at zero // loop their siblings and add them to the sibling div //sibling.hasCard = true; //sibling.cardHolder = sib_icon; // loop through their parents and set their branchLevel & cardNumber, and add them to the buffer // use splice (index, num of things to remove) to remove this person from the buffer // should remove 1 item starting at index zero // viewable width of tree // centering on the tree doesn't need to be done on update call? // build paths