From e2a48d8701f91b8e24fbe9e99e91eb72a87bb749 Mon Sep 17 00:00:00 2001 From: horchi Date: Sun, 5 Mar 2017 16:39:28 +0100 Subject: git init --- http/src/js/pages.now.js | 135 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 http/src/js/pages.now.js (limited to 'http/src/js/pages.now.js') diff --git a/http/src/js/pages.now.js b/http/src/js/pages.now.js new file mode 100644 index 0000000..8244f33 --- /dev/null +++ b/http/src/js/pages.now.js @@ -0,0 +1,135 @@ +epgd.pages.now = { + $ul: null, + timestamp_min: -1, + timestamp_max: 0, + timestamp_cur: 0, + + init: function () { + $(window).bind('channels_load', function () { epgd.pages.timestamp_max = 0; }); + }, + render: function () { + //this.renderTime = new Date().getTime(); + if (!window.pages_now) { + this.$search = $('
').appendTo($('#menu_now')).click(function () { + if (this.curType == '@Now') + window.pages_now.setTime(null,'@Now'); + }); + var $searchMenu = this.$searchMenu = $('').appendTo($('#menu_now')).hide(); + epgd.profile.quickTimes && epgd.profile.quickTimes.replace(/([^=]+)=!?([^~]+)~?/g, function (a, l, v) { + $searchMenu.append('
  • ' + l + '
  • '); + }); + if (!$searchMenu.find('li[data-type="@Next"]').length) + $searchMenu.prepend('
  • ' + epgd.tr.pages.eventDetail.eventNext + '
  • '); + if (!$searchMenu.find('li[data-type="@Now"]').length) + $searchMenu.prepend('
  • ' + epgd.tr.pages.dateTimePicker.currentText + '
  • '); + this.$searchMenu.click(function (ev) { + if (ev.target.getAttribute('data-type')) { + window.pages_now.setTime(null, ev.target.getAttribute('data-type')); + $searchMenu.hide(); + } + }); + $(window).bind("epgd_close.pages_now", function () { + if (window.pages_now) { + epgd.$dtPicker.hide(); + window.pages_now.$searchMenu.remove(); + window.pages_now.$search.remove(); + delete window.pages_now; + } + $(window).unbind(".pages_now"); + $('#menu_now').unbind(".pages_now"); + }).bind("datepicker.pages_now", function () { + this.pages_now.setTime(epgd.utils.unixTime(epgd.$dtPicker.datetimepicker('getDate'))); + })[0].pages_now = this; + this.$ul = epgd.$con.html('
    ').find('ul') + .click(function (ev) { + if ($(ev.target).closest('.channel').length) { + $(window).trigger("epgd_close.eventDetail"); + if (ev.target.className == 'i-tv') + epgd.vdrs.current.switchChannel(ev.target.parentNode.id); + else { + epgd.$menu.menu("select", { target: "#menu_magazine" }); + epgd.pages.magazine.setChannel(ev.target.parentNode.id); + } + return; + } + var li = $(ev.target).closest('li')[0]; + if (!li) return; + if (!li.eventDetail) + li.eventDetail = new epgd.eventDetail(li.title); + epgd.utils.loader.process(function () { + li.eventDetail.render(); + }); + }); + this.setTime(null, '@Now'); + }; + $('#menu_now').addClass("menu-active").bind("click.pages_now", function (ev) { + if ((ev.target == this || ev.target.nodeName == 'A') && window.pages_now) { + window.pages_now.$searchMenu.show(); + ev.preventDefault(); + } + return false; + }).append(epgd.$dtPicker.show()); + }, + setTime: function (start, type) { + type = type || '@time'; + var at = ' ' + epgd.tr.pages.now.at; + if (type == '@Now' || type == '@time') { + this.timestamp_cur = start || epgd.utils.unixTime(epgd.utils.now()); + this.load("data/events?time=" + this.timestamp_cur); + epgd.$dtPicker.datetimepicker('setDate', epgd.utils.date(this.timestamp_cur)); + } else if (type == '@Next') + this.load("data/events?next=1&time=" + this.timestamp_cur); + else if (type[0] == '@') { + at = ' ' + epgd.tr.menu.search; + this.load("data/search", 'post', JSON.stringify({ autotimername: type.slice(1) })); + } else { + $.timepicker.quicklink({ target: { nodeName: 'U', innerHTML: type }, data: { unit: 'time' } }); + $(window).trigger('datepicker'); + } + this.$search[0].curType = type; + this.$search.text(this.$searchMenu.find('li[data-type="' + type + '"]').text() + at); + }, + load: function (url,type,data) { + epgd.utils.loader.process(function () { + pages_now.$ul.empty(); + epgd.ajax({ url: epgd.login.url + url, async: false, cache: false, type:type,data:data }, function (data) { + if (!data.events || !data.events.length) { + epgd.utils.loader.close(); + return epgd.utils.popup(epgd.tr.error.noData); + } + var imgPath = epgd.profile.eventImgPath ? epgd.profile.eventImgPath + '?no=0&maxW=100&maxH=70&id=' : false, + min = 0, + max = 2000000000, + dFormat = epgd.tr.dateTimePicker.dateFormat.replace(/\.?y+/,''); + now = parseInt(epgd.utils.now().getTime() / 1000, 10); + //maxHeight = 0, + $.each(data.events, function (id, event) { + var end = event.starttime + event.duration, + progress = ((now - event.starttime) / event.duration * 100), + desc = event.shortdescription || event.shorttext; + if (event.starttime > min) min = event.starttime; + if (end < max) max = end; + $('
  • ' + + epgd.channels.getHtml(event.channelid) + + '
    ' + epgd.utils.formatTime(event.starttime) + + ' – ' + epgd.utils.formatTime(end) + ' ' + epgd.tr.oClock + + (event.tipp ? '' + event.tipp + '' : '') + + '
    ' + + (progress > 0 && progress <= 100 ? '
    ' : '
    ' + epgd.utils.formatDate(event.starttime, dFormat) + '
    ') + + '
    ' + + (imgPath && event.imagecount ? '' : '') + + '
    ' + event.title + + (event.numrating ? ' ' : '') + + '
    ' + + (event.genre ? '' + event.genre + ' ' : '') + (desc ? desc.replace(/\n/g, '
    ') : '') + + '
    ' + + '
  • ').appendTo(pages_now.$ul); + }); + epgd.pages.now.timestamp_min = min; + epgd.pages.now.timestamp_max = max; + epgd.utils.loader.close(); + }); + }, true); + } + +}; -- cgit v1.2.3