Example #1
0
export default function toggleUL( objName, hrefObj ) {

    const divs = document.getElementsByTagName( "ul" );
    for ( let i = 0; i < divs.length; i++ ) {
        if ( divs[ i ].className === "tree_child_hidden" ) {
            divs[ i ].style.display = "none";
        }
    }

    const dObj = document.getElementById( objName );
    if ( dObj ) {
        if ( dObj.style.display === "block" ) {
            dObj.style.display = "none";
        } else {
            dObj.style.display = "block";
        }
    }

    const hrefs = selector( "span.toplevel" );
    for ( let i = 0; i < hrefs.length; i++ ) {
        css.replaceClass( hrefs.get( i ), "expanded", "collapsed" );
    }
    if ( hrefObj ) {
        css.addClass( hrefObj, "expanded" );
    }
}
function processJSON() {
    const parent = selector( "#fish_tabs" ).get( 0 ),
        container = selector( '#fishdataContentArea' ).get( 0 );

    parent.innerHTML = '';
    let fish = jsonData[ 'tropical_fish' ][ 'fish_data' ];
    for ( let i = 0, len = fish.length; i < len; i += 1 ) {
        const name = fish[ i ][ 'name' ][ '#text' ];
        const data = fish[ i ][ 'comment' ][ '#text' ];
        const option = dom.createElement( 'option', parent );
        option.value = name.toLowerCase().replace( /\ /g, '-' );
        option.text = name;
        const span = dom.createElement( 'span', container, {
            "id": name.toLowerCase().replace( /\ /g, '-' ),
            'innerHTML': data
        } );
        addClass( span, 'selection-tied' );
        if ( i > 0 ) {
            span.style.display = 'none';
        }
    }
    events.addEvent( parent, 'change', onFishTabsChanged );
}
function startFishInfo() {

    if ( !fishInfoWorker ) {
        setupFishInfo();
    }

    if ( fishInfoWorker ) {
        const homeContent = selector( '#welcome-content' ).get( 0 );
        const displayWindow = selector( '.WebWindowArea', homeContent ).get( 0 );

        Array.from( displayWindow.childNodes ).forEach( item => {
            if ( item.nodeName.toLowerCase() === 'div' ) {
                item.style.display = 'none';
            }
        } );

        const animFishContainer = dom.createElement( 'div', displayWindow, {
            id: 'animated-fish'
        } );
        animFishContainer.style.display = 'block';

        fetcher( 'frags/fish-svg.frag' )
            .then( data => {

                animFishContainer.innerHTML = `${message}<br>${data}`;
                const parts = selector( 'ellipse', animFishContainer );

                const mouth = parts[ 0 ].attributes.ry,
                    omouth = parts[ 1 ].attributes.ry;

                fishInfoWorker.onmessage = ( msg ) => {
                    if ( msg && msg.data ) {
                        requestAnimationFrame( () => {
                            mouth.value = msg.data.mouth;
                            omouth.value = msg.data.omouth;
                        } );
                    }
                };
                fishInfoWorker.postMessage( {
                    'start': 'start'
                } );

                if ( perf.hasPerformanceMetrics ) {
                    performance.measure( 'animated fish render' );
                }
            } );

        const mainWindow = document.getElementById( 'main-window' );
        const title = selector( '.WebWindowTitle span', mainWindow ).get( 0 );

        const winArea = selector( '.WebWindowArea', mainWindow ).get( 0 );
        const fishInfoSection = dom.createElement( 'div', winArea, {
            id: 'fins-info-section'
        } );
        fishInfoSection.style.display = 'block';
        addClass( fishInfoSection, 'left-align' );
        fishInfoSection.innerHTML = fishTabs;

        ajax.get( getXMLDocument, '/data/tropical_fish.xml' );
    }
}