<commit_before>var _gaq = _gaq || []; // global task queue for Google Analytics

define( [
            'dojo/_base/lang',
            'dojo/topic',
            'dojo/aspect',
            'dojo/_base/array',
            'dijit/layout/ContentPane',
            'dijit/layout/BorderContainer',
            'dijit/Dialog',
            'dijit/form/ComboBox',
            'dijit/form/Button',
            'dijit/form/Select',
            'JBrowse/Util',
            'JBrowse/Store/LazyTrie',
            'JBrowse/Store/Autocomplete',
            'JBrowse/GenomeView',
            'JBrowse/TouchScreenSupport',
            'JBrowse/ConfigManager',
            'JBrowse/View/InfoDialog'
        ],
        function(
            lang,
            topic,
            aspect,
            array,
            dijitContentPane,
            dijitBorderContainer,
            dijitDialog,
            dijitComboBox,
            dijitButton,
            dijitSelectBox,
            Util,
            LazyTrie,
            AutocompleteStore,
            GenomeView,
            Touch,
            ConfigManager,
            InfoDialog
        ) {

var dojof = Util.dojof;

/**
 * Construct a new Browser object.
 * @class This class is the main interface between JBrowse and embedders
 * @constructor
 * @param params an object with the following properties:<br>
 * <ul>
 * <li><code>config</code> - list of objects with "url" property that points to a config JSON file</li>
 * <li><code>containerID</code> - ID of the HTML element that contains the browser</li>
 * <li><code>refSeqs</code> - object with "url" property that is the URL to list of reference sequence information items</li>
 * <li><code>browserRoot</code> - (optional) URL prefix for the browser code</li>
 * <li><code>tracks</code> - (optional) comma-delimited string containing initial list of tracks to view</li>
 * <li><code>location</code> - (optional) string describing the initial location</li>
 * <li><code>defaultTracks</code> - (optional) comma-delimited string containing initial list of tracks to view if there are no cookies and no "tracks" parameter</li>
 * <li><code>defaultLocation</code> - (optional) string describing the initial location if there are no cookies and no "location" parameter</li>
 * <li><code>show_nav</code> - (optional) string describing the on/off state of navigation box</li>
 * <li><code>show_tracklist</code> - (optional) string describing the on/off state of track bar</li>
 * <li><code>show_overview</code> - (optional) string describing the on/off state of overview</li>
 * </ul>
 */

var Browser = function(params) {
    this.deferredFunctions = [];
    this.globalKeyboardShortcuts = {};
    this.isInitialized = false;

    this.config = params;
    if( ! this.config.baseUrl )
        this.config.baseUrl = Util.resolveUrl( window.location.href, '.' ) + '/data/';

    this.startTime = Date.now();

    this.container = dojo.byId(this.config.containerID);
    this.container.onselectstart = function() { return false; };
    this.container.genomeBrowser = this;

    // init our touch device support
    this.addDeferred( Touch.loadTouch );

    // schedule the config load, the first step in the initialization
    // process, to happen when the page is done loading
    dojo.addOnLoad( dojo.hitch( this,'loadConfig' ) );

    dojo.connect( this, 'onConfigLoaded',  Util.debugHandler( this, 'loadUserCSS' ));
    dojo.connect( this, 'onConfigLoaded',  Util.debugHandler( this, 'loadRefSeqs' ));
    dojo.connect( this, 'onConfigLoaded',  Util.debugHandler( this, 'loadNames'   ));
    dojo.connect( this, 'onRefSeqsLoaded', Util.debugHandler( this, 'initView'    ));
    dojo.connect( this, 'onRefSeqsLoaded', Util.debugHandler( this, 'reportUsageStats' ));
    dojo.connect( this, 'onRefSeqsLoaded', Util.debugHandler( this, 'initPlugins' ));
};

Browser.prototype.version = function() {
    var BUILD_SYSTEM_JBROWSE_VERSION;
    return BUILD_SYSTEM_JBROWSE_VERSION || 'development';
}.call();

/**
 * Load and instantiate any plugins defined in the configuration.
 */
Browser.prototype.initPlugins = function() {
    var plugins = this.config.plugins;

    // coerce plugins to array of objects
    plugins = array.map( dojo.isArray(plugins) ? plugins : [plugins], function( p ) {
        return typeof p == 'object' ? p : { 'name': p };
    });

    var pluginNames = array.map( plugins, function( p ) {
        return p.name;
    });

    this.plugins = [];

    require( {
                 packages: array.map( pluginNames, function(c) { return { name: c, location: "../plugins/"+c+"/js" }; })
             },
             pluginNames,
             dojo.hitch( this, function() {
                             array.forEach( arguments, function( pluginClass, i ) {

                                                // instantiate the plugin
                                                var plugin = new pluginClass(
                                                    dojo.mixin( dojo.clone( plugins[i] ), { browser: this } )
                                                );
                                                this.plugins.push( plugin );

                                                // load its css<commit_msg>fix JBrowse plugin loader breaking if no plugins are desired<commit_after>var _gaq = _gaq || []; // global task queue for Google Analytics

define( [
            'dojo/_base/lang',
            'dojo/topic',
            'dojo/aspect',
            'dojo/_base/array',
            'dijit/layout/ContentPane',
            'dijit/layout/BorderContainer',
            'dijit/Dialog',
            'dijit/form/ComboBox',
            'dijit/form/Button',
            'dijit/form/Select',
            'JBrowse/Util',
            'JBrowse/Store/LazyTrie',
            'JBrowse/Store/Autocomplete',
            'JBrowse/GenomeView',
            'JBrowse/TouchScreenSupport',
            'JBrowse/ConfigManager',
            'JBrowse/View/InfoDialog'
        ],
        function(
            lang,
            topic,
            aspect,
            array,
            dijitContentPane,
            dijitBorderContainer,
            dijitDialog,
            dijitComboBox,
            dijitButton,
            dijitSelectBox,
            Util,
            LazyTrie,
            AutocompleteStore,
            GenomeView,
            Touch,
            ConfigManager,
            InfoDialog
        ) {

var dojof = Util.dojof;

/**
 * Construct a new Browser object.
 * @class This class is the main interface between JBrowse and embedders
 * @constructor
 * @param params an object with the following properties:<br>
 * <ul>
 * <li><code>config</code> - list of objects with "url" property that points to a config JSON file</li>
 * <li><code>containerID</code> - ID of the HTML element that contains the browser</li>
 * <li><code>refSeqs</code> - object with "url" property that is the URL to list of reference sequence information items</li>
 * <li><code>browserRoot</code> - (optional) URL prefix for the browser code</li>
 * <li><code>tracks</code> - (optional) comma-delimited string containing initial list of tracks to view</li>
 * <li><code>location</code> - (optional) string describing the initial location</li>
 * <li><code>defaultTracks</code> - (optional) comma-delimited string containing initial list of tracks to view if there are no cookies and no "tracks" parameter</li>
 * <li><code>defaultLocation</code> - (optional) string describing the initial location if there are no cookies and no "location" parameter</li>
 * <li><code>show_nav</code> - (optional) string describing the on/off state of navigation box</li>
 * <li><code>show_tracklist</code> - (optional) string describing the on/off state of track bar</li>
 * <li><code>show_overview</code> - (optional) string describing the on/off state of overview</li>
 * </ul>
 */

var Browser = function(params) {
    this.deferredFunctions = [];
    this.globalKeyboardShortcuts = {};
    this.isInitialized = false;

    this.config = params;
    if( ! this.config.baseUrl )
        this.config.baseUrl = Util.resolveUrl( window.location.href, '.' ) + '/data/';

    this.startTime = Date.now();

    this.container = dojo.byId(this.config.containerID);
    this.container.onselectstart = function() { return false; };
    this.container.genomeBrowser = this;

    // init our touch device support
    this.addDeferred( Touch.loadTouch );

    // schedule the config load, the first step in the initialization
    // process, to happen when the page is done loading
    dojo.addOnLoad( dojo.hitch( this,'loadConfig' ) );

    dojo.connect( this, 'onConfigLoaded',  Util.debugHandler( this, 'loadUserCSS' ));
    dojo.connect( this, 'onConfigLoaded',  Util.debugHandler( this, 'loadRefSeqs' ));
    dojo.connect( this, 'onConfigLoaded',  Util.debugHandler( this, 'loadNames'   ));
    dojo.connect( this, 'onRefSeqsLoaded', Util.debugHandler( this, 'initView'    ));
    dojo.connect( this, 'onRefSeqsLoaded', Util.debugHandler( this, 'reportUsageStats' ));
    dojo.connect( this, 'onRefSeqsLoaded', Util.debugHandler( this, 'initPlugins' ));
};

Browser.prototype.version = function() {
    var BUILD_SYSTEM_JBROWSE_VERSION;
    return BUILD_SYSTEM_JBROWSE_VERSION || 'development';
}.call();

/**
 * Load and instantiate any plugins defined in the configuration.
 */
Browser.prototype.initPlugins = function() {
    this.plugins = [];

    var plugins = this.config.plugins;

    if( ! plugins )
        return;

    // coerce plugins to array of objects
    plugins = array.map( dojo.isArray(plugins) ? plugins : [plugins], function( p ) {
        return typeof p == 'object' ? p : { 'name': p };
    });

    var pluginNames = array.map( plugins, function( p ) {
        return p.name;
    });

    require( {
                 packages: array.map( pluginNames, function(c) { return { name: c, location: "../plugins/"+c+"/js" }; })
             },
             pluginNames,
             dojo.hitch( this, function() {
                             array.forEach( arguments, function( pluginClass, i ) {

                                                // instantiate the plugin
                                                var plugin = new pluginClass(
                                                    dojo.mixin( dojo.clone( plugins[i] ), { browser: this } )
                                                );
                                                this.plugins.push( plugin );

                                                // load its css
{'fraction_non_alphanumeric': 0.11947657879764839, 'fraction_numerical': 0.0, 'mean_word_length': 2.1710763680096212, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1321487', 'n_tokens_mistral': 2965, 'n_tokens_neox': 2885, 'n_words': 777}