$dataTable .= '<td>';
$video = $product->video;
if (!empty($video)) {
- $dataTable .= '<video controls width="200">';
- $dataTable .= '<source src="' . Html::encode($video->url) . '" type="video/mp4">';
+ $videoUrl = Html::encode($video->url);
+ $ext = strtolower(pathinfo($video->url, PATHINFO_EXTENSION));
+ $mimeTypes = [
+ 'mp4' => 'video/mp4',
+ 'mov' => 'video/quicktime',
+ 'avi' => 'video/x-msvideo',
+ ];
+ $mimeType = $mimeTypes[$ext] ?? 'video/mp4';
+ $dataTable .= '<video controls width="200" preload="none">';
+ $dataTable .= '<source src="' . $videoUrl . '" type="' . $mimeType . '">';
$dataTable .= 'Ваш браузер не поддерживает видео.';
$dataTable .= '</video>';
}
let pendingAllowed = true;
+let notificationIntervalId = null;
setTimeout(initPendingNotifications, 3000);
function initPendingNotifications() {
pendingNotifications();
- setInterval(pendingNotifications, 10000);
+ notificationIntervalId = setInterval(pendingNotifications, 10000);
}
+// Останавливаем polling когда вкладка неактивна — экономим соединения и трафик
+document.addEventListener('visibilitychange', function () {
+ if (document.hidden) {
+ if (notificationIntervalId) {
+ clearInterval(notificationIntervalId);
+ notificationIntervalId = null;
+ }
+ } else {
+ if (!notificationIntervalId) {
+ pendingNotifications();
+ notificationIntervalId = setInterval(pendingNotifications, 10000);
+ }
+ }
+});
+
// pendingNotifications();
const $counter = $('#kolokolchik-counter');