1function t937_init(recid, styles) {2var rec = document.getElementById('rec' + recid);3if (!rec) return;45var windowWidth = window.innerWidth;6var screenMin = rec.getAttribute('data-screen-min');7var screenMax = rec.getAttribute('data-screen-max');89if (screenMin && windowWidth < parseInt(screenMin, 10)) return false;10if (screenMax && windowWidth > parseInt(screenMax, 10)) return false;1112var playlist = rec.querySelector('.t937__playlist-wrap');
var videoColumn = rec.querySelector('.t937__col_video'); var videoData = t937_parseData(recid); var params = t937_getUrlParametrs(recid); var activeVideoId = params.activeVideoId; t937_setSizes(recid, styles); t937_renderVideoCount(videoData, recid, styles); t937_renderPlaylist(videoData, activeVideoId, recid, styles); t937_renderVideoFrame(videoData, activeVideoId, recid, styles); if (videoColumn) videoColumn.style.height = ''; if (playlist) playlist.style.visibility = 'visible'; t937_addEvents(recid, styles);}function t937_getUrlParametrs(recid) { var activeRecId; var activeVideoId; var hash = window.location.hash; if (hash && hash.indexOf('#tlection=') === -1) { activeRecId = recid; activeVideoId = 1; } else { var params = hash.replace('#tlection=', '').split('_'); activeRecId = params[0]; activeVideoId = +recid === +activeRecId ? params[1] : 1; } return { activeRecId: activeRecId, activeVideoId: activeVideoId, };}function t937_parseData(recid) { var rec = document.getElementById('rec' + recid); if (!rec) return; var recData = rec ? rec.querySelector('.t937__data') : null; var data = recData ? recData.innerHTML : ''; var videos = []; if (data) { data = data.replace(/&/gi, '&'); var segments = data.split('\n'); for (var i = 0; i < segments.length; i++) { /* url; title; time; description */ var segment = segments[i]; var parts = segment.split(';'); var video = t937_getVideoData(parts); if (video.url || video.section) { videos.push(video); } } } return videos;}function t937_getVideoData(data) { /* If string contains '[...]', return as not a video data but section */ var first = data[0].trim(); if (first.indexOf('[') === 0 && first.indexOf(']') === first.length - 1) { return { section: first.slice(1, -1), }; } var url = data[0] && data[0].length ? data[0].trim() : null; var title = data[1] ? data[1].trim() : null; var time = data[2] ? data[2].trim() : null; var description = data[3] ? data[3].trim() : null; var type = null; if (/youtube.com|youtu.be/gi.test(url)) { type = 'youtube'; } else if (/vimeo.com/gi.test(url)) { type = 'vimeo'; } else if (/rutube.ru/gi.test(url)) { type = 'rutube'; } else if (/kinescope.io/gi.test(url)) { type = 'kinescope'; } else if (/vk.com|vk.ru|vkvideo.ru/gi.test(url)) { type = 'vkvideo'; // В сервисе boomstream есть ссылки формата .mp4 // Их лучше загружать в тег video, чтобы применялись все настройки видео } else if (/boomstream.com/gi.test(url) && !/.mp4/gi.test(url)) { type = 'boomstream'; } else if (/.mp4/gi.test(url)) {