восстановление просмотра сериала
восстанавливается сезон, серия и время
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
<script type="text/javascript">
|
||||
var video_data = ${json};
|
||||
var player;
|
||||
var videotime = 0;
|
||||
var origDocTitle;
|
||||
var isSerial = false;
|
||||
|
||||
function msToTime(ms) {
|
||||
function addZ(n) { return (n<10? '0':'') + n; }
|
||||
@@ -29,6 +29,41 @@
|
||||
$('#title').show();
|
||||
}
|
||||
|
||||
function setSeason(idx) {
|
||||
var season_title = video_data.playlist[idx].comment;
|
||||
$('#dropdownSeason').html(season_title + ' <span class="caret"></span>');
|
||||
$('#dropdownSerial').html('Serials <span class="caret"></span>');
|
||||
|
||||
var serial_menu = $('#pl-serial-menu');
|
||||
serial_menu.html('');
|
||||
video_data.playlist[idx].playlist.forEach(function(item, i){
|
||||
serial_menu.append('<li><a data-file="' + item.file + '" data-season="' + idx + '" href="#" onclick="setSerial('+ idx + ',' + i + ');return false;">' + item.comment + '</a></li>');
|
||||
});
|
||||
|
||||
/*
|
||||
serial_menu.find('a').bind('click', function(){
|
||||
$('#dropdownSerial').html(this.text + ' <span class="caret"></span>');
|
||||
player.attr('src', '${basedir}'+this.attributes['data-file'].value);
|
||||
player.attr('data-season', this.attributes['data-season'].value);
|
||||
player.attr('data-serial', this.attributes['data-serial'].value);
|
||||
setTitle(this.text);
|
||||
});
|
||||
*/
|
||||
|
||||
$('#pl-serial').removeClass('hide');
|
||||
}
|
||||
|
||||
function setSerial(idx, sidx) {
|
||||
var serial_title = video_data.playlist[idx].playlist[sidx].comment;
|
||||
$('#dropdownSerial').html(serial_title + ' <span class="caret"></span>');
|
||||
|
||||
var serial_file = video_data.playlist[idx].playlist[sidx].file;
|
||||
player.attr('src', '${basedir}' + serial_file);
|
||||
player.attr('data-season', idx);
|
||||
player.attr('data-serial', sidx);
|
||||
setTitle(serial_title);
|
||||
}
|
||||
|
||||
$(function(){
|
||||
player = $('#player');
|
||||
origDocTitle = document.title;
|
||||
@@ -43,48 +78,32 @@
|
||||
player.attr('src', '${basedir}'+video_data.file);
|
||||
$('#plbr').hide();
|
||||
} else if (typeof(video_data.playlist) !== 'undefined') {
|
||||
isSerial = true;
|
||||
$('#pl-season').removeClass('hide');
|
||||
menu = $('#pl-season-menu');
|
||||
|
||||
menu.html('');
|
||||
video_data.playlist.forEach(function(item, i){
|
||||
menu.append('<li><a data-tag="' + i + '" href="#" onclick="return false;">' + item.comment + '</a></li>');
|
||||
});
|
||||
|
||||
ddBtn = $('#dropdownSeason');
|
||||
smenu = $('#pl-serial-menu');
|
||||
menu.find('a').bind('click', function(){
|
||||
ddBtn.html(this.text + ' <span class="caret"></span>');
|
||||
|
||||
$('#dropdownSerial').html('Serials <span class="caret"></span>');
|
||||
|
||||
smenu.html('');
|
||||
video_data.playlist[this.attributes['data-tag'].value].playlist.forEach(function(item){
|
||||
smenu.append('<li><a data-file="' + item.file + '" href="#" onclick="return false;">' + item.comment + '</a></li>');
|
||||
});
|
||||
|
||||
smenu.find('a').bind('click', function(){
|
||||
$('#dropdownSerial').html(this.text + ' <span class="caret"></span>');
|
||||
player.attr('src', '${basedir}'+this.attributes['data-file'].value);
|
||||
setTitle(this.text);
|
||||
});
|
||||
|
||||
$('#pl-serial').removeClass('hide');
|
||||
menu.append('<li><a data-tag="' + i + '" href="#" onclick="setSeason(' + i + ');return false;">' + item.comment + '</a></li>');
|
||||
});
|
||||
}
|
||||
|
||||
// save video time
|
||||
// load video time
|
||||
var path = window.location.pathname.substr("${basedir}".length);
|
||||
var data = Cookies.getJSON(path);
|
||||
data = Cookies.getJSON(path);
|
||||
if (data != null) {
|
||||
videotime = data.time;
|
||||
var fulltime = msToTime(videotime * 1000);
|
||||
var fulltime = msToTime(data.time * 1000);
|
||||
$('#mdl-vtime').text(fulltime.h + ':' + fulltime.m + ':' + fulltime.s);
|
||||
if (isSerial) {
|
||||
$('#mdl-season').text(data.season + 1);
|
||||
$('#mdl-serial').text(data.serial + 1);
|
||||
}
|
||||
$('#modal').modal('show');
|
||||
} else {
|
||||
player.load();
|
||||
}
|
||||
|
||||
// save video time
|
||||
var tl;
|
||||
player.bind('play', function(){
|
||||
tl = $.now();
|
||||
@@ -94,14 +113,24 @@
|
||||
var sec = Math.floor((tc-tl)/1000);
|
||||
if (sec >= 5) {
|
||||
if (Math.floor(player[0].currentTime) <= 10) return;
|
||||
Cookies.set(path, {time:player[0].currentTime});
|
||||
save_data = {time:player[0].currentTime};
|
||||
if (isSerial) {
|
||||
save_data.season = parseInt(player.attr('data-season'), 10);
|
||||
save_data.serial = parseInt(player.attr('data-serial'), 10);
|
||||
}
|
||||
Cookies.set(path, save_data);
|
||||
tl = tc;
|
||||
console.debug(save_data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function continueVideo() {
|
||||
player[0].currentTime = videotime;
|
||||
if (isSerial) {
|
||||
setSeason(data.season);
|
||||
setSerial(data.season, data.serial);
|
||||
}
|
||||
player[0].currentTime = data.time;
|
||||
player[0].load();
|
||||
}
|
||||
</script>
|
||||
@@ -109,8 +138,15 @@
|
||||
<div class="modal fade" tabindex="-1" role="dialog" id="modal">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Продолжить просмотр?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="text-center">Продолжить просмотр с <span id="mdl-vtime"></span>?</p>
|
||||
<b>Время:</b> <span id="mdl-vtime"></span>
|
||||
<div id="mdl-blk-serial">
|
||||
<b>Сезон:</b> <span id="mdl-season"></span><br>
|
||||
<b>Серия:</b> <span id="mdl-serial"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="continueVideo()">Да</button>
|
||||
|
||||
Reference in New Issue
Block a user