188 lines
8.0 KiB
JavaScript
188 lines
8.0 KiB
JavaScript
$(function() {
|
|
// function log(data) {
|
|
// // $.ajax({
|
|
// // type: 'GET',
|
|
// // timeout: 6000,
|
|
// // url: "/api/log?v=".concat(data),
|
|
// // cache: false
|
|
// // })
|
|
// }
|
|
$('img').lazyload();
|
|
var domBtnNav = $('#btn-nav');
|
|
var domPopNav = $('#pop-nav');
|
|
var domBtnSearch = $('#btn-search');
|
|
var domPopSearch = $('#pop-search');
|
|
if (domBtnNav.length) {
|
|
domBtnNav.on('click', function() {
|
|
domPopNav.toggleClass('on')
|
|
});
|
|
domBtnSearch.on('click', function() {
|
|
domPopSearch.toggleClass('on')
|
|
});
|
|
$('body').on('click', function(e) {
|
|
if ($(e.target).closest('#btn-nav').length < 1) {
|
|
domPopNav.removeClass('on')
|
|
}
|
|
})
|
|
}
|
|
// var player = {
|
|
// domPlayer: $('#dom-player'),
|
|
// dp: null,
|
|
// vod: null,
|
|
// vodSouIdx: null,
|
|
// getPageUri: function getPageUri(vodId, vodSouIdx) {
|
|
// return window.location.origin + window.location.pathname + '?vod=' + vodId + '-' + vodSouIdx
|
|
// },
|
|
// play: function play() {
|
|
// browserStore.setPriority('lc');
|
|
// browserStore.setItem('player.' + post.id + '.vodId', player.vod.id);
|
|
// browserStore.setItem('player.' + post.id + '.vodSouIdx', player.vodSouIdx);
|
|
// window.history.replaceState({}, '', player.getPageUri(player.vod.id, player.vodSouIdx));
|
|
// $('[data-vod_sou_idx]').removeClass('on');
|
|
// $("[data-vod_id='" + player.vod.id + "']").addClass('on');
|
|
// $("[data-vod_id='" + player.vod.id + "'] [data-vod_sou_idx='" + player.vodSouIdx + "'] ").addClass('on');
|
|
// var source = player.vod.source[player.vodSouIdx];
|
|
// var video = {
|
|
// url: source[1],
|
|
// type: 'customHls',
|
|
// customType: {
|
|
// customHls: function customHls(video, player) {
|
|
// var hls = new Hls();
|
|
// hls.loadSource(video.src);
|
|
// hls.attachMedia(video)
|
|
// }
|
|
// }
|
|
// };
|
|
// if (!player.dp) {
|
|
// var _DPlayer;
|
|
// var logAt = Date.now();
|
|
// var logTimer = setTimeout(function() {
|
|
// if (logAt) {
|
|
// logAt = null;
|
|
// clearTimeout(logTimer);
|
|
// Math.random() < 0.06 && log("".concat(player.vod.id, ".2.-1"))
|
|
// }
|
|
// }, 8000);
|
|
// player.dp = new DPlayer((_DPlayer = {
|
|
// container: player.domPlayer[0],
|
|
// video: video,
|
|
// volume: 1,
|
|
// screenshot: false,
|
|
// autoplay: true,
|
|
// theme: '#fc3437',
|
|
// loop: true
|
|
// }, _defineProperty(_DPlayer, "screenshot", false), _defineProperty(_DPlayer, "airplay", true), _defineProperty(_DPlayer, "chromecast", true), _defineProperty(_DPlayer, "preload", true), _defineProperty(_DPlayer, "mutex", false), _DPlayer));
|
|
// player.dp.on('canplay', function() {
|
|
// player.dp.play();
|
|
// if (logAt) {
|
|
// logAt = null;
|
|
// clearTimeout(logTimer);
|
|
// Math.random() < 0.06 && log("".concat(player.vod.id, ".2.").concat(Date.now() - logAt));
|
|
// Math.random() < 0.06 && log("".concat(player.vod.id, ".3.").concat(player.dp.video.videoWidth * player.dp.video.videoHeight))
|
|
// }
|
|
// })
|
|
// } else {
|
|
// player.dp.switchVideo(video);
|
|
// player.dp.play()
|
|
// }
|
|
// player.dp.notice(post.i18n.loading, 6000)
|
|
// },
|
|
// playNext: function playNext() {
|
|
// player.vodSouIdx = (player.vodSouIdx + 1) % player.vod.source.length;
|
|
// play()
|
|
// },
|
|
// bindChange: function bindChange() {
|
|
// $('[data-vod_sou_idx]').on('click', function(e) {
|
|
// e.preventDefault();
|
|
// var vodId = $(this).closest('[data-vod_id]').data('vod_id');
|
|
// var vodSouIdx = $(this).data('vod_sou_idx');
|
|
// window.location.href = player.getPageUri(vodId, vodSouIdx)
|
|
// })
|
|
// },
|
|
// do: function _do() {
|
|
// if (!player.domPlayer.length) return;
|
|
// player.bindChange();
|
|
// var vodSeqMatch = window.location.search.match(/vod=([0-9_]*)-([0-9]*)/);
|
|
// if (vodSeqMatch) {
|
|
// player.vod = post.vods.find(function(v) {
|
|
// return v.id == vodSeqMatch[1]
|
|
// });
|
|
// player.vodSouIdx = vodSeqMatch[2]
|
|
// }
|
|
// if (!player.vod) {
|
|
// browserStore.setPriority('lc');
|
|
// var vodId = browserStore.getItem('player.' + post.id + '.vodId');
|
|
// var vodSouIdx = browserStore.getItem('player.' + post.id + '.vodSouIdx');
|
|
// if (vodId) {
|
|
// player.vod = post.vods.find(function(v) {
|
|
// return v.id == vodId
|
|
// });
|
|
// player.vodSouIdx = vodSouIdx
|
|
// }
|
|
// }
|
|
// if (!player.vod) {
|
|
// player.vod = post.vods[0]
|
|
// }
|
|
// player.vodSouIdx = player.vod.source[player.vodSouIdx] ? player.vodSouIdx : 0;
|
|
// player.play()
|
|
// }
|
|
// };
|
|
// player.do();
|
|
// var ttl = {
|
|
// isFirst: true,
|
|
// interval: 7000,
|
|
// ajaxArr: [],
|
|
// do: function _do() {
|
|
// while (ttl.ajaxArr.length) {
|
|
// ttl.ajaxArr.shift().abort()
|
|
// }
|
|
// var now = new Date().getTime();
|
|
// $('[data-vod_ttl]').each(function() {
|
|
// var dom = $(this);
|
|
// var vodId = dom.closest('[data-vod_id]').data('vod_id');
|
|
// var m3u = post.vods.find(function(v) {
|
|
// return v.id == vodId
|
|
// })['source'][0][1];
|
|
// ttl.ajaxArr.push($.ajax({
|
|
// type: 'GET',
|
|
// timeout: 6000,
|
|
// url: m3u,
|
|
// cache: false,
|
|
// crossDomain: true,
|
|
// success: function success() {
|
|
// var diff = new Date().getTime() - now;
|
|
// dom.removeClass();
|
|
// if (diff < 1000) {
|
|
// dom.addClass('ttl v1');
|
|
// $('.val', dom).html(diff + 'ms')
|
|
// } else if (diff < 3000) {
|
|
// dom.addClass('ttl v2');
|
|
// $('.val', dom).html(diff + 'ms')
|
|
// } else {
|
|
// dom.addClass('ttl v3');
|
|
// $('.val', dom).html('差')
|
|
// }
|
|
// if (ttl.isFirst) {
|
|
// Math.random() < 0.01 && log("".concat(vodId, ".1.").concat(diff))
|
|
// }
|
|
// },
|
|
// error: function error() {
|
|
// dom.removeClass();
|
|
// dom.addClass('ttl v3');
|
|
// $('.val', dom).html(post.i18n.overtime);
|
|
// if (ttl.isFirst) {
|
|
// Math.random() < 0.01 && log("".concat(vodId, ".1.-1"))
|
|
// }
|
|
// }
|
|
// }))
|
|
// });
|
|
// ttl.interval += 500;
|
|
// setTimeout(function() {
|
|
// ttl.isFirst = false;
|
|
// ttl.do()
|
|
// }, ttl.interval)
|
|
// }
|
|
// };
|
|
// ttl.do()
|
|
});
|