From d807d28fc42237466595986d1f2e59485bb87c90 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Fri, 15 Dec 2017 14:57:15 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D0=B8=D1=80=D0=B0=D0=B5=D0=BC=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=80=D1=8B=D0=B9=20=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/kinosearch/webapp/player.ftl | 21 -- .../kinosearch/webapp/static/js/player.js | 199 ------------------ 2 files changed, 220 deletions(-) delete mode 100644 src/main/resources/kinosearch/webapp/static/js/player.js diff --git a/src/main/resources/kinosearch/webapp/player.ftl b/src/main/resources/kinosearch/webapp/player.ftl index 4e34a61..71e86bf 100644 --- a/src/main/resources/kinosearch/webapp/player.ftl +++ b/src/main/resources/kinosearch/webapp/player.ftl @@ -3,27 +3,6 @@ - -
diff --git a/src/main/resources/kinosearch/webapp/static/js/player.js b/src/main/resources/kinosearch/webapp/static/js/player.js deleted file mode 100644 index 06065ee..0000000 --- a/src/main/resources/kinosearch/webapp/static/js/player.js +++ /dev/null @@ -1,199 +0,0 @@ -const PlayerCore = function(playerObj, titleObj, videoData) { - this.path = window.location.pathname; - this.origDocTitle = document.title; - this.timeLast = 0; - - const _this = this; - -/* временно отключаю возможность авто-сохранения времени просмотра - // сохранение времени просмотра - playerObj.bind('play', function() { - _this.timeLast = $.now(); - }); - - playerObj.bind('timeupdate', function() { - let timeCurrent = $.now(); - let sec = Math.floor((timeCurrent - _this.timeLast)/1000); - if (sec >= 5) { - let playerCurrentTime = playerObj[0].currentTime; - if (Math.floor(playerCurrentTime) <= 10) - return; - let save_data = { 'time': playerCurrentTime }; - Cookies.set(_this.path, save_data, { 'expires': 30 }); - _this.timeLast = timeCurrent; - console.debug({ - 'path': _this.path, - 'saveTime': save_data - }); //TODO убрать на продакшене - } - }); -*/ - this.getType = function() { - return videoData.type; - }; - - this.setTitle = function(title) { - if (!title) { - title = videoData.title; - } - document.title = title + " :: " + _this.origDocTitle; - titleObj.text(title); - titleObj.show(); - }; - - this.setupForOneFilm = function() { - playerObj.attr('src', videoData.file); - playerObj.load(); - }; - - this.setupForSimpleSerial = function(serialBlock) { - let menu = serialBlock.find('.dropdown-menu'); - menu.html(''); - let _self = this; - videoData.serials.forEach(function(item, i) { - let aTag = $('', { 'href': '#', 'text': item.title }); - aTag.click(function() { - _self.setSerial(i, serialBlock); - }); - let liTag = $('
  • '); - liTag.append(aTag); - menu.append(liTag); - }); - - serialBlock.removeClass('hide'); - }; - - this.setupForSeasonSerial = function(seasonBlock, serialBlock) { - let menu = seasonBlock.find('.dropdown-menu'); - menu.html(''); - let _self = this; - videoData.seasons.forEach(function(item, i) { - let aTag = $('', { 'href': '#', 'text': item.title }); - aTag.click(function() { - _self.setSeason(i, seasonBlock, serialBlock); - }); - let liTag = $('
  • '); - liTag.append(aTag); - menu.append(liTag); - }); - - seasonBlock.removeClass('hide'); - }; - - this.setSerial = function(idx, serialBlock, sidx) { - if (!sidx) { - sidx = 0; - } - - let title; - let playerSrc; - if (_this.getType() == 'seasons_serial') { - title = videoData.seasons[sidx].serials[idx].title; - playerSrc = videoData.seasons[sidx].serials[idx].file; - } else { - title = videoData.serials[idx].title; - playerSrc = videoData.serials[idx].file; - } - _this.setTitle(title); - - let menuBtn = serialBlock.find('#dropdownSerial'); - menuBtn.html(title + ' '); - - playerObj.attr('src', playerSrc); - playerObj.attr('data-serial', idx); - }; - - this.setTime = function(time) { - playerObj[0].currentTime = time; - }; - - this.load = function() { - playerObj.load(); - }; -}; - -function msToTime(ms) { - function addZ(n) { - return (n < 10 ? '0' : '') + n; - } - - const _ms = ms % 1000; - ms = (ms - _ms) / 1000; - const _sec = ms % 60; - ms = (ms - _sec) / 60; - const _min = ms % 60; - const _hr = (ms - _min) / 60; - - return { - 'sec': addZ(_sec), - 'min': addZ(_min), - 'hour': addZ(_hr) - }; -} - -/* -function loadPlayerCookieData(playerCore) { - let data = Cookies.getJSON(playerCore.path); - - if (data != null) { - let fulltime = msToTime(data.time * 1000); - $('#mdl-vtime').text(fulltime.hour + ':' + fulltime.min + ':' + fulltime.sec); - - if (playerCore.getType() == 'simple_serial') { - $('#mdl-serial').find('span').text(data.serial + 1); - $('#mdl-serial').removeClass('hide'); - - $('#mdl-btn-yes').click(function() { - playerCore.setSerial(data.serial, $('#pl-serial')); - - playerCore.setTime(data.time); - playerCore.load(); - }); - - $('#mdl-btn-no').click(function() { - playerCore.load(); - }); - } else if (playerCore.getType() == 'seasons_serial') { - $('#mdl-season').find('span').text(data.season + 1); - $('#mdl-season').removeClass('hide'); - $('#mdl-serial').find('span').text(data.serial + 1); - $('#mdl-serial').removeClass('hide'); - - $('#mdl-btn-yes').click(function() { - playerCore.setSeason(data.season, $('#pl-season')); - playerCore.setSerial(data.serial, $('#pl-serial'), data.season); - - playerCore.setTime(data.time); - playerCore.load(); - }); - - $('#mdl-btn-no').click(function() { - playerCore.load(); - }); - } - $('#modal').modal('show'); - } -} -*/ - -function initPlayer(video_data) { - const playerCore = new PlayerCore($('#player'), $('#title'), video_data); - - // загрузка ранее сохранённых данных - //loadPlayerCookieData(playerCore); - - if (playerCore.getType() == 'one_film') { - playerCore.setTitle(); - playerCore.setupForOneFilm(); - } else if (playerCore.getType() == 'simple_serial') { - playerCore.setupForSimpleSerial($('#pl-serial')); - $('#title').hide(); - } else if (playerCore.getType() == 'seasons_serial') { - playerCore.setupForSeasonSerial($('#pl-season'), $('#pl-serial')); - $('#title').hide(); - } else { - console.debug(video_data); //TODO убрать из продакшена - } - - return playerCore; -}