#!/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 time import localtime, strftime
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__ = 1644596121.023216
__CHEETAH_genTimestamp__ = 'Fri Feb 11 16:15:21 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/timers.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 timers(Template):

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


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

        super(timers, 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
        
        _orig_filter_22434861 = _filter
        filterName = u'WebSafe'
        if self._CHEETAH__filters.has_key("WebSafe"):
            _filter = self._CHEETAH__currentFilter = self._CHEETAH__filters[filterName]
        else:
            _filter = self._CHEETAH__currentFilter = \
			self._CHEETAH__filters[filterName] = getattr(self._CHEETAH__filtersLib, filterName)(self).filter
        write(u'''<div id="content_main" class="ui-widget-content" style="min-height: 500px;">
\t<div id="tvcontentmain">
\t\t<div id="toolbar-header" class="ui-widget-header">
\t\t<div style=display:inline-block;float:left;>
\t\t\t<select id="timersort">
''')
        count = 0
        da = VFFSL(SL,"tstrings",True)['date']
        na = VFFSL(SL,"tstrings",True)['name']
        sortnames = [VFFSL(SL,"na",True),VFFSL(SL,"na",True),VFFSL(SL,"da",True),VFFSL(SL,"da",True)]
        sorttypes = ['name','named','date','dated']
        sortimg = ['fa-sort-alpha-asc','fa-sort-alpha-desc','fa-sort-numeric-asc','fa-sort-numeric-desc']
        sort = VFFSL(SL,"getVar",False)('sort', 'dated')
        for title in VFFSL(SL,"sortnames",True): # generated from line 17, col 4
            write(u'''\t\t\t\t<option value="''')
            _v = VFFSL(SL,"sorttypes",True)[VFFSL(SL,"count",True)] # u'$sorttypes[$count]' on line 18, col 20
            if _v is not None: write(_filter(_v, rawExpr=u'$sorttypes[$count]')) # from line 18, col 20.
            write(u'''"
''')
            if VFFSL(SL,"sorttypes",True)[VFFSL(SL,"count",True)] == VFFSL(SL,"sort",True): # generated from line 19, col 5
                write(u'''\t\t\t\t\tselected="selected"
''')
            write(u'''\t\t\t\t data-class="''')
            _v = VFFSL(SL,"sortimg",True)[VFFSL(SL,"count",True)] # u'$sortimg[$count]' on line 22, col 18
            if _v is not None: write(_filter(_v, rawExpr=u'$sortimg[$count]')) # from line 22, col 18.
            write(u'''">''')
            _v = VFFSL(SL,"title",True) # u'$title' on line 22, col 36
            if _v is not None: write(_filter(_v, rawExpr=u'$title')) # from line 22, col 36.
            write(u'''</option>
''')
            count += 1
        write(u'''\t\t</select>
\t\t</div>
\t\t\t<span id="toolbar">
\t\t\t\t<span id="timerbuttons">
\t\t\t\t\t<button id="timerbutton0" onclick="addTimer(); return false">''')
        _v = VFFSL(SL,"tstrings",True)['add_timer'] # u"$tstrings['add_timer']" on line 29, col 67
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['add_timer']")) # from line 29, col 67.
        write(u'''</button>
\t\t\t\t\t<button id="timerbutton1" onclick="cleanupTimer(); return false">''')
        _v = VFFSL(SL,"tstrings",True)['cleanup_timer'] # u"$tstrings['cleanup_timer']" on line 30, col 71
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['cleanup_timer']")) # from line 30, col 71.
        write(u'''</button>
\t\t\t\t\t<button id="timerbutton2" onclick="lastcontenturl=\'\';load_maincontent(\'ajax/timers?sort=''')
        _v = VFFSL(SL,"sort",True) # u'$sort' on line 31, col 94
        if _v is not None: write(_filter(_v, rawExpr=u'$sort')) # from line 31, col 94.
        write(u'''\'); return false;">''')
        _v = VFFSL(SL,"tstrings",True)['refresh_timer'] # u"$tstrings['refresh_timer']" on line 31, col 118
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['refresh_timer']")) # from line 31, col 118.
        write(u'''</button>
\t\t\t\t</span>
\t\t\t</span>
\t\t</div>

\t\t<div id="timers">
''')
        for timer in VFFSL(SL,"timers",True): # generated from line 37, col 3
            write(u'''\t\t\t<div class="tm_row ui-widget-content ui-state-default" id="''')
            _v = VFFSL(SL,"timer.begin",True) # u'$timer.begin' on line 38, col 63
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.begin')) # from line 38, col 63.
            write(u'''-''')
            _v = VFFSL(SL,"timer.end",True) # u'$timer.end' on line 38, col 76
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.end')) # from line 38, col 76.
            write(u'''">
\t\t\t\t<div class="t_buttons tm_buttons">
\t\t\t\t\t\t<div>
''')
            sref = quote(VFFSL(SL,"timer.serviceref",True), safe=' ~@#$&()*!+=:;,.?/\'')
            tname = quote(VFFSL(SL,"timer.name",True))
            write(u'''\t\t\t\t\t\t<a href=\'#\' onclick="editTimer(\'''')
            _v = VFFSL(SL,"sref",True) # u'$sref' on line 43, col 39
            if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 43, col 39.
            write(u"""', '""")
            _v = VFFSL(SL,"timer.begin",True) # u'$timer.begin' on line 43, col 48
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.begin')) # from line 43, col 48.
            write(u"""', '""")
            _v = VFFSL(SL,"timer.end",True) # u'$timer.end' on line 43, col 64
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.end')) # from line 43, col 64.
            write(u'''\');" title="''')
            _v = VFFSL(SL,"tstrings",True)['edit_timer'] # u"$tstrings['edit_timer']" on line 43, col 86
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['edit_timer']")) # from line 43, col 86.
            write(u'''"><div><i class="fa fa-edit"></i></div></a>
\t\t\t\t\t\t<a href=\'#\' onclick="deleteTimer(\'''')
            _v = VFFSL(SL,"sref",True) # u'$sref' on line 44, col 41
            if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 44, col 41.
            write(u"""', '""")
            _v = VFFSL(SL,"timer.begin",True) # u'$timer.begin' on line 44, col 50
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.begin')) # from line 44, col 50.
            write(u"""', '""")
            _v = VFFSL(SL,"timer.end",True) # u'$timer.end' on line 44, col 66
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.end')) # from line 44, col 66.
            write(u"""', '""")
            _v = VFFSL(SL,"tname",True) # u'$tname' on line 44, col 80
            if _v is not None: write(_filter(_v, rawExpr=u'$tname')) # from line 44, col 80.
            write(u'''\');" title="''')
            _v = VFFSL(SL,"tstrings",True)['delete_timer'] # u"$tstrings['delete_timer']" on line 44, col 98
            if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['delete_timer']")) # from line 44, col 98.
            write(u'''"><div><i class="fa fa-trash-o"></i></div></a>
\t\t\t\t\t\t<a href=\'#\' onclick="toggleTimerStatus(\'''')
            _v = VFFSL(SL,"sref",True) # u'$sref' on line 45, col 47
            if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 45, col 47.
            write(u"""', '""")
            _v = VFFSL(SL,"timer.begin",True) # u'$timer.begin' on line 45, col 56
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.begin')) # from line 45, col 56.
            write(u"""', '""")
            _v = VFFSL(SL,"timer.end",True) # u'$timer.end' on line 45, col 72
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.end')) # from line 45, col 72.
            write(u'''\');" 
''')
            if VFFSL(SL,"timer.disabled",True): # generated from line 46, col 7
                write(u'''\t\t\t\t\t\ttitle="''')
                _v = VFFSL(SL,"tstrings",True)['enable_timer'] # u"$tstrings['enable_timer']" on line 47, col 14
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['enable_timer']")) # from line 47, col 14.
                write(u'''"><div id=\'img-''')
                _v = VFFSL(SL,"timer.begin",True) # u'$timer.begin' on line 47, col 54
                if _v is not None: write(_filter(_v, rawExpr=u'$timer.begin')) # from line 47, col 54.
                write(u'''-''')
                _v = VFFSL(SL,"timer.end",True) # u'$timer.end' on line 47, col 67
                if _v is not None: write(_filter(_v, rawExpr=u'$timer.end')) # from line 47, col 67.
                write(u'''\'><i data-ref="''')
                _v = VFFSL(SL,"sref",True) # u'$sref' on line 47, col 92
                if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 47, col 92.
                write(u'''" class="fa fa-square-o">
''')
            else: # generated from line 48, col 7
                write(u'''\t\t\t\t\t\ttitle="''')
                _v = VFFSL(SL,"tstrings",True)['disable_timer'] # u"$tstrings['disable_timer']" on line 49, col 14
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['disable_timer']")) # from line 49, col 14.
                write(u'''"><div id=\'img-''')
                _v = VFFSL(SL,"timer.begin",True) # u'$timer.begin' on line 49, col 55
                if _v is not None: write(_filter(_v, rawExpr=u'$timer.begin')) # from line 49, col 55.
                write(u'''-''')
                _v = VFFSL(SL,"timer.end",True) # u'$timer.end' on line 49, col 68
                if _v is not None: write(_filter(_v, rawExpr=u'$timer.end')) # from line 49, col 68.
                write(u'''\'><i data-ref="''')
                _v = VFFSL(SL,"sref",True) # u'$sref' on line 49, col 93
                if _v is not None: write(_filter(_v, rawExpr=u'$sref')) # from line 49, col 93.
                write(u'''" class="fa fa-check-square-o">
''')
            write(u'''\t\t\t\t\t\t</i></div></a>
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t<div class="tm_text">
\t\t\t\t\t<div>
\t\t\t\t\t\t<div class="tm_title">
\t\t\t\t\t\t\t''')
            _v = VFFSL(SL,"timer.name",True) # u'$timer.name' on line 57, col 8
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.name')) # from line 57, col 8.
            write(u'''
\t\t\t\t\t\t</div>
\t\t\t\t\t\t''')
            _v = VFFSL(SL,"tstrings",True)[("day_" + (time.strftime("%w", time.localtime(VFFSL(SL,"timer.begin",True)))))] # u'$tstrings[("day_" + (time.strftime("%w", time.localtime($timer.begin))))]' on line 59, col 7
            if _v is not None: write(_filter(_v, rawExpr=u'$tstrings[("day_" + (time.strftime("%w", time.localtime($timer.begin))))]')) # from line 59, col 7.
            write(u'''
\t\t\t\t\t\t''')
            _v = VFFSL(SL,"timer.realbegin",True) # u'$timer.realbegin' on line 60, col 7
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.realbegin')) # from line 60, col 7.
            write(u''' - ''')
            _v = VFFSL(SL,"timer.realend",True) # u'$timer.realend' on line 60, col 26
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.realend')) # from line 60, col 26.
            write(u'''
''')
            if VFFSL(SL,"timer.repeated",True) != 0: # generated from line 61, col 7
                write(u'''\t\t\t\t\t\t\t<div>
\t\t\t\t\t\t\t\t''')
                _v = VFFSL(SL,"tstrings",True)['every_timer'] # u"$tstrings['every_timer']" on line 63, col 9
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['every_timer']")) # from line 63, col 9.
                write(u'''
''')
                flags = VFFSL(SL,"timer.repeated",True)
                timerDays = []
                for day in [VFFSL(SL,"tstrings",True)['monday'],VFFSL(SL,"tstrings",True)['tuesday'],VFFSL(SL,"tstrings",True)['wednesday'],VFFSL(SL,"tstrings",True)['thursday'],VFFSL(SL,"tstrings",True)['friday'],VFFSL(SL,"tstrings",True)['saturday'],VFFSL(SL,"tstrings",True)['sunday']]: # generated from line 66, col 8
                    if VFFSL(SL,"flags",True)&1: # generated from line 67, col 9
                        write(u'''\t\t\t\t\t\t\t\t\t''')
                        _v = VFN(VFFSL(SL,"timerDays",True),"append",False)(VFFSL(SL,"day",True)) # u'$timerDays.append($day)' on line 68, col 10
                        if _v is not None: write(_filter(_v, rawExpr=u'$timerDays.append($day)')) # from line 68, col 10.
                        write(u'''
''')
                    flags = VFFSL(SL,"flags",True) >> 1
                _v = ', '.join(VFFSL(SL,"timerDays",True))
                if _v is not None: write(_filter(_v))
                write(u'''\t\t\t\t\t\t\t</div>
''')
            write(u'''\t\t\t\t\t\t<div style="font-weight: bold;">
\t\t\t\t\t\t\t''')
            _v = VFFSL(SL,"timer.servicename",True) # u'$timer.servicename' on line 76, col 8
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.servicename')) # from line 76, col 8.
            write(u'''
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t\t<div>
\t\t\t\t\t\t''')
            _v = VFFSL(SL,"timer.description",True) # u'$timer.description' on line 80, col 7
            if _v is not None: write(_filter(_v, rawExpr=u'$timer.description')) # from line 80, col 7.
            write(u'''
\t\t\t\t\t</div>
\t\t\t\t\t<div>
\t\t\t\t\t\t<span class="tm_desc" style="font-weight: bold;">
''')
            if VFFSL(SL,"timer.disabled",True): # generated from line 84, col 8
                write(u'''\t\t\t\t\t\t\t\t''')
                _v = VFFSL(SL,"tstrings",True)['disabled'] # u"$tstrings['disabled']" on line 85, col 9
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['disabled']")) # from line 85, col 9.
                write(u'''
''')
            elif VFFSL(SL,"timer.state",True) == 0: # generated from line 86, col 8
                write(u'''\t\t\t\t\t\t\t\t''')
                _v = VFFSL(SL,"tstrings",True)['waiting'] # u"$tstrings['waiting']" on line 87, col 9
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['waiting']")) # from line 87, col 9.
                write(u'''
''')
            elif VFFSL(SL,"timer.state",True) == 2: # generated from line 88, col 8
                write(u'''\t\t\t\t\t\t\t\t''')
                _v = VFFSL(SL,"tstrings",True)['running'] # u"$tstrings['running']" on line 89, col 9
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['running']")) # from line 89, col 9.
                write(u'''
''')
            elif VFFSL(SL,"timer.state",True) == 3: # generated from line 90, col 8
                write(u'''\t\t\t\t\t\t\t\t''')
                _v = VFFSL(SL,"tstrings",True)['finished'] # u"$tstrings['finished']" on line 91, col 9
                if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['finished']")) # from line 91, col 9.
                write(u'''
''')
            write(u'''\t\t\t\t\t\t</span>
\t\t\t\t\t</div>
\t\t\t\t</div>
\t\t\t\t<div style="clear: both;"></div>
\t\t\t</div>
''')
        write(u'''\t\t</div>
\t</div>
</div>
<script type="text/javascript">
var reloadTimers = true;
$(function() {
\tsetTMHover();
\t$(\'#timerbuttons\').buttonset();
\tif(!timeredit_initialized)
\t\t$(\'#editTimerForm\').load(\'ajax/edittimer\');
\t$(\'#timers\').scroll(function() {
\t\tSetLSValue(\'TimerListOffset\',$(\'#timers\').scrollTop());
\t});
\t$(\'#timers\').scrollTop(GetLSValue(\'TimerListOffset\',0));
\t
\t$.widget( "custom.iconselectmenu", $.ui.selectmenu, {
\t\t_renderItem: function( ul, item ) {
\t\t\tvar li = $( "<li>" ),
\t\t\twrapper = $( "<div>",{ text: item.label } ).prepend (
\t\t\t$( "<span class=\'sortimg\'>").append (
\t\t\t\t$( "<i>", { "class": "fa " + item.element.data("class") })
\t\t\t\t)
\t\t\t);
\t\t\treturn li.append( wrapper ).appendTo( ul );
\t\t\t}
\t\t});

\t\t$("#timersort").iconselectmenu({change: function(event, ui) {
\t\t\tload_maincontent(\'ajax/timers?sort=\' + ui.item.value);
\t\t}
\t}).addClass("ui-menu-icons");
\t
\t$("#timersort option").each(function()
\t{
\t\tvar simg=\'\';
\t\tif( $(this).val() == $( "#timersort" ).val() )
\t\t{
\t\t\tsimg=$(this).data("class");
\t\t\tif (simg) {
\t\t\t\tvar img = $( "<span class=\'sortimg\'>").append (
\t\t\t\t\t$( "<i>", { "class": "fa " + simg })
\t\t\t\t\t);
\t\t\t\t$("#timersort-button .ui-selectmenu-text").prepend(img);
\t\t\t}
\t\t}
\t});
});
</script>
''')
        _filter = self._CHEETAH__currentFilter = _orig_filter_22434861
        
        ########################################
        ## 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_timers= 'respond'

## END CLASS DEFINITION

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


# 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=timers()).run()


