import { Page }              from "./modules/Page.js";
import { InfiniteScroll }    from "./modules/InfiniteScroll.js";


class Main { 

    constructor() {

        /// get the page properties
        this.page = new Page();

        this.theme_name = 'webnews';

        
        this.infinite = this.page.props.infinite == 'true' ? new InfiniteScroll( 

            this.page.props.contents,
            this.page.props.container,
            this.page.props.content,
            '#wait-loading',              // preloader element
            4                             // max loads
                                     
        ) :  null;
    
    }

    getBaseDir() {

        let firstLevelDomain = window.location.host.replace(/(.*?)\..*/, '$1');

        let dir = [ 'www','staging','preprod','local','new' ].includes( firstLevelDomain ) ? {

            jsdir  : `/app/themes/${this.theme_name}/`,
            cssdir : `/app/themes/${this.theme_name}/`

        } : { 
            
            jsdir  : '/',
            cssdir : '/'
            
        }

        return dir;
    }
}

window.UI = new Main();

console.log( UI );