<commit_before>const moment               = require('moment');
const HighchartUI          = require('./charts/highchart.ui');
const requireHighstock     = require('./common').requireHighstock;
const Reset                = require('./reset');
const Tick                 = require('./tick');
const updatePurchaseStatus = require('./update_values').updatePurchaseStatus;
const ViewPopupUI          = require('../user/view_popup/view_popup.ui');
const BinarySocket         = require('../../base/socket');
const ChartSettings        = require('../../common/chart_settings');
const addComma             = require('../../../_common/base/currency_base').addComma;
const CommonFunctions      = require('../../../_common/common_functions');
const localize             = require('../../../_common/localize').localize;

const TickDisplay = (() => {
    let number_of_ticks,
        display_symbol,
        contract_start_ms,
        contract_category,
        should_set_barrier,
        barrier,
        display_decimals,
        show_contract_result,
        price,
        payout,
        ticks_needed,
        x_indicators,
        chart,
        Highcharts,
        applicable_ticks,
        contract_start_moment,
        counter,
        spots_list,
        tick_init,
        subscribe,
        reset_spot_plotted,
        response_id,
        contract,
        selected_tick;

    let id_render = 'tick_chart';

    const winning_color = 'rgba(46, 136, 54, 0.2)';
    const losing_color  = 'rgba(204, 0, 0, 0.1)';

    const color  = 'orange';
    const marker = {
        fillColor: color,
        lineColor: color,
        lineWidth: 3,
        radius   : 4,
        states   : { hover: { fillColor: color, lineColor: color, lineWidth: 3, radius: 4 } },
    };

    const initialize = (data, options) => {
        // setting up globals
        applicable_ticks     = [];
        number_of_ticks      = parseInt(data.number_of_ticks);
        display_symbol       = data.display_symbol;
        contract_start_ms    = parseInt(data.contract_start) * 1000;
        contract_category    = data.contract_category;
        should_set_barrier   = !contract_category.match('digits');
        barrier              = data.barrier;
        display_decimals     = data.display_decimals || 2;
        show_contract_result = data.show_contract_result;
        reset_spot_plotted   = false;

        if (data.id_render) {
            id_render = data.id_render;
        }

        if (data.show_contract_result) {
            price  = parseFloat(data.price);
            payout = parseFloat(data.payout);
        }

        setXIndicators();
        requireHighstock((Highstock) => {
            Highcharts = Highstock;
            const is_small_width     = window.innerWidth < 480;
            const overlay_margin_top = is_small_width ? 70 : 40;
            const overlay_height     = is_small_width ? 200 : 170;
            initializeChart({
                display_decimals,
                data         : [],
                el           : id_render,
                events       : { load: () => { plot(); } },
                margin_top   : show_contract_result ? overlay_margin_top : null,
                has_animation: show_contract_result,
                height       : show_contract_result ? overlay_height : null,
                radius       : 4,
                title        : show_contract_result ? '' : display_symbol,
                tooltip      : {
                    formatter() {
                        const new_y = addComma(this.y.toFixed(display_decimals));
                        const mom   = moment.utc(applicable_ticks[this.x].epoch * 1000).format('dddd, MMM D, HH:mm:ss');
                        return `<div class='tooltip-body'>${mom}<br/>${display_symbol} ${new_y}</div>`;
                    },
                },
                type  : 'line',
                width : data.width ? data.width : (show_contract_result ? 394 : null),
                x_axis: { labels: { enabled: false }, ...(show_contract_result ? { max: number_of_ticks + 1, min: 0, type: 'linear' } : {}) },
            }, options);
        });
    };

    const setXIndicators = () => {
        const exit_tick_index = number_of_ticks - 1;
        if (contract_category.match('asian')) {
            ticks_needed = number_of_ticks;
            x_indicators = {
                _0: { label: localize('Entry Spot'), id: 'start_tick' },
            };
            x_indicators[`_${exit_tick_index}`] = {
                label    : localize('Exit Spot'),
                id       : 'exit_tick',
                dashStyle: 'Dash',
            };
        } else if (contract_category.match(/callput|reset/i)) {
            ticks_needed = number_of_ticks + 1;
            x_indicators = {
                _0: { label: localize('Entry Spot'), id: 'entry_tick' },
            };
            x_indicators[`_${number_of_ticks}`] = {
                label    : localize('Exit Spot'),
                id       : 'exit_tick',
                dashStyle: 'Dash',
            };
            if (contract_category.match('reset')) {
                const reset_time_index = Math.floor(number_of_ticks / 2); // use index to draw ticks reset_time
                x_indicators[`_${reset_time_index}`] = {
                    index: reset_time_index,
                    label: localize('Reset Time'),
                    id   : 'reset_tick',
                    color: '#000',
                };
            }
        } else if (contract_category.match('touchnotouch')) {
            ticks_needed = number_of_ticks + 1;
            x_indicators = {
                _0: { label: localize('Entry Spot'), id: 'entry_tick' },
            };
        } else if (contract_category.match('digits')) {
            ticks_needed = number_of_ticks;
            x_indicators = {
                _0: { label: localize('Tick [_1]', '1'), id: 'start_tick' },
            };
            x_indicators[`_${exit_tick_index}`] = {
                label    : localize('Tick [_1]', number_of_ticks),
                id       : 'last_tick',
                dashStyle: 'Dash',
            };
        } else if (contract_category.match('highlowticks')) {
            ticks_needed = number_of_ticks;
            x_indicators = {
                _0: { label: localize('Entry Spot'), id: 'start_tick' },
            };
            x_indicators[`_${exit_tick_index}`] = {
                label: localize('Exit Spot'),
                id   : 'exit_tick',
            };
        } else {
            x_indicators = {};
        }
    };

    const initializeChart = (config, data) => {
        const has_reset_barrier = contract.entry_spot && contract.barrier &&
            Reset.isReset(contract_category) && Reset.isNewBarrier(contract.entry_spot, contract.barrier);
        Highcharts.setOptions({
            lang: { thousandsSep: ',' },
        });
        ChartSettings.setChartOptions(config);
        chart = new Highcharts.Chart(ChartSettings.getChartOptions());
        HighchartUI.updateLabels(chart, {
            contract_type   : contract_category,<commit_msg>change hi/lo Exit Spot line to dash<commit_after>const moment               = require('moment');
const HighchartUI          = require('./charts/highchart.ui');
const requireHighstock     = require('./common').requireHighstock;
const Reset                = require('./reset');
const Tick                 = require('./tick');
const updatePurchaseStatus = require('./update_values').updatePurchaseStatus;
const ViewPopupUI          = require('../user/view_popup/view_popup.ui');
const BinarySocket         = require('../../base/socket');
const ChartSettings        = require('../../common/chart_settings');
const addComma             = require('../../../_common/base/currency_base').addComma;
const CommonFunctions      = require('../../../_common/common_functions');
const localize             = require('../../../_common/localize').localize;

const TickDisplay = (() => {
    let number_of_ticks,
        display_symbol,
        contract_start_ms,
        contract_category,
        should_set_barrier,
        barrier,
        display_decimals,
        show_contract_result,
        price,
        payout,
        ticks_needed,
        x_indicators,
        chart,
        Highcharts,
        applicable_ticks,
        contract_start_moment,
        counter,
        spots_list,
        tick_init,
        subscribe,
        reset_spot_plotted,
        response_id,
        contract,
        selected_tick;

    let id_render = 'tick_chart';

    const winning_color = 'rgba(46, 136, 54, 0.2)';
    const losing_color  = 'rgba(204, 0, 0, 0.1)';

    const color  = 'orange';
    const marker = {
        fillColor: color,
        lineColor: color,
        lineWidth: 3,
        radius   : 4,
        states   : { hover: { fillColor: color, lineColor: color, lineWidth: 3, radius: 4 } },
    };

    const initialize = (data, options) => {
        // setting up globals
        applicable_ticks     = [];
        number_of_ticks      = parseInt(data.number_of_ticks);
        display_symbol       = data.display_symbol;
        contract_start_ms    = parseInt(data.contract_start) * 1000;
        contract_category    = data.contract_category;
        should_set_barrier   = !contract_category.match('digits');
        barrier              = data.barrier;
        display_decimals     = data.display_decimals || 2;
        show_contract_result = data.show_contract_result;
        reset_spot_plotted   = false;

        if (data.id_render) {
            id_render = data.id_render;
        }

        if (data.show_contract_result) {
            price  = parseFloat(data.price);
            payout = parseFloat(data.payout);
        }

        setXIndicators();
        requireHighstock((Highstock) => {
            Highcharts = Highstock;
            const is_small_width     = window.innerWidth < 480;
            const overlay_margin_top = is_small_width ? 70 : 40;
            const overlay_height     = is_small_width ? 200 : 170;
            initializeChart({
                display_decimals,
                data         : [],
                el           : id_render,
                events       : { load: () => { plot(); } },
                margin_top   : show_contract_result ? overlay_margin_top : null,
                has_animation: show_contract_result,
                height       : show_contract_result ? overlay_height : null,
                radius       : 4,
                title        : show_contract_result ? '' : display_symbol,
                tooltip      : {
                    formatter() {
                        const new_y = addComma(this.y.toFixed(display_decimals));
                        const mom   = moment.utc(applicable_ticks[this.x].epoch * 1000).format('dddd, MMM D, HH:mm:ss');
                        return `<div class='tooltip-body'>${mom}<br/>${display_symbol} ${new_y}</div>`;
                    },
                },
                type  : 'line',
                width : data.width ? data.width : (show_contract_result ? 394 : null),
                x_axis: { labels: { enabled: false }, ...(show_contract_result ? { max: number_of_ticks + 1, min: 0, type: 'linear' } : {}) },
            }, options);
        });
    };

    const setXIndicators = () => {
        const exit_tick_index = number_of_ticks - 1;
        if (contract_category.match('asian')) {
            ticks_needed = number_of_ticks;
            x_indicators = {
                _0: { label: localize('Entry Spot'), id: 'start_tick' },
            };
            x_indicators[`_${exit_tick_index}`] = {
                label    : localize('Exit Spot'),
                id       : 'exit_tick',
                dashStyle: 'Dash',
            };
        } else if (contract_category.match(/callput|reset/i)) {
            ticks_needed = number_of_ticks + 1;
            x_indicators = {
                _0: { label: localize('Entry Spot'), id: 'entry_tick' },
            };
            x_indicators[`_${number_of_ticks}`] = {
                label    : localize('Exit Spot'),
                id       : 'exit_tick',
                dashStyle: 'Dash',
            };
            if (contract_category.match('reset')) {
                const reset_time_index = Math.floor(number_of_ticks / 2); // use index to draw ticks reset_time
                x_indicators[`_${reset_time_index}`] = {
                    index: reset_time_index,
                    label: localize('Reset Time'),
                    id   : 'reset_tick',
                    color: '#000',
                };
            }
        } else if (contract_category.match('touchnotouch')) {
            ticks_needed = number_of_ticks + 1;
            x_indicators = {
                _0: { label: localize('Entry Spot'), id: 'entry_tick' },
            };
        } else if (contract_category.match('digits')) {
            ticks_needed = number_of_ticks;
            x_indicators = {
                _0: { label: localize('Tick [_1]', '1'), id: 'start_tick' },
            };
            x_indicators[`_${exit_tick_index}`] = {
                label    : localize('Tick [_1]', number_of_ticks),
                id       : 'last_tick',
                dashStyle: 'Dash',
            };
        } else if (contract_category.match('highlowticks')) {
            ticks_needed = number_of_ticks;
            x_indicators = {
                _0: { label: localize('Entry Spot'), id: 'start_tick' },
            };
            x_indicators[`_${exit_tick_index}`] = {
                label    : localize('Exit Spot'),
                id       : 'exit_tick',
                dashStyle: 'Dash',
            };
        } else {
            x_indicators = {};
        }
    };

    const initializeChart = (config, data) => {
        const has_reset_barrier = contract.entry_spot && contract.barrier &&
            Reset.isReset(contract_category) && Reset.isNewBarrier(contract.entry_spot, contract.barrier);
        Highcharts.setOptions({
            lang: { thousandsSep: ',' },
        });
        ChartSettings.setChartOptions(config);
        chart = new Highcharts.Chart(ChartSettings.getChartOptions());
        HighchartUI.updateLabels(chart, {
            contract_type   : contract_category,
{'fraction_non_alphanumeric': 0.11832621929885942, 'fraction_numerical': 0.008816737807011405, 'mean_word_length': 1.6714018691588786, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '4431364', 'n_tokens_mistral': 4213, 'n_tokens_neox': 3960, 'n_words': 729}