#!/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 urllib import quote
from json import dumps
from Plugins.Extensions.OpenWebif.local 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__ = 1406885499.317004
__CHEETAH_genTimestamp__ = 'Fri Aug  1 18:31:39 2014'
__CHEETAH_src__ = '/home/wslee2/models/5-wo/force1plus/openpli3.0/build-force1plus/tmp/work/mips32el-oe-linux/enigma2-plugin-extensions-openwebif-1+git5+3c0c4fbdb28d7153bf2140459b553b3d5cdd4149-r0/git/plugin/controllers/views/ajax/event.tmpl'
__CHEETAH_srcLastModified__ = 'Fri Aug  1 18:30:05 2014'
__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 event(Template):

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


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

        super(event, 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
        
        etime = time.localtime(VFFSL(SL,"event",True)['begin'])
        channel = VFN(VFFSL(SL,"event",True)['channel'],"replace",False)("'", r"\'")
        write(u'''
<!-- Icons from: http://findicons.com/pack/1987/eico -->
<div id="leftmenu_main">
\t<div id="leftmenu_top" class="handle" style="cursor:move">''')
        _v = VFFSL(SL,"event",True)['channel'] # u"$event['channel']" on line 9, col 60
        if _v is not None: write(_filter(_v, rawExpr=u"$event['channel']")) # from line 9, col 60.
        write(u'''
\t\t<div id="leftmenu_expander_main" class="leftmenu_icon leftmenu_icon_collapse" onclick="$(\'#eventdescription\').hide(200)"></div>
\t</div>
\t<div id="leftmenu_container_main" style="padding:6px">
\t\t<div style="float:left; width:80px;">
\t\t\t<div id="station" style="background-color: #1c478e; padding:2px; width:75px; text-align:center; overflow:hidden">''')
        _v = VFFSL(SL,"event",True)['channel'] # u"$event['channel']" on line 14, col 117
        if _v is not None: write(_filter(_v, rawExpr=u"$event['channel']")) # from line 14, col 117.
        write(u'''</div>
\t\t\t<div style="background-color: #1c478e; color:#fff; width:79px; font-size:23px; margin-top: 5px; text-align:center">
\t\t\t\t''')
        _v = VFN(VFFSL(SL,"time",True),"strftime",False)("%H:%M", VFFSL(SL,"etime",True)) # u'$time.strftime("%H:%M", $etime)' on line 16, col 5
        if _v is not None: write(_filter(_v, rawExpr=u'$time.strftime("%H:%M", $etime)')) # from line 16, col 5.
        write(u'''<br/>
\t\t\t\t<span style="font-size:12px; color:#A9D1FA">''')
        _v = VFFSL(SL,"int",False)(VFFSL(SL,"event",True)['duration']/60) # u"$int($event['duration']/60)" on line 17, col 49
        if _v is not None: write(_filter(_v, rawExpr=u"$int($event['duration']/60)")) # from line 17, col 49.
        write(u''' min</span>
\t\t\t</div>

\t\t\t<div style="background-color: #1c478e; color:#fff; width:79px;margin:5px 0">
\t\t\t\t<div style="font-size:23px; text-align:center">''')
        _v = VFFSL(SL,"tstrings",True)[("day_" + (VFN(VFFSL(SL,"time",True),"strftime",False)("%w", VFFSL(SL,"etime",True))))] # u'$tstrings[("day_" + ($time.strftime("%w", $etime)))]' on line 21, col 52
        if _v is not None: write(_filter(_v, rawExpr=u'$tstrings[("day_" + ($time.strftime("%w", $etime)))]')) # from line 21, col 52.
        write(u'''</div>
\t\t\t\t<div style="color:#A9D1FA; text-align:center">''')
        _v = VFN(VFFSL(SL,"time",True),"strftime",False)("%d", VFFSL(SL,"etime",True)) # u'$time.strftime("%d", $etime)' on line 22, col 51
        if _v is not None: write(_filter(_v, rawExpr=u'$time.strftime("%d", $etime)')) # from line 22, col 51.
        write(u''' ''')
        _v = VFFSL(SL,"tstrings",True)[("month_" + (VFN(VFFSL(SL,"time",True),"strftime",False)("%m", VFFSL(SL,"etime",True))))] # u'$tstrings[("month_" + ($time.strftime("%m", $etime)))]' on line 22, col 80
        if _v is not None: write(_filter(_v, rawExpr=u'$tstrings[("month_" + ($time.strftime("%m", $etime)))]')) # from line 22, col 80.
        write(u'''</div>
\t\t\t</div>

\t\t\t<div>
\t\t\t    <img src="/images/ico_timer.png" alt="''')
        _v = VFFSL(SL,"tstrings",True)['add_timer'] # u"$tstrings['add_timer']" on line 26, col 46
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['add_timer']")) # from line 26, col 46.
        write(u'''" title="''')
        _v = VFFSL(SL,"tstrings",True)['add_timer'] # u"$tstrings['add_timer']" on line 26, col 77
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['add_timer']")) # from line 26, col 77.
        write(u'''" style="cursor:pointer" onclick="addTimer(theevent)" />
\t\t\t    <img src="/images/ico_zap.png" alt="Zap" title="''')
        _v = VFFSL(SL,"tstrings",True)['zap'] # u"$tstrings['zap']" on line 27, col 56
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['zap']")) # from line 27, col 56.
        write(u'''" style="cursor:pointer" onclick="zapChannel(\'''')
        _v = VFFSL(SL,"str",False)(VFFSL(SL,"event",True)['sref']) # u"$str($event['sref'])" on line 27, col 118
        if _v is not None: write(_filter(_v, rawExpr=u"$str($event['sref'])")) # from line 27, col 118.
        write(u"""', '""")
        _v = VFFSL(SL,"channel",True) # u'$channel' on line 27, col 142
        if _v is not None: write(_filter(_v, rawExpr=u'$channel')) # from line 27, col 142.
        write(u'''\')" />
\t\t\t\t<a href="/web/stream.m3u?ref=''')
        _v = VFFSL(SL,"quote",False)(VFFSL(SL,"event",True)['sref']) # u"$quote($event['sref'])" on line 28, col 34
        if _v is not None: write(_filter(_v, rawExpr=u"$quote($event['sref'])")) # from line 28, col 34.
        write(u'''&name=''')
        _v = VFFSL(SL,"quote",False)(VFFSL(SL,"event",True)['channel']) # u"$quote($event['channel'])" on line 28, col 62
        if _v is not None: write(_filter(_v, rawExpr=u"$quote($event['channel'])")) # from line 28, col 62.
        write(u'''" target="_blank"><img 
\t\t\t\t\tsrc="/images/ico_stream2.png" alt="Stream ''')
        _v = VFFSL(SL,"channel",True) # u'$channel' on line 29, col 48
        if _v is not None: write(_filter(_v, rawExpr=u'$channel')) # from line 29, col 48.
        write(u'''" title="''')
        _v = VFFSL(SL,"tstrings",True)['stream'] # u"$tstrings['stream']" on line 29, col 65
        if _v is not None: write(_filter(_v, rawExpr=u"$tstrings['stream']")) # from line 29, col 65.
        write(u''' ''')
        _v = VFFSL(SL,"channel",True) # u'$channel' on line 29, col 85
        if _v is not None: write(_filter(_v, rawExpr=u'$channel')) # from line 29, col 85.
        write(u'''" style="cursor:pointer" /></a>
\t\t\t</div>
\t\t</div>
\t\t<div style="float:left; width:250px; margin-left: 5px">
\t\t\t<div style="font-size: 13px; font-weight: bold">''')
        _v = VFFSL(SL,"event",True)['title'] # u"$event['title']" on line 33, col 52
        if _v is not None: write(_filter(_v, rawExpr=u"$event['title']")) # from line 33, col 52.
        write(u'''</div>
''')
        if VFFSL(SL,"event",True)['title'] != VFFSL(SL,"event",True)['shortdesc']: # generated from line 34, col 1
            write(u'''\t\t\t<div style="font-size: 12px; font-weight: bold">''')
            _v = VFFSL(SL,"event",True)['shortdesc'] # u"$event['shortdesc']" on line 35, col 52
            if _v is not None: write(_filter(_v, rawExpr=u"$event['shortdesc']")) # from line 35, col 52.
            write(u'''</div>
''')
        write(u'''\t\t\t<div style="max-height:400px; overflow:auto"><p>''')
        _v = VFN(VFFSL(SL,"event",True)['longdesc'],"replace",False)("\n","<br/>") # u'$(event[\'longdesc\'].replace("\\n","<br/>"))' on line 37, col 52
        if _v is not None: write(_filter(_v, rawExpr=u'$(event[\'longdesc\'].replace("\\n","<br/>"))')) # from line 37, col 52.
        write(u'''</p></div>
\t\t</div>
\t\t<div style="clear:left"></div>
\t</div>
</div>
<script>
var theevent = ''')
        _v = VFFSL(SL,"dumps",False)(VFFSL(SL,"event",True)) # u'$dumps($event)' on line 43, col 16
        if _v is not None: write(_filter(_v, rawExpr=u'$dumps($event)')) # from line 43, col 16.
        write(u''';
if (picons[theevent[\'channel\']])
\t$(\'#station\').html(\'<img src="\'+picons[theevent[\'channel\']]+\'" width="75" />\');
</script>
''')
        
        ########################################
        ## 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_event= 'respond'

## END CLASS DEFINITION

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


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


