#!/usr/bin/env python




##################################################
## DEPENDENCIES
import sys
import os
import os.path
try:
    import builtins as builtin
except ImportError:
    import __builtin__ as builtin
from os.path import getmtime, exists
import time
import types
from Cheetah.Version import MinCompatibleVersion as RequiredCheetahVersion
from Cheetah.Version import MinCompatibleVersionTuple as RequiredCheetahVersionTuple
from Cheetah.Template import Template
from Cheetah.DummyTransaction import *
from Cheetah.NameMapper import NotFound, valueForName, valueFromSearchList, valueFromFrameOrSearchList
from Cheetah.CacheRegion import CacheRegion
import Cheetah.Filters as Filters
import Cheetah.ErrorCatchers as ErrorCatchers
from six.moves.urllib.parse import quote
from json import dumps
from Plugins.Extensions.OpenWebif.controllers.i18n import tstrings

##################################################
## MODULE CONSTANTS
VFFSL=valueFromFrameOrSearchList
VFSL=valueFromSearchList
VFN=valueForName
currentTime=time.time
__CHEETAH_version__ = '2.4.4'
__CHEETAH_versionTuple__ = (2, 4, 4, 'development', 0)
__CHEETAH_genTime__ = 1644596120.567471
__CHEETAH_genTimestamp__ = 'Fri Feb 11 16:15:20 2022'
__CHEETAH_src__ = '/home/nonsolosat/openpli-dreambox-oe-core/build/tmp/work/dm520-oe-linux/enigma2-plugin-extensions-openwebif/gitAUTOINC+81b15e17ab-r0/git/plugin/controllers/views/ajax/epgpop.tmpl'
__CHEETAH_srcLastModified__ = 'Fri Feb 11 15:59:45 2022'
__CHEETAH_docstring__ = 'Autogenerated by Cheetah: The Python-Powered Template Engine'

if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
    raise AssertionError(
      'This template was compiled with Cheetah version'
      ' %s. Templates compiled before version %s must be recompiled.'%(
         __CHEETAH_version__, RequiredCheetahVersion))

##################################################
## CLASSES

class epgpop(Template):

    ##################################################
    ## CHEETAH GENERATED METHODS


    def __init__(self, *args, **KWs):

        super(epgpop, self).__init__(*args, **KWs)
        if not self._CHEETAH__instanceInitialized:
            cheetahKWArgs = {}
            allowedKWs = 'searchList namespaces filter filtersLib errorCatcher'.split()
            for k,v in KWs.items():
                if k in allowedKWs: cheetahKWArgs[k] = v
            self._initCheetahInstance(**cheetahKWArgs)
        

    def respond(self, trans=None):



        ## CHEETAH: main method generated for this template
        if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
            trans = self.transaction # is None unless self.awake() was called
        if not trans:
            trans = DummyTransaction()
            _dummyTrans = True
        else: _dummyTrans = False
        write = trans.response().write
        SL = self._CHEETAH__searchList
        _filter = self._CHEETAH__currentFilter
        
        ########################################
        ## START - generated method body
        
        if len(VFFSL(SL,"events",True)) == 0: # generated from line 4, col 1
            write(u'''<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<title>No items found.</title>
</head>
<body style="background: #FFFFFF; scrollbar: auto;">
<img src="../images/not_found.jpg" title="No items found" border="0" style="display:none;" id="ajpg">
<img src="../themes/not_found.png" title="No items found" border="0" onerror=\'$(this).hide();$("#ajpg").show();\'>
</body>
</html>
''')
        else: # generated from line 15, col 1
            t = "original"
            if VFFSL(SL,"varExists",False)('theme'): # generated from line 17, col 1
                t = VFFSL(SL,"theme",True)
            write(u'''<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="images/favicon.png">
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery-ui.min.js"></script>
<link rel="stylesheet" href="../css/jquery-ui.min.css">
''')
            if VFFSL(SL,"t",True) != "original" and VFFSL(SL,"t",True) != "clear": # generated from line 29, col 1
                t = VFFSL(SL,"t",True) + '.css'
                write(u'''\t<link rel="stylesheet" href="../themes/''')
                _v = VFFSL(SL,"t",True) # u'$t' on line 31, col 41
                if _v is not None: write(_filter(_v, rawExpr=u'$t')) # from line 31, col 41.
                write(u'''">
''')
            write(u'''<link type="text/css" href="../css/style.min.css" rel="stylesheet"/>
<link type="text/css" href="../web/css" rel="stylesheet"/>
<script type="text/javascript" src="../js/openwebif.min.js?v1.2.24"></script>
<script type="text/javascript" src="../js/jquery-ui-timepicker-addon.min.js"></script>
<script type="text/javascript" src="../js/chosen.1.8.2.min.js"></script>
<script type="text/javascript">initJsTranslation(''')
            _v = VFFSL(SL,"dumps",False)(VFFSL(SL,"tstrings",True)) # u'$dumps($tstrings)' on line 38, col 50
            if _v is not None: write(_filter(_v, rawExpr=u'$dumps($tstrings)')) # from line 38, col 50.
            write(u''')</script>
<style>

a {text-decoration:none;color:#000;}
.tb { display:inline-block; margin-left:3px;}
.tb i.fa { font-size:32px;}
#station { cursor:pointer;}
.im { font-family:Impact,Arial;font-size:18px;text-decoration:none;}
table { font-size:12px; font-family: Verdana,Arial,sans-serif;}
.deltimer{display:none;}
.ETV table {font-size:12px;width:100%;}
.ETV table td { width:50px;height:40px;}
.eft td { height:60px;vertical-align: middle;}
.efi { width:100px;}
.eft td > div { display:table;width:100%;}
.esl1,.esl2 { display:table-cell;width:30%;font-size:13px;font-weight: bold;vertical-align: middle;height: 60px;padding-left: 10px;}
.esl2 { width:70%;border-left: 1px solid black;}
.eff {width:100% !important;vertical-align: top;padding-left:10px;}
.efi img {width:100px;height:60px; border:none;}
.eff1 {width:100%;}
.panel.ui-state-hover { background-image: none; }
</style>

<title>Open Webif ''')
            _v = VFFSL(SL,"tstrings",True)['epg'] # u"$tstrings['epg']" on line 61, col 19
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['epg']")) # from line 61, col 19.
            write(u'''</title>
</head>
<body>
<div class="ETV">
<table class="ui-widget ui-widget-content" border="0" cellspacing="1" cellpadding="5">
''')
            for event in VFFSL(SL,"events",True): # generated from line 66, col 1
                channel = VFN(VFFSL(SL,"event.sname",True),"replace",False)("'", r"\'")
                title = VFN(VFFSL(SL,"event.title",True),"replace",False)("'", r"\'")
                sref = quote(VFFSL(SL,"event.sref",True), safe=' ~@#$&()*!+=:;,.?/\'')
                write(u"""
\t<tbody data-id='""")
                _v = VFFSL(SL,"sref",True) # u'$sref' on line 71, col 18
                if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 71, col 18.
                write(u''';''')
                _v = VFFSL(SL,"event.begin_timestamp",True) # u'$event.begin_timestamp' on line 71, col 24
                if _v is not None: write(_filter(_v, rawExpr=u'$event.begin_timestamp')) # from line 71, col 24.
                write(u''';''')
                _v = VFFSL(SL,"event.duration",True) # u'$event.duration' on line 71, col 47
                if _v is not None: write(_filter(_v, rawExpr=u'$event.duration')) # from line 71, col 47.
                write(u'''\'>
\t<tr class="eft">
\t<td class="efi ui-widget-header" colspan="2"><img src="''')
                _v = VFFSL(SL,"event.picon",True) # u'$event.picon' on line 73, col 57
                if _v is not None: write(_filter(_v, rawExpr=u'$event.picon')) # from line 73, col 57.
                write(u'''" title=""></td>
\t<td style="width:100%;height:60px;">
\t\t<div>
\t\t<div class="esl1 panel ui-state-hover">''')
                _v = VFFSL(SL,"event.sname",True) # u'$event.sname' on line 76, col 42
                if _v is not None: write(_filter(_v, rawExpr=u'$event.sname')) # from line 76, col 42.
                write(u'''<br />
''')
                if 'ns' in VFFSL(SL,"event",True): # generated from line 77, col 4
                    if '4097:' in VFFSL(SL,"event.sref",True) or '5002:' in VFFSL(SL,"event.sref",True) or 'http%3a' in VFFSL(SL,"event.sref",True) or 'https%3a' in VFFSL(SL,"event.sref",True): # generated from line 78, col 5
                        write(u'''\t\t\t\t\tIPTV
''')
                    else: # generated from line 80, col 5
                        write(u'''\t\t\t\t\t''')
                        _v = VFFSL(SL,"event.service_type",True) # u'$event.service_type' on line 81, col 6
                        if _v is not None: write(_filter(_v, rawExpr=u'$event.service_type')) # from line 81, col 6.
                        write(u''' / ''')
                        _v = VFFSL(SL,"event.ns",True) # u'$event.ns' on line 81, col 28
                        if _v is not None: write(_filter(_v, rawExpr=u'$event.ns')) # from line 81, col 28.
                        write(u'''
''')
                    write(u'''\t\t\t<br />
''')
                write(u'''\t\t\t''')
                _v = VFFSL(SL,"event.date",True) # u'$event.date' on line 85, col 4
                if _v is not None: write(_filter(_v, rawExpr=u'$event.date')) # from line 85, col 4.
                write(u'''</div>
\t\t<div class="esl2 panel ui-state-hover">''')
                _v = VFFSL(SL,"event.title",True) # u'$event.title' on line 86, col 42
                if _v is not None: write(_filter(_v, rawExpr=u'$event.title')) # from line 86, col 42.
                write(u'''<br/>''')
                _v = VFFSL(SL,"event.begin",True) # u'$event.begin' on line 86, col 59
                if _v is not None: write(_filter(_v, rawExpr=u'$event.begin')) # from line 86, col 59.
                write(u'''&nbsp;-&nbsp;''')
                _v = VFFSL(SL,"event.end",True) # u'$event.end' on line 86, col 84
                if _v is not None: write(_filter(_v, rawExpr=u'$event.end')) # from line 86, col 84.
                write(u'''&nbsp;(''')
                _v = VFFSL(SL,"event.duration",True) # u'$event.duration' on line 86, col 101
                if _v is not None: write(_filter(_v, rawExpr=u'$event.duration')) # from line 86, col 101.
                write(u''' min.)</div>
\t\t</div>
\t</td>
\t</tr>
\t<tr>
\t\t<td class="timerpanel panel ui-state-hover">
\t\t\t<a class="tb addtimer" href="#" onclick="addTimerEvent(\'''')
                _v = VFFSL(SL,"sref",True) # u'$sref' on line 92, col 60
                if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 92, col 60.
                write(u"""',""")
                _v = VFFSL(SL,"event.id",True) # u'$event.id' on line 92, col 67
                if _v is not None: write(_filter(_v, rawExpr=u'$event.id')) # from line 92, col 67.
                write(u''',false);return false;" title="''')
                _v = VFFSL(SL,"tstrings",True)['add_timer'] # u"$tstrings['add_timer']" on line 92, col 106
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['add_timer']")) # from line 92, col 106.
                write(u'''">
\t\t\t<i class="fa fa-timerplus"></i>
\t\t\t</a>
\t\t\t<a class="tb deltimer" href="#" onclick="delTimerEvent(\'''')
                _v = VFFSL(SL,"sref",True) # u'$sref' on line 95, col 60
                if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 95, col 60.
                write(u"""',""")
                _v = VFFSL(SL,"event.id",True) # u'$event.id' on line 95, col 67
                if _v is not None: write(_filter(_v, rawExpr=u'$event.id')) # from line 95, col 67.
                write(u''');return false;" title="''')
                _v = VFFSL(SL,"tstrings",True)['delete_timer'] # u"$tstrings['delete_timer']" on line 95, col 100
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['delete_timer']")) # from line 95, col 100.
                write(u'''">
\t\t\t<i class="fa fa-timertrash"></i>
\t\t\t</a>
\t</td>
\t\t<td class="panel ui-state-hover">
\t\t<a class="tb" href="#" onclick="addEditTimerEvent(\'''')
                _v = VFFSL(SL,"sref",True) # u'$sref' on line 100, col 54
                if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 100, col 54.
                write(u"""',""")
                _v = VFFSL(SL,"event.id",True) # u'$event.id' on line 100, col 61
                if _v is not None: write(_filter(_v, rawExpr=u'$event.id')) # from line 100, col 61.
                write(u''');return false;" title="''')
                _v = VFFSL(SL,"tstrings",True)['edit_timer'] # u"$tstrings['edit_timer']" on line 100, col 94
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['edit_timer']")) # from line 100, col 94.
                write(u'''">
\t\t\t<i class="fa fa-timeredit"></i>
\t\t\t</a>
\t\t\t</td>
\t\t<td class="eff" rowspan="4"><div class="eff1">
\t\t\t<span>''')
                _v = VFFSL(SL,"event.shortdesc",True) # u'$event.shortdesc' on line 105, col 10
                if _v is not None: write(_filter(_v, rawExpr=u'$event.shortdesc')) # from line 105, col 10.
                write(u'''</span><br><br></div>
\t\t\t''')
                _v = VFFSL(SL,"event.longdesc",True) # u'$event.longdesc' on line 106, col 4
                if _v is not None: write(_filter(_v, rawExpr=u'$event.longdesc')) # from line 106, col 4.
                write(u'''
\t</td>
\t</tr>
\t<tr>
\t\t<td class="panel ui-state-hover">
\t\t\t<a class="tb" href="#" onclick="addTimerEvent(\'''')
                _v = VFFSL(SL,"sref",True) # u'$sref' on line 111, col 51
                if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 111, col 51.
                write(u"""',""")
                _v = VFFSL(SL,"event.id",True) # u'$event.id' on line 111, col 58
                if _v is not None: write(_filter(_v, rawExpr=u'$event.id')) # from line 111, col 58.
                write(u''',true);return false;" title="''')
                _v = VFFSL(SL,"tstrings",True)['add_zaptimer'] # u"$tstrings['add_zaptimer']" on line 111, col 96
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['add_zaptimer']")) # from line 111, col 96.
                write(u'''">
\t\t\t<i class="fa fa-timerplay"></i>
\t\t\t</a>
\t</td>
\t\t<td class="panel ui-state-hover">
''')
                if VFFSL(SL,"at",True): # generated from line 116, col 5
                    write(u'''\t\t\t<a class="tb" href="#" onclick="addAutoTimerEvent(\'''')
                    _v = VFFSL(SL,"sref",True) # u'$sref' on line 117, col 55
                    if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 117, col 55.
                    write(u"""','""")
                    _v = VFFSL(SL,"channel",True) # u'$channel' on line 117, col 63
                    if _v is not None: write(_filter(_v, rawExpr=u'$channel')) # from line 117, col 63.
                    write(u"""','""")
                    _v = VFFSL(SL,"title",True) # u'$title' on line 117, col 74
                    if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 117, col 74.
                    write(u"""','""")
                    _v = VFFSL(SL,"event.begin",True) # u'$event.begin' on line 117, col 83
                    if _v is not None: write(_filter(_v, rawExpr=u'$event.begin')) # from line 117, col 83.
                    write(u"""','""")
                    _v = VFFSL(SL,"event.end",True) # u'$event.end' on line 117, col 98
                    if _v is not None: write(_filter(_v, rawExpr=u'$event.end')) # from line 117, col 98.
                    write(u'''\');return false;" title="''')
                    _v = VFFSL(SL,"tstrings",True)['add_autotimer'] # u"$tstrings['add_autotimer']" on line 117, col 133
                    if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['add_autotimer']")) # from line 117, col 133.
                    write(u'''">
\t\t\t\t<i class="fa fa-timerat"></i>
\t\t\t</a>
''')
                write(u'''\t</td>
\t</tr>
\t<tr>
\t\t<td class="panel ui-state-hover">
''')
                if VFFSL(SL,"moviedb",True) == "Kinopoisk": # generated from line 125, col 4
                    write(u'''\t\t\t\t<a class="tb" target="_blank" href="http://www.kinopoisk.ru/index.php?first=no&kp_query=''')
                    _v = VFFSL(SL,"quote",False)(VFFSL(SL,"event.title",True)) # u'$quote($event.title)' on line 126, col 93
                    if _v is not None: write(_filter(_v, rawExpr=u'$quote($event.title)')) # from line 126, col 93.
                    write(u'''"><img src="../images/kinopoisk.png" style="width:24px; height:24px; margin:0px 3px 0px 0px" title="''')
                    _v = VFFSL(SL,"tstrings",True)['search_kinopoisk'] # u"$tstrings['search_kinopoisk']" on line 126, col 213
                    if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['search_kinopoisk']")) # from line 126, col 213.
                    write(u'''" border="0"></a>
''')
                elif VFFSL(SL,"moviedb",True) == "CSFD": # generated from line 127, col 4
                    write(u'''\t\t\t\t<a class="im tb" target="_blank" href="https://www.csfd.cz/hledat/?q=''')
                    _v = VFFSL(SL,"event.title",True) # u'$event.title' on line 128, col 74
                    if _v is not None: write(_filter(_v, rawExpr=u'$event.title')) # from line 128, col 74.
                    write(u'''" title="''')
                    _v = VFFSL(SL,"tstrings",True)['search_csfd'] # u"$tstrings['search_csfd']" on line 128, col 95
                    if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['search_csfd']")) # from line 128, col 95.
                    write(u'''">csfd</a>
''')
                else: # generated from line 129, col 4
                    write(u'''\t\t\t\t<a class="im tb" target="_blank" href="http://www.imdb.com/find?s=all&amp;q=''')
                    _v = VFFSL(SL,"quote",False)(VFFSL(SL,"event.title",True)) # u'$quote($event.title)' on line 130, col 81
                    if _v is not None: write(_filter(_v, rawExpr=u'$quote($event.title)')) # from line 130, col 81.
                    write(u'''" title="''')
                    _v = VFFSL(SL,"tstrings",True)['search_imdb'] # u"$tstrings['search_imdb']" on line 130, col 110
                    if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['search_imdb']")) # from line 130, col 110.
                    write(u'''">IMDb</a>
''')
                write(u'''\t</td>
\t\t<td></td>
\t</tr>
</tbody>
''')
            write(u'''</table>
</div>
<div id="editTimerForm" title="''')
            _v = VFFSL(SL,"tstrings",True)['edit_timer'] # u"$tstrings['edit_timer']" on line 139, col 32
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['edit_timer']")) # from line 139, col 32.
            write(u'''"></div>
</body>
<script type="text/javascript">
var t = [
''')
            for timer in VFFSL(SL,"timers",True): # generated from line 143, col 1
                write(u"""\t{'begin':""")
                _v = VFFSL(SL,"timer.begin",True) # u'$timer.begin' on line 144, col 11
                if _v is not None: write(_filter(_v, rawExpr=u'$timer.begin')) # from line 144, col 11.
                write(u""",'end':""")
                _v = VFFSL(SL,"timer.end",True) # u'$timer.end' on line 144, col 30
                if _v is not None: write(_filter(_v, rawExpr=u'$timer.end')) # from line 144, col 30.
                write(u""",'sref':'""")
                _v = VFFSL(SL,"timer.serviceref",True) # u'$timer.serviceref' on line 144, col 49
                if _v is not None: write(_filter(_v, rawExpr=u'$timer.serviceref')) # from line 144, col 49.
                write(u"""'},
""")
            write(u'''];
var reloadTimers = true;
$(function() {
\t$(\'#editTimerForm\').load(\'ajax/edittimer\');
\tif (t.length > 0) {
\t\tvar x = $(".ETV tbody");
\t\tif (x != undefined)
\t\t\tShowTimers(t);
\t}
});

$(function() {
\t$(".ui-dialog").css({position: \'fixed\',top:\'10\'});
\t$(document).scroll(function (e) {
// FIXME !!
//\t\tif ($(".ui-widget-overlay"))
//\t\t{
//\t\t\t$(".ui-widget-overlay").css({ position: \'fixed\',top: \'0\'});
//\t\t\t$(".ui-dialog").css({position: \'fixed\',top: $(window).scrollTop()});
//\t\t}
\t});
});

</script>
</html>
''')
        
        ########################################
        ## END - generated method body
        
        return _dummyTrans and trans.response().getvalue() or ""
        
    ##################################################
    ## CHEETAH GENERATED ATTRIBUTES


    _CHEETAH__instanceInitialized = False

    _CHEETAH_version = __CHEETAH_version__

    _CHEETAH_versionTuple = __CHEETAH_versionTuple__

    _CHEETAH_genTime = __CHEETAH_genTime__

    _CHEETAH_genTimestamp = __CHEETAH_genTimestamp__

    _CHEETAH_src = __CHEETAH_src__

    _CHEETAH_srcLastModified = __CHEETAH_srcLastModified__

    _mainCheetahMethod_for_epgpop= 'respond'

## END CLASS DEFINITION

if not hasattr(epgpop, '_initCheetahAttributes'):
    templateAPIClass = getattr(epgpop, '_CHEETAH_templateClass', Template)
    templateAPIClass._addCheetahPlumbingCodeToClass(epgpop)


# CHEETAH was developed by Tavis Rudd and Mike Orr
# with code, advice and input from many other volunteers.
# For more information visit http://www.CheetahTemplate.org/

##################################################
## if run from command line:
if __name__ == '__main__':
    from Cheetah.TemplateCmdLineIface import CmdLineIface
    CmdLineIface(templateObj=epgpop()).run()


