PageSourceSearch

https://incanto.eu/local/templates/.default/scripts/custom/ServerAjaxResponse.js?17884178212147

js incanto.eu collected 2026-09-29 11:31:03 UTC 2,147 bytes, 88 lines download raw bytes

1/**
2 * Аякс-ответ, приходящий от сервера
3 *
4 * @param response
5 * @constructor
6 */
7var ServerAjaxResponse = function (response) {
8    this.response = response.data;
9};
10
11/**
12 * @returns {boolean}
13 */
14ServerAjaxResponse.prototype.isSuccess = function () {
15    return this.response && !!this.response.success;
16};
17
18/**
19 * @returns {boolean}
20 */
21ServerAjaxResponse.prototype.isRedirectResponse = function () {
22    return this.response && !!this.response.redirect;
23};
24
25/**
26 * @returns {boolean}
27 */
28ServerAjaxResponse.prototype.hasErrors = function () {
29    return Object.keys(this.getErrors()).length > 0;
30};
31
32/**
33 * @returns {{errorCode: string|array errorMsg}}
34 */
35ServerAjaxResponse.prototype.getErrors = function () {
36    if (!this.response) {
37        return {};
38    }
39    return this.response.errors || {};
40};
41
42/**
43 * @returns {{errorCode: string|array errorMsg}}
44 */
45ServerAjaxResponse.prototype.getPayload = function () {
46    if (!this.response) {
47        return {};
48    }
49    return this.response.payload || {};
50};
51
52/**
53 * Получает список ошибок с измененными ключами.
54 * Например чтобы перевести список ошибок {EMAIL: 'неверный email'} к виду {email: 'неверный email'}
55 * следует вызвать этот метод с параметром {EMAIL: 'email'}
56 *
57 * @param keysMap
58 */
59ServerAjaxResponse.prototype.getErrorsWithMappedKeys = function (keysMap) {
60    var result = {};
61
62    var errors = this.getErrors();
63    Object.keys(errors).forEach(function (key) {
64        result[keysMap[key] || key] = errors[key];
65    });
66
67    return result;
68};
69
70/**
71 * @returns {Array} список дополнительных сообщений
72 */
73ServerAjaxResponse.prototype.getNotifyMessages = function () {
74    if (!this.response) {
75        return [];
76    }
77    return this.response.notifyMessages || [];
78};
79
80/**
81 * @returns {string} URL для редиректа
82 */
83ServerAjaxResponse.prototype.getRedirectUrl = function () {
84    if (!this.response) {
85        return '';
86    }
87    return this.response.redirect || '';
88};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.