PageSourceSearch

https://cdnn.1prime.ru//js/id/id.profile.lib.js

js 1prime.ru collected 2026-10-01 08:34:34 UTC 7,740 bytes, 252 lines download raw bytes

1$(function() {
2    /**
3     * Profile class
4     * @param {object} options
5     */
6    Profile = function(options) {
7        var that = this;
8
9        $.extend(that, {
10            csrf_token: '',
11            actions: {
12                delete_field: '/services/id/profile/delete_field/',
13                update_field: '/services/id/profile/update_field/',
14                send_email: '/services/id/change_email/send_email/',
15                change_privacy: '/services/id/profile/change_privacy/',
16                change_password: '/services/id/profile/change_password/',
17                delete_account: '/services/id/profile/delete_account/',
18                delete_social: '/services/id/profile/delete_social/',
19                update_avatar: '/services/id/profile/update_avatar/',
20                send_message: '/services/id/profile/send_message/',
21                password_recovery: '/services/id/profile/password-recovery/'
22            },
23        }, options);
24    }
25
26    /**
27     * Update user data
28     * @param  {object} field Dom elements
29     * @return {object} Promise
30     */
31    Profile.prototype.updateField = function(field) {
32        var that = this,
33            data = field.serializeArray();
34
35        data.push({
36            name: 'csrf_token',
37            value: that.csrf_token
38        });
39
40        return $.ajax({
41            url: that.actions.update_field,
42            data: data,
43            type: 'post',
44            dataType: 'json'
45        });
46    };
47
48    /**
49     * Change privacy
50     * @param  {object} data
51     * @return {object} Promise
52     */
53    Profile.prototype.changePrivacy = function(data) {
54        var that = this,
55            data = data || {};
56
57        data.csrf_token = that.csrf_token;
58
59        return $.ajax({
60            url: that.actions.update_field,
61            data: data,
62            type: 'post',
63            dataType: 'json'
64        });
65    };
66
67    /**
68     * Recovery password
69     * @return {object} Promise
70     */
71    Profile.prototype.passwordRecovery = function() {
72        var that = this;
73
74        return $.ajax({
75            url: that.actions.password_recovery,
76            type: 'post',
77            dataType: 'json',
78            data: {
79                'csrf_token': that.csrf_token
80            }
81        });
82    };
83
84    /**
85     * Delete account
86     * @return {object} Promise
87     */
88    Profile.prototype.accountDelete = function() {
89        var that = this;
90
91        return $.ajax({
92            url: that.actions.delete_account,
93            type: 'post',
94            dataType: 'json',
95            data: {
96                'csrf_token': that.csrf_token
97            }
98        });
99    };
100
101    /**
102     * Delete social account
103     * @param  {string} provider
104     * @return {object} Promise
105     */
106    Profile.prototype.socialDelete = function(provider) {
107        var that = this;
108
109        return $.ajax({
110            url: that.actions.delete_social,
111            data: {
112                provider: provider,
113                csrf_token: that.csrf_token
114            },
115            type: 'post',
116            dataType: "json"
117        });
118    };
119
120    /**
121     * Link social account via new window
122     * @param  {object} options
123     */
124    Profile.prototype.socialLink = function(options) {
125        var options = $.extend({
126            name: 'Авторизация',
127            params: 'menubar=yes,location=yes,resizable=no,scrollbars=no,status=yes',
128            width: '500',
129            height: '300',
130            provider: '',
131            success: function() {}
132        }, options || {});
133
134        var url = GLOBAL.auth[options.provider] + '?link=1',
135            left = (screen.width - options.width) / 2,
136            top = (screen.height - options.height) / 2,
137            params = 'top=' + top + ',left=' + left + ',width=' + options.width + ',height=' + options.height + options.params;
138
139        // Открыть окно авторизации
140        var socialLinkWindow = window.open(url, options.name, params),
141            socialWindowInterval;
142
143        // Вызывается из окна авторизации в случае успешной авторизации
144        window.document.linkSocialAccountSuccess = function(data) {
145            options.success(data);
146        }
147
148        // Вызывается из окна авторизации в случае ошибки
149        window.document.linkSocialAccountError = function(data, error) {
150            console.error({
151                'field_name': error[0],
152                'error_code': error[1]
153            });            
154        }
155
156        function listenMessage(msg) {
157            msg = JSON.parse(msg.data);
158
159            if (typeof window.document[msg.func] === 'function') {
160                window.document[msg.func](msg.data, msg.error);
161
162                // Закрыть окно
163                if (socialLinkWindow) {
164                    socialLinkWindow.close();
165                }
166
167                if (socialWindowInterval) {
168                    clearInterval(socialWindowInterval)
169                }
170            }
171        }
172        
173        if (window.addEventListener) {
174            window.addEventListener("message", listenMessage, false);
175        } else {
176            window.attachEvent("onmessage", listenMessage);
177        }
178
179        socialWindowInterval = setInterval(function() {
180            socialLinkWindow.postMessage('linkSocialAccount', '*');
181        }, 2000)
182    };
183
184    /**
185     * Показать соц сети на публичной странице
186     * @param  {object} options
187     */
188    Profile.prototype.showSocial = function(options) {
189
190    }
191
192    /**
193     * Alert modal window
194     * @param  {object} options
195     */
196    Profile.prototype.alert = function(options) {
197        var modal = $('#idProfileAlert');
198
199        // Вставляем текст сообщения
200        modal.find('.l-modal__text span').html(options.text);
201
202        // Отменяем старый обработчик закрытия
203        modal.find('.l-modal__confirm-yes').off('click.idProfileAlert');
204
205        // Добавляем новый обработчик закрытия
206        if (options.onclose instanceof Function) {
207            modal.on('click.idProfileAlert', '.l-modal__confirm-yes', options.onclose);
208        }
209
210        // Открываем модальное окно
211        modalLayer.open('id_alert');
212    };
213
214    /**
215     * Confirm modal window
216     * @param  {object} options
217     */
218    Profile.prototype.confirm = function(options) {
219        var modal = $('#idProfileConfirm');
220
221        // Вставляем текст сообщения
222        modal.find('.l-modal__text span').html(options.text);
223
224        // Отменяем старый обработчик закрытия
225        modal.find('.l-modal__confirm-yes').off('click.idProfileConfirm');
226        modal.find('.l-modal__confirm-no').off('click.idProfileConfirm');
227
228        // Добавляем новый обработчик закрытия
229        if (options.onclose instanceof Function) {
230            modal.on('click.idProfileConfirm', '.l-modal__confirm-no', options.onclose);
231        }
232
233        // Добавляем новый обработчик закрытия
234        if (options.success instanceof Function) {
235            modal.on('click.idProfileConfirm', '.l-modal__confirm-yes', options.success);
236        }
237
238        // Открываем модальное окно
239        modalLayer.open('id_confirm');
240    }
241
242    // Logout
243    Profile.prototype.logout = function() {
244        return $.ajax({
245            url: '/services/id/logout/',
246            type: 'post',
247            data: {
248                csrf_token: GLOBAL.csrf_token
249            }
250        });
251    }
252});

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.