PageSourceSearch

https://masterakrasoti.ru/nassets/3e6171b4/js/frames/statistics.js?v=1790428180

js masterakrasoti.ru collected 2026-10-08 11:04:21 UTC 12,223 bytes, 387 lines download raw bytes

1jQuery.widget('gc.gcVideoStatistics', $.gc.gcFileSelectorFolder, {
2	options: {
3		mainHash: null,
4		previewList: []
5	},
6	mapFrameHashToSrc: null,
7	currentPreview: null,
8	watermarkEnableInput: false,
9	users: {},
10	grids: [],
11	popup: null,
12	gridData: [],
13	gridFilter: [
14		-1, -1, -1, -1
15	],
16	_create: function() {
17		var self = this;
18		var $messageEl = $('<div><h3>' + Yii.t('common', 'Просмотры') + '</h3></div>');
19		self.messageEl = $messageEl;
20
21		ajaxCall('/pl/fileservice/video/info', {
22				'file-hash': self.options.mainHash,
23				'result-format': 'json'
24			}, {crossDomain: true}, function (response) {
25			if (response.videoHash !== null) {
26				self.options.statisticsUrl = response.statisticsUrl;
27				self.options.apiHost = response.apiHost;
28				self.options.isVertical = response.isVertical;
29
30				self.generateDatatable();
31			} else {
32				$messageEl.text(window.tt('common', 'Это видео еще не обработано'));
33			}
34		});
35	},
36	init: function() {
37		this.gridFilter = [-1, -1, -1, -1];
38	},
39	generateRows: function(deleted = false) {
40		var $users = this.users;
41		var $content =  $('<tbody>');
42		var self = this;
43		$.each($users, function (index, value) {
44			var next = false;
45
46			if (deleted && !value.deleted) {
47				return;
48			}
49
50			if (!deleted && value.deleted) {
51				return;
52			}
53
54			var grids = '';
55			var maxIndex = 0;
56
57			$.each(self.gridFilter, function (index, value) {
58				if (value >= 0) {
59					maxIndex = index;
60				}
61			});
62
63			if (value.images.length < maxIndex + 1) {
64				return;
65			}
66
67			$.each(value.images, function( index, value ) {
68				// hack
69				var name = parseInt(value) + '.jpg';
70				if (self.gridFilter[index] >= 0 && self.gridFilter[index] == parseInt(value)) {
71					grids += '<div class="grid-image"><img src="https://vh-asset-static2.kinescopecdn.net/vhstatic/grid-image/1/' + name + '" alt="grid"></div>';
72					return;
73				}
74
75				if (self.gridFilter[index] == -1) {
76					grids += '<div class="grid-image"><img src="https://vh-asset-static2.kinescopecdn.net/vhstatic/grid-image/1/' + name + '" alt="grid"></div>';
77					return;
78				}
79
80				next = true;
81			});
82
83			if (next) {
84				return;
85			}
86
87			var $grid = '<td>' + grids + '</td>';
88			var firstName = value.first_name === null || value.deleted ? '' : value.first_name;
89			var lastName = value.last_name === null || value.deleted ? '' : value.last_name;
90			var timeCreated = value.time_created === null || value.deleted ? '' : value.time_created;
91
92			$content.append($('<tr>' +
93				'<th scope="row">' + (value.deleted ? Yii.t('common', 'Пользователь удален') : value.email) + '</th>' +
94				'<td>' + firstName + '</td>' +
95				'<td>' + lastName + '</td>' +
96				'<td>' + timeCreated + '</td>' + $grid));
97		});
98
99		$content.append($('</tbody>'));
100
101		return $content;
102	},
103	generateHtml: function() {
104		var $content = $('<table class="table">');
105		var $deletedContent = $content.clone();
106
107		var $tableHead = $('<thead>\n' +
108			'    <tr>\n' +
109			'      <th scope="col">Email</th>\n' +
110			'      <th scope="col">' + Yii.t('common', 'Имя') + '</th>\n' +
111			'      <th scope="col">' + Yii.t('common', 'Фамилия') + '</th>\n' +
112			'      <th scope="col">' + Yii.t('common', 'Дата визита') + '</th>\n' +
113			'      <th scope="col">' + Yii.t('common', 'Вид сетки') + '</th>\n' +
114			'    </tr>\n' +
115			'  </thead>');
116
117        var $deletedTableHead = $tableHead.clone();
118
119		var $tableRows = this.generateRows(false);
120        var $deletedTableRows = this.generateRows(true);
121
122        var $tableEnd = $('</table>');
123        var $deletedTableEnd = $tableEnd.clone();
124
125		$content.append($tableHead);
126		$content.append($tableRows);
127		$content.append($tableEnd);
128
129        $deletedContent.append($deletedTableHead);
130        $deletedContent.append($deletedTableRows);
131        $deletedContent.append($deletedTableEnd);
132
133		this.mainTable = $content;
134        this.deletedTable = $deletedContent;
135
136		return $content;
137	},
138	generateDatatable: function () {
139		var $tables = $('<div class="stat-tables"></div>');
140		var $notification = $('<div class="statistics-notification">' +
141			Yii.t('common', 'При удалении пользователей статистика просмотров будет удалена') +
142			'</div>');
143		var $deletedStatistics = $('<a style="color:#ff4c4c" href="#"></a>');
144		var $activeStatistics = $('<a style="color:#74cc00" href="#"></a>');
145		var $bottomPanel = $('<div class="stat-bottom" style="position: fixed; bottom: 5px;"></div>');
146
147		this.element.addClass("statistics-content");
148		this.element.css({
149			'padding' : '20px',
150			'width' : '85%',
151			'display' : 'inline-block',
152			'overflow' : 'hidden',
153			'overflow-y' : 'auto',
154			'height': '590px',
155		});
156
157		$notification.css({
158			'color' : '#7b7b7b'
159		});
160
161		var datatableOptions = {
162			"ordering": false,
163			"scrollY": '400px',
164			"scrollCollapse": true,
165			"paging": true,
166			"language": {
167				"search": Yii.t('common', 'Поиск:'),
168				"lengthMenu": Yii.t('common', 'Показать') + ' _MENU_ ' + Yii.t('common', 'записей'),
169				"zeroRecords": Yii.t('common', 'Извините, ничего не найдено'),
170				"info": Yii.t('common', 'Количество записей') + ': _MAX_',
171				"infoEmpty": Yii.t('common', 'Записей не найдено'),
172				"infoFiltered": Yii.t('common', '(отфильтровано') + ' _MAX_ ' + Yii.t('common', 'записей') + ')',
173				"paginate": {
174					"first": Yii.t('common', 'Первая'),
175					"last": Yii.t('common', 'Последняя'),
176					"next": Yii.t('common', 'Следующая'),
177					"previous": Yii.t('common', 'Предыдущая')
178				},
179			}
180		};
181
182		var $firstPositionSelect = this.generateFindFilter('first');
183		var $secondPositionSelect = this.generateFindFilter('second');
184		var $thirdPositionSelect = this.generateFindFilter('third');
185		var $fourthPositionSelect = this.generateFindFilter('fourth');
186
187		var $filter = $('<div class="filter-form"></div>');
188
189		$filter.append($firstPositionSelect);
190		$filter.append($secondPositionSelect);
191		$filter.append($thirdPositionSelect);
192		$filter.append($fourthPositionSelect);
193
194		var $filterWrapper = $('<div id="filter-wrapper"></div>');
195		$filterWrapper.append($filter);
196		this.element.append($('<div><h3>' + Yii.t('common', 'Фильтр') + '</h3></div>'));
197		this.element.append($filterWrapper);
198		this.element.append($('<br>'));
199		this.element.append(this.messageEl);
200		this.element.append($tables);
201		this.element.append($bottomPanel);
202		var self = this;
203		var select2Config = {
204			dropdownParent: $(this).find('.modal-content'),
205			minimumResultsForSearch: -1,
206			formatResult: function (state) {
207				if (state.element[0].value === '-1') {
208					return $('<div>' + Yii.t('common', 'Без сетки') + '</div>');
209				}
210
211				return  $('<div style="float: left; border: 1px solid black;height: 60px;\n' +
212					'width: 60px;' +
213					'margin: 2px 2px 2px 2px;' +
214					'overflow: hidden;"><img style="width: 100%; transform: scale(3);" ' +
215					'src="https://vh-asset-static2.kinescopecdn.net/vhstatic/grid-image/1/'
216					+ state.element[0].value + '.jpg" /></div>');
217			},
218		};
219
220		var $selects = [
221			$firstPositionSelect.select2(select2Config),
222			$secondPositionSelect.select2(select2Config),
223			$thirdPositionSelect.select2(select2Config),
224			$fourthPositionSelect.select2(select2Config),
225		]
226
227		this.selects = $selects;
228
229		var onSelect = function (e) {
230			var position = e.target.id;
231			var val = e.val;
232
233			switch (position) {
234				case 'first_position' :
235					self.gridFilter[0] = val;
236					break;
237				case 'second_position' :
238					self.gridFilter[1] = val;
239					break;
240				case 'third_position' :
241					self.gridFilter[2] = val;
242					break;
243				case 'fourth_position' :
244					self.gridFilter[3] = val;
245					break;
246			}
247
248			self.generateHtml();
249			$tables.empty();
250
251			$tables.append(self.mainTable);
252			$tables.append(self.deletedTable);
253
254			self.mainTable.DataTable(datatableOptions);
255			self.deletedTable.DataTable(datatableOptions);
256			self.mainTable.parent().parent().parent().css('height', '400px');
257			self.deletedTable.parent().parent().parent().css('height', '400px');
258
259			if (self.currentTable === 'active' || !self.currentTable) {
260				self.deletedTable.parent().parent().parent().hide();
261			} else {
262				self.mainTable.parent().parent().parent().hide();
263			}
264		}
265
266		$firstPositionSelect.on("select2-selecting", onSelect);
267		$secondPositionSelect.on("select2-selecting", onSelect);
268		$thirdPositionSelect.on("select2-selecting", onSelect);
269		$fourthPositionSelect.on("select2-selecting", onSelect);
270
271		$('.select2-drop').css('z-index', 99999);
272		$('.select2-results').css('display', 'grid');
273
274		$('html').click(function(e) {
275			if(!$(e.target).hasClass('select2-drop') ) {
276				$selects.forEach(el => el.select2('close'));
277			}
278		});
279
280		$activeStatistics.hide();
281
282		ajaxCall(self.options.statisticsUrl , {}, {}, function (response) {
283			let userIds = response.info.map(a => a.payload.replace(/\D/g, ""));
284			ajaxCall('/pl/fileservice/video/users-info', {
285				'json': JSON.stringify(userIds),
286			}, {}, function (resp) {
287				self.dictionary = resp.result;
288				if (response.info) {
289					let users = [];
290					for(var i in response.info) {
291						let id = response.info[i].payload.replace(/\D/g, "")
292						if (!self.dictionary[id]) {
293							continue;
294						}
295
296						users.push({
297							id: id,
298							time_created: response.info[i].time_created,
299							deleted: !!+self.dictionary[id].deleted,
300							email: self.dictionary[id].email,
301							first_name: self.dictionary[id].first_name,
302							last_name: self.dictionary[id].last_name,
303							images: response.info[i].images,
304						});
305					}
306
307					self.users = users;
308
309					$bottomPanel.append($notification);
310					$bottomPanel.append($deletedStatistics);
311					$bottomPanel.append($activeStatistics);
312
313					self.generateHtml();
314
315					var deletedUsers = [];
316					var activeUsers = [];
317
318					for(var i in self.users) {
319						if (self.users[i].deleted) {
320							deletedUsers.push([i, self.users[i]]);
321						} else {
322							activeUsers.push([i, self.users[i]]);
323						}
324					}
325
326					if (deletedUsers.length) {
327						$deletedStatistics.text(
328							Yii.t('common', 'Показать статистику ') +
329							deletedUsers.length + Yii.t('common', ' удаленных пользователей')
330						);
331						$deletedStatistics.click(function (e) {
332							e.preventDefault();
333							$activeStatistics.show();
334							$deletedStatistics.hide();
335
336							self.currentTable = 'deleted';
337							self.mainTable.parent().parent().parent().hide();
338							self.deletedTable.parent().parent().parent().show();
339						});
340
341						$activeStatistics.text(
342							Yii.t('common', 'Показать статистику ') +
343							activeUsers.length +
344							Yii.t('common', ' активных пользователей')
345						);
346						$activeStatistics.click(function (e) {
347							e.preventDefault();
348							$activeStatistics.hide();
349							$deletedStatistics.show();
350							self.currentTable = 'active';
351
352							self.mainTable.parent().parent().parent().show();
353							self.deletedTable.parent().parent().parent().hide();
354						});
355					}
356
357					$tables.append(self.mainTable);
358					$tables.append(self.deletedTable);
359
360					self.mainTable.DataTable(datatableOptions);
361					self.deletedTable.DataTable(datatableOptions);
362					self.mainTable.parent().parent().parent().css('height', '400px');
363					self.deletedTable.parent().parent().parent().css('height', '400px');
364
365					self.deletedTable.parent().parent().parent().hide();
366				} else {
367					self.messageEl.text('Статистика недеоступна. Обратитесь в техподдержку.');
368				}
369			});
370		});
371	},
372	generateFindFilter: function (order) {
373		var $selectForm = $('<select id="' + order + '_position" style="width: 12vw; margin-right: 15px;"></select>');
374		var $zeroOption = $('<option value="-1">' + Yii.t('common', 'Без сетки') + '</option>');
375		$selectForm.append($zeroOption);
376
377		for (var i = 0; i < 22; i++) {
378			var $option = $('<option value="' + i + '">' + Yii.t('common', 'Сетка') + ' ' + i + '</option>');
379			$selectForm.append($option);
380		}
381		return $selectForm;
382	},
383	onSelect: function (e) {
384
385
386	}
387} );

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.