<commit_before>var MBContract         = require('./mb_contract').MBContract;
var MBDefaults         = require('./mb_defaults').MBDefaults;
var MBNotifications    = require('./mb_notifications').MBNotifications;
var MBPrice            = require('./mb_price').MBPrice;
var MBSymbols          = require('./mb_symbols').MBSymbols;
var MBTick             = require('./mb_tick').MBTick;
var TradingAnalysis    = require('../trade/analysis').TradingAnalysis;
var japanese_client    = require('../../common_functions/country_base').japanese_client;
var displayUnderlyings = require('../trade/common').displayUnderlyings;
var showFormOverlay    = require('../trade/common').showFormOverlay;
var processForgetTicks = require('../trade/process').processForgetTicks;

var MBProcess = (function() {
    var market_status = '',
        symbols_timeout;
    /*
     * This function process the active symbols to get markets
     * and underlying list
     */
    function processActiveSymbols(data) {
        'use strict';

        if (data.hasOwnProperty('error')) {
            MBNotifications.show({ text: data.error.message, uid: 'ACTIVE_SYMBOLS' });
            return;
        }

        // populate the Symbols object
        MBSymbols.details(data);

        var symbols_list = japanese_client() || !page.client.is_logged_in ?
                MBSymbols.underlyings().major_pairs : MBSymbols.getAllSymbols(),
            symbol       = MBDefaults.get('underlying'),
            update_page  = MBSymbols.need_page_update();

        if (update_page && (!symbol || !symbols_list[symbol])) {
            symbol = undefined;
        }
        // check if all symbols are inactive
        var is_market_closed = true;
        Object.keys(symbols_list).forEach(function(s) {
            if (symbols_list[s].is_active) {
                is_market_closed = false;
            }
        });
        clearSymbolTimeout();
        if (is_market_closed) {
            handleMarketClosed();
        } else {
            handleMarketOpen();
            displayUnderlyings('underlying', symbols_list, symbol);

            if (symbol && !symbols_list[symbol].is_active) {
                MBNotifications.show({ text: page.text.localize('This symbol is not active. Please try another symbol.'), uid: 'SYMBOL_INACTIVE' });
            } else if (update_page) {
                MBProcess.processMarketUnderlying();
            }
        }
    }

    function handleMarketClosed() {
        $('.japan-form, .japan-table, #trading_bottom_content').addClass('invisible');
        MBNotifications.show({ text: page.text.localize('Market is closed. Please try again later.'), uid: 'MARKET_CLOSED' });
        symbols_timeout = setTimeout(function() { MBSymbols.getSymbols(1); }, 30000);
    }

    function handleMarketOpen() {
        $('.japan-form, .japan-table, #trading_bottom_content').removeClass('invisible');<commit_msg>Do not process previous underlying if it's not in the list<commit_after>var MBContract         = require('./mb_contract').MBContract;
var MBDefaults         = require('./mb_defaults').MBDefaults;
var MBNotifications    = require('./mb_notifications').MBNotifications;
var MBPrice            = require('./mb_price').MBPrice;
var MBSymbols          = require('./mb_symbols').MBSymbols;
var MBTick             = require('./mb_tick').MBTick;
var TradingAnalysis    = require('../trade/analysis').TradingAnalysis;
var japanese_client    = require('../../common_functions/country_base').japanese_client;
var displayUnderlyings = require('../trade/common').displayUnderlyings;
var showFormOverlay    = require('../trade/common').showFormOverlay;
var processForgetTicks = require('../trade/process').processForgetTicks;

var MBProcess = (function() {
    var market_status = '',
        symbols_timeout;
    /*
     * This function process the active symbols to get markets
     * and underlying list
     */
    function processActiveSymbols(data) {
        'use strict';

        if (data.hasOwnProperty('error')) {
            MBNotifications.show({ text: data.error.message, uid: 'ACTIVE_SYMBOLS' });
            return;
        }

        // populate the Symbols object
        MBSymbols.details(data);

        var symbols_list = japanese_client() || !page.client.is_logged_in ?
                MBSymbols.underlyings().major_pairs : MBSymbols.getAllSymbols(),
            symbol       = MBDefaults.get('underlying'),
            update_page  = MBSymbols.need_page_update();

        if (update_page && (!symbol || !symbols_list[symbol])) {
            symbol = undefined;
            MBDefaults.remove('underlying');
        }
        // check if all symbols are inactive
        var is_market_closed = true;
        Object.keys(symbols_list).forEach(function(s) {
            if (symbols_list[s].is_active) {
                is_market_closed = false;
            }
        });
        clearSymbolTimeout();
        if (is_market_closed) {
            handleMarketClosed();
        } else {
            handleMarketOpen();
            displayUnderlyings('underlying', symbols_list, symbol);

            if (symbol && !symbols_list[symbol].is_active) {
                MBNotifications.show({ text: page.text.localize('This symbol is not active. Please try another symbol.'), uid: 'SYMBOL_INACTIVE' });
            } else if (update_page) {
                MBProcess.processMarketUnderlying();
            }
        }
    }

    function handleMarketClosed() {
        $('.japan-form, .japan-table, #trading_bottom_content').addClass('invisible');
        MBNotifications.show({ text: page.text.localize('Market is closed. Please try again later.'), uid: 'MARKET_CLOSED' });
        symbols_timeout = setTimeout(function() { MBSymbols.getSymbols(1); }, 30000);
    }

    function handleMarketOpen() {
        $('.japan-form, .japan-table, #trading_bottom_content').removeClass('invisible');
{'fraction_non_alphanumeric': 0.1272511043153245, 'fraction_numerical': 0.0020387359836901123, 'mean_word_length': 2.591824283099451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4738629', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1607, 'n_words': 314}