{"size": 2467, "ext": "js", "max_stars_repo_path": "src/HeractJS/Scripts/project/shared/utils/helpers.js", "max_stars_repo_name": "ConstYavorskiy/HeractJS", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/HeractJS/Scripts/project/shared/utils/helpers.js", "max_issues_repo_name": "ConstYavorskiy/HeractJS", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/HeractJS/Scripts/project/shared/utils/helpers.js", "max_forks_repo_name": "ConstYavorskiy/HeractJS", "max_forks_repo_forks_event_min_datetime": "2016-05-26T08:16:19.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-27T10:07:09.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 4, "avg_line_length": 36.2794117647, "max_line_length": 140, "alphanum_fraction": 0.4827725983}
﻿/**
 * Developer: Denis Krasnovskiy
 * Date: 9/01/2015
 * Copyright: 2009-2015 Comindware®
 *       All Rights Reserved
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Comindware
 *       The copyright notice above does not evidence any
 *       actual or intended publication of such source code.
 */

/* global define, require, _, $ */

define(['coreui'],
    function(core) {
        'use strict';

        var helpers = {
            systemNameFiltration: function(unfiltredText) {
                var regText = unfiltredText.replace(/[\W]/gi, ''),
                    arrText = [],
                    i;

                for (i = 0; i < regText.length; i++) {
                     arrText.push(regText[i]);
                }

                for (i = 0; i < arrText.length; i++) {
                    if (parseInt(arrText[i])) {
                        arrText.splice(i, 1);
                        i--;
                    } else {
                        return arrText.toString().replace(/,/gi, '');
                    }
                }
            },

            redirect: function() {
                this.title = Localizer.get('CORE.SERVICES.MESSAGE.TITLE.ACCESSDENIED');
                this.description = Localizer.get('CORE.SERVICES.MESSAGE.DESCRIPTION.ACCESSDENIEDDESCRIPTION');
                this.button = [
                    {
                        id: false,
                        text: Localizer.get('CORE.SERVICES.MESSAGE.BUTTONS.RETURN'),
                        default: true
                    }
                ];

                core.services.MessageService.showMessageDialog(this.description, this.title, this.button).then(function () {
                    this.location = window.location;
                    if (this.location.origin) {
                        this.location.href = this.location.origin;
                    } else {
                        this.location.href = this.location.protocol + '//' + this.location.host;
                    }
                }.bind(this));
            },

            parseResponse: function (response) {
                var responseJSON = response.responseJSON,
                    extraData = responseJSON.extraData,
                    exception = responseJSON.exceptionCode;

                return { extraData: extraData, message: Localizer.get('PROCESS.RECORDTYPES.RECORDS.ATTRIBUTEVALUEISNOTUNIQUE')[exception] };
            }
        }
        return helpers;
    });