<commit_before>var ViewPopupUI = (function() {
    var _container = null;
    return {
        _init: function () {
            _container = null;
        },
        container: function (refresh) {
            if (refresh) {
                if (this._container) {
                    this._container.remove();
                }
                this._container = null;
            }
            if (!this._container) {
                var that = this;
                var con = $('<div class="inpage_popup_container inpage_popup_container_ws" id="sell_popup_container"><a class="close"></a><div class="inpage_popup_content"></div></div>');
                con.hide();
                var _on_close = function () {
                    that.cleanup(true);
                    chartUpdated = false;
                    if (TradePage.is_trading_page() || TradePage_Beta.is_trading_page()) {
                        // Re-subscribe the trading page's tick stream which was unsubscribed by popup's chart
                        BinarySocket.send({'ticks_history':$('#underlying').val(),'style':'ticks','end':'latest','count':20,'subscribe':1});
                    }
                };
                con.find('a.close').on('click', function () { _on_close(); } );
                $(document).on('keydown', function(e) {
                     if (e.which === 27) _on_close();
                });
                this._container = con;
            }
            return this._container;
        },
        cleanup: function () {
            this.forget_streams();
            this.forget_chart_streams();
            this.clear_timer();
            this.close_container();
            this._init();
            $(window).off('resize', function(){ViewPopupUI.reposition_confirmation();});
        },
        forget_streams: function() {
            while(window.stream_ids && window.stream_ids.length > 0) {
                var id = window.stream_ids.pop();
                if(id && id.length > 0) {
                    BinarySocket.send({"forget": id});
                }
            }
        },
        forget_chart_streams: function() {
            while(window.chart_stream_ids && window.chart_stream_ids.length > 0) {
                var id = window.chart_stream_ids.pop();
                if(id && id.length > 0) {
                    BinarySocket.send({"forget": id});
                }
            }
        },
        clear_timer: function() {
            if(window.ViewPopupTimerInterval) {
                clearInterval(window.ViewPopupTimerInterval);
                window.ViewPopupTimerInterval = undefined;
            }
        },
        close_container: function () {
            if (this._container) {
                this._container.hide().remove();
                $('.popup_page_overlay').hide().remove();
                this._container = null;
            }
        },
        disable_button: function (button) {
            button.attr('disabled', 'disabled');
            button.fadeTo(0, 0.5);
        },
        enable_button: function (button) {
            button.removeAttr('disabled');
            button.fadeTo(0, 1);
        },
        show_inpage_popup: function (data, containerClass, dragHandle) {
            var that = this;
            var con = this.container(true);
            if(containerClass) {
                con.addClass(containerClass);
            }
            if (data) {
                $('.inpage_popup_content', con).html(data);
            }
            var body = $(document.body);
            con.css('position', 'fixed').css('z-index', get_highest_zindex() + 100);
            body.append(con);
            con.show();
            $(document.body).append($('<div/>', {class: 'popup_page_overlay'}));
            $('.popup_page_overlay').click(function(){con.find('a.close').click();});
            con.draggable({
                stop: function() {
                    that.reposition_confirmation_ondrag();
                },
                handle: dragHandle,
                scroll: false,
            });
            $(dragHandle).disableSelection();<commit_msg>Fix multiple disabled view buttons<commit_after>var ViewPopupUI = (function() {
    var _container = null;
    return {
        _init: function () {
            _container = null;
        },
        container: function (refresh) {
            if (refresh) {
                if (this._container) {
                    this._container.remove();
                }
                this._container = null;
            }
            if (!this._container) {
                var that = this;
                var con = $('<div class="inpage_popup_container inpage_popup_container_ws" id="sell_popup_container"><a class="close"></a><div class="inpage_popup_content"></div></div>');
                con.hide();
                var _on_close = function () {
                    that.cleanup(true);
                    chartUpdated = false;
                    if (TradePage.is_trading_page() || TradePage_Beta.is_trading_page()) {
                        // Re-subscribe the trading page's tick stream which was unsubscribed by popup's chart
                        BinarySocket.send({'ticks_history':$('#underlying').val(),'style':'ticks','end':'latest','count':20,'subscribe':1});
                    }
                };
                con.find('a.close').on('click', function () { _on_close(); } );
                $(document).on('keydown', function(e) {
                     if (e.which === 27) _on_close();
                });
                this._container = con;
            }
            return this._container;
        },
        cleanup: function () {
            this.forget_streams();
            this.forget_chart_streams();
            this.clear_timer();
            this.close_container();
            this._init();
            $(window).off('resize', function(){ViewPopupUI.reposition_confirmation();});
        },
        forget_streams: function() {
            while(window.stream_ids && window.stream_ids.length > 0) {
                var id = window.stream_ids.pop();
                if(id && id.length > 0) {
                    BinarySocket.send({"forget": id});
                }
            }
        },
        forget_chart_streams: function() {
            while(window.chart_stream_ids && window.chart_stream_ids.length > 0) {
                var id = window.chart_stream_ids.pop();
                if(id && id.length > 0) {
                    BinarySocket.send({"forget": id});
                }
            }
        },
        clear_timer: function() {
            if(window.ViewPopupTimerInterval) {
                clearInterval(window.ViewPopupTimerInterval);
                window.ViewPopupTimerInterval = undefined;
            }
        },
        close_container: function () {
            if (this._container) {
                this._container.hide().remove();
                $('.popup_page_overlay').hide().remove();
                this._container = null;
            }
        },
        disable_button: function (button) {
            $('.open_contract_detailsws[disabled]').each(function() {
                ViewPopupUI.enable_button($(this));
            });
            button.attr('disabled', 'disabled');
            button.fadeTo(0, 0.5);
        },
        enable_button: function (button) {
            button.removeAttr('disabled');
            button.fadeTo(0, 1);
        },
        show_inpage_popup: function (data, containerClass, dragHandle) {
            var that = this;
            var con = this.container(true);
            if(containerClass) {
                con.addClass(containerClass);
            }
            if (data) {
                $('.inpage_popup_content', con).html(data);
            }
            var body = $(document.body);
            con.css('position', 'fixed').css('z-index', get_highest_zindex() + 100);
            body.append(con);
            con.show();
            $(document.body).append($('<div/>', {class: 'popup_page_overlay'}));
            $('.popup_page_overlay').click(function(){con.find('a.close').click();});
            con.draggable({
                stop: function() {
                    that.reposition_confirmation_ondrag();
                },
                handle: dragHandle,
                scroll: false,
            });
            $(dragHandle).disableSelection();
{'fraction_non_alphanumeric': 0.13567599761762955, 'fraction_numerical': 0.0040500297796307325, 'mean_word_length': 1.4884410195613516, 'pattern_counts': {'":': 4, '<': 17, '<?xml version=': 0, '>': 25, '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': '4045913', 'n_tokens_mistral': 2232, 'n_tokens_neox': 2119, 'n_words': 347}