<commit_before>/**
 * Copyright 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
 * Please see distribution for license.
 */
$.register_module({
    name: 'og.common.gadgets.Surface',
    dependencies: ['og.common.gadgets.manager'],
    obj: function () {
        var prefix = 'og_surface_gadget_', counter = 1;
        return function (config) {
            var gadget = this, surface, alive = prefix + counter++, $selector = $(config.selector),
                surface_options = {selector: config.selector, options: {}};
            $(config.selector).addClass(alive).css({position: 'absolute', top: 0, left: 0, right: 0, bottom: 0});
            gadget.alive = function () {
                var live = !!$('.' + alive).length;
                if (!live && surface) surface.die(), gadget.dataman.kill();
                return live;
            };
            gadget.resize = function () {try {surface.resize();} catch (error) {}};
            gadget.dataman = new og.analytics
                .Cell({source: config.source, row: config.row, col: config.col, format: 'EXPANDED'}, 'surface')
                .on('data', function (data) {
                    data = data.v || data;
                    if (!data.xValues || !data.yValues)
                        return !surface && $selector.html('bad data: ' + JSON.stringify(data));
                    surface_options.data = {
                        vol: data.vol,
                        xs: data.xValues, xs_labels: data.xLabels, xs_label: data.xTitle,
                        zs: data.yValues, zs_labels: data.yLabels, zs_label: data.yTitle
                    };
                    if (!surface) surface = new JSurface3D(surface_options);
                    else surface.update('surface', surface_options.data);
                })
                .on('fatal', function (message) {$selector.html(message)});
            if (!config.child) og.common.gadgets.manager.register(gadget);
        }
    }
});<commit_msg>fix bug in surface gadget cleanup<commit_after>/**
 * Copyright 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
 * Please see distribution for license.
 */
$.register_module({
    name: 'og.common.gadgets.Surface',
    dependencies: ['og.common.gadgets.manager'],
    obj: function () {
        var prefix = 'og_surface_gadget_', counter = 1;
        return function (config) {
            var gadget = this, surface, alive = prefix + counter++, $selector = $(config.selector),
                surface_options = {selector: config.selector, options: {}};
            $(config.selector).addClass(alive).css({position: 'absolute', top: 0, left: 0, right: 0, bottom: 0});
            gadget.alive = function () {
                var live = !!$('.' + alive).length;
                if (live) return true;
                try {if (surface) surface.die();} catch (error) {}
                try {gadget.dataman.kill();} catch (error) {}
                return false;
            };
            gadget.resize = function () {try {surface.resize();} catch (error) {}};
            gadget.dataman = new og.analytics
                .Cell({source: config.source, row: config.row, col: config.col, format: 'EXPANDED'}, 'surface')
                .on('data', function (data) {
                    data = data.v || data;
                    if (!data.xValues || !data.yValues)
                        return !surface && $selector.html('bad data: ' + JSON.stringify(data));
                    surface_options.data = {
                        vol: data.vol,
                        xs: data.xValues, xs_labels: data.xLabels, xs_label: data.xTitle,
                        zs: data.yValues, zs_labels: data.yLabels, zs_label: data.yTitle
                    };
                    if (!surface) surface = new JSurface3D(surface_options);
                    else surface.update('surface', surface_options.data);
                })
                .on('fatal', function (message) {$selector.html(message)});
            if (!config.child) og.common.gadgets.manager.register(gadget);
        }
    }
});
{'fraction_non_alphanumeric': 0.13863802782523799, 'fraction_numerical': 0.00488162069807176, 'mean_word_length': 1.8458333333333334, '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': '4906822', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1096, 'n_words': 274}