<commit_before>/*
 * Copyright 2016 EPAM Systems
 *
 *
 * This file is part of EPAM Report Portal.
 * https://github.com/reportportal/service-ui
 *
 * Report Portal is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Report Portal is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */
define(function (require) {
    'use strict';

    var Epoxy = require('backbone-epoxy');
    var _ = require('underscore');
    var Util = require('util');
    var Service = require('coreService');
    var GadgetModel = require('dashboard/GadgetModel');
    var WidgetModel = require('newWidgets/WidgetModel');
    var WidgetView = require('newWidgets/WidgetView');
    var WidgetService = require('newWidgets/WidgetService');

    var PreviewWidgetView = Epoxy.View.extend({
        className: 'preview-widget-view',
        initialize: function (options) {
            var self = this;
            var gadget;
            var curWidget;
            var widgetData;
            if (options.sharedWidgetModel) {
                this.model = new GadgetModel({ gadget: options.sharedWidgetModel.get('gadget') });
            }
            gadget = this.model.get('gadget');
            if (!WidgetService.getWidgetConfig(gadget).hasPreview || (!options.validateForPreview() && !options.sharedWidgetModel)) {
                this.$el.css('background-image', 'url(' + this.model.get('gadgetPreviewImg') + ')');
                return true;
            }
            this.$el.html('<div class="preloader" style="display: block; padding-top: 50px;">' +
                '<i class="material-icons loader-animation">refresh</i>' +
                '</div>');
            if (options.sharedWidgetModel) {
                Service.getSharedWidgetData(options.sharedWidgetModel.get('id'))
                    .done(function (data) {
                        self.model.parseData(data);
                        self.widgetView && self.widgetView.destroy();<commit_msg>Fixed some cases JS error on drawing a shared widget preview.<commit_after>/*
 * Copyright 2016 EPAM Systems
 *
 *
 * This file is part of EPAM Report Portal.
 * https://github.com/reportportal/service-ui
 *
 * Report Portal is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Report Portal is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */
define(function (require) {
    'use strict';

    var Epoxy = require('backbone-epoxy');
    var _ = require('underscore');
    var Util = require('util');
    var Service = require('coreService');
    var GadgetModel = require('dashboard/GadgetModel');
    var WidgetModel = require('newWidgets/WidgetModel');
    var WidgetView = require('newWidgets/WidgetView');
    var WidgetService = require('newWidgets/WidgetService');

    var PreviewWidgetView = Epoxy.View.extend({
        className: 'preview-widget-view',
        initialize: function (options) {
            var self = this;
            var gadget;
            var curWidget;
            var widgetData;
            if (options.sharedWidgetModel) {
                this.model = new GadgetModel({ gadget: options.sharedWidgetModel.get('gadget') });
            }
            gadget = this.model.get('gadget');
            if (!WidgetService.getWidgetConfig(gadget).hasPreview || (!(options.validateForPreview && options.validateForPreview()) && !options.sharedWidgetModel)) {
                this.$el.css('background-image', 'url(' + this.model.get('gadgetPreviewImg') + ')');
                return true;
            }
            this.$el.html('<div class="preloader" style="display: block; padding-top: 50px;">' +
                '<i class="material-icons loader-animation">refresh</i>' +
                '</div>');
            if (options.sharedWidgetModel) {
                Service.getSharedWidgetData(options.sharedWidgetModel.get('id'))
                    .done(function (data) {
                        self.model.parseData(data);
                        self.widgetView && self.widgetView.destroy();
{'fraction_non_alphanumeric': 0.11347233360064155, 'fraction_numerical': 0.0028067361668003207, 'mean_word_length': 2.638949671772429, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3139685', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1282, 'n_words': 396}