<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      eventCookie="@@@eventCookie@@@" dtvPlatform="@@@dtvPlatform@@@">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <link href="resource:css/main.css" rel="stylesheet" type="text/css" />
    <t:include filename="dynamic.js" />
    <t:include filename="settings.js" />
    <script type="text/javascript" src="resource:templates/osxdnd.js" />

    <t:execOnLoad><![CDATA[
sorts.switchUnwatchedFirstChannel(None)

global searchFilter

searchFilter = lambda x: filters.matchingItems(x, None)

matchingItems = views.newWatchableItems.filter(lambda x:searchFilter(x) and x.getFeedURL() != "dtv:singleFeed",sortFunc=sorts.itemSortNew.sort, resort=True)

def updateSearchString(newSearch):
    global searchFilter
    if len(newSearch) == 0:
        searchFilter = lambda x: filters.matchingItems(x, None)
    else:
        searchFilter = lambda x: filters.matchingItems(x, newSearch)
    views.newWatchableItems.recomputeFilter(matchingItems)

def setSortBy(by, section, handle):
    sorts.itemSortNew.setSortBy(by)
    views.newWatchableItems.recomputeSort(matchingItems)
    handle.forceUpdate()
]]>
    </t:execOnLoad>
    <t:execOnUnload><![CDATA[
matchingItems.unlink()
]]>
    </t:execOnUnload>

</head>

<body onkeydown="sendKeyToSearchBox(event);">

<!-- TITLE BAR ************************************************************ -->
<div id="main-titlebar">
    <div id="main-icon" class="noborder"><img src="resource:images/newvideos-icon.png" /></div>
    <h1 id="main-title" i18n:translate="">New</h1>
    <div id="search-box-container">
        <input id="search-box" type="search" onfocus="onSearchFocus(this)" onblur="endEditSearch()" value="***_('Find')***"/>
    </div>
</div>
<!-- / TITLE BAR -->

<div id="main-container">
    <div t:updateForView="matchingItems">
        <div t:hideIf="matchingItems.len() == 0">
            <t:executeTemplate filename="static-tab-sort-bar" 
                itemSort="sorts.itemSortNew"
                section="'main'" />
        </div>
    </div>
    <div id="main-unwatched">
        <div t:repeatForView="matchingItems" t:repeatTemplate='download-item' t:containerDiv="true" />
    </div>	
</div>

</body>
</html>
