import {Application} from 'backbone.marionette'
import {history} from 'backbone'
import $ from 'jquery'

// CSS
import '../node_modules/bootstrap/dist/css/bootstrap.css';
import '../node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.standalone.css'
import '../assets/css/application.scss'
import '../assets/css/playlists.scss';

// Modules & overrides
import '../node_modules/moment/locale/de'
import 'bootstrap-datepicker'
import './overrides/marionette.stickit'
import './overrides/marionette.js'
import './overrides/underscore'

// Controller
import playlistsController from './modules/playlists/controller'
import breadcrumbController from './modules/breadcrumb/controller'
import overviewController from './modules/activities/controller'
import videosController from './modules/videos/controller'
import youtubeController from './modules/youtube/controller'

// Router
import './modules/playlists/router'
import './modules/activities/router'
import './modules/videos/router'
import './modules/navigation/controller'

// Views
import NavigationView from './modules/navigation/views/Navigation'

class App extends Application {

    get regions() {
        return {
            main: '#region-main',
            breadcrumb: '#region-breadcrumb',
            navigation: '#region-navigation',
            adBlock: '#region-adblock'
        }
    }

    initialize() {
        this.listenTo(this, 'start', this._onStart);
    }

    navigate(route, options = { trigger: true }) {
        route = route || history.getFragment() || 'overview';

        history.navigate(route, options);
    }

    _onStart() {
        youtubeController.init();
        breadcrumbController.init(this.getRegion('breadcrumb'));
        playlistsController.init(this.getRegion('main'));
        overviewController.init(this.getRegion('main'));
        videosController.init(this.getRegion('main'));
        
        this._initNavigation();
        this._detectAdBlock();

        history.start();

        this.navigate();

        $(window).on('resize.app', (e) => {
            this.channel.trigger('resize', e);
        });
    }

    _initNavigation() {
        this.getRegion('navigation').show(new NavigationView());
    }

    _detectAdBlock() {
        fuckAdBlock.on(true, () => {
            // detected
            this.getRegion('adBlock').$el.show();
        });
        fuckAdBlock.check();
    }
}

const app = new App();

export default app;
@@ -1885,24 +1885,16 @@
 ain'));%0A
-        
 %0A       
@@ -2227,24 +2227,171 @@
 AdBlock() %7B%0A
+        // Workaround: fuckadblock is not working in ffx -%3E disable%0A        if(navigator.userAgent.toLowerCase().indexOf('firefox') %3E -1) return;%0A%0A
         fuck
@@ -2411,24 +2411,24 @@
 ue, () =%3E %7B%0A
-
             
@@ -2485,24 +2485,24 @@
 $el.show();%0A
+
         %7D);%0A
@@ -2505,37 +2505,8 @@
 %7D);%0A
-        fuckAdBlock.check();%0A
     

Disable fuckadblock for ffx