<?php defined('PHPNEW_STATIC_TPL') === false && exit(URL_HOST);?>
{template header}
<script type="text/javascript">
    var search,searchs,types;
    var keys = '{$keys}';
    $(function (){
        if(keys){
            get_search_data(keys, 0);
        }
    })
    function get_search_data(search, types){
        if(!search){
            search = encodeURIComponent($('input[name="searchs"]').val());
            types  = $('select[name="types"]').find(':selected').val();
        }else{
            search = encodeURIComponent(search);
        }
        if(searchs == search){
            //$('.setr td').text('<span style="color:red"> 抱歉, 搜索并无结果 </span>'); 
            return false;
        }else{
            searchs = search;
        }
        
        $('.setr').remove();
        $('table').show();
        $('table').append('<tr class="setr"><td colspan="10" style="text-align: center;">请稍等, 结果正在处理..</td></tr>');
        
        $.getJSON('./index.php?search=ajax&searchs='+search+'&types='+types,function(data){
            if(!data){
               $('.setr td').html('<span style="color:red"> 抱歉, 本次搜索无结果 </span>');
            }
            $.each(data,function (idx,item){
                if(idx == 0)
                    $('.setr').remove();
                search = '';
                search += '<td>'+item['thread_view']+'</td>';
                search += '<td>'+item['thread_fid']+'</td>';
                search += '<td><a href="'+item['thread_link']+'" target="_blank">'+item['thread_title']+'</a></td>';
                search += '<td>'+item['thread_state']+'</td>';
                search += '<td>'+item['thread_date']+'</td>';
                search = '<tr class="setr">'+search+'</tr>';
                $('table').append(search);
            })
        });
    }
</script>
<style type="text/css">
    th{background-color: #0080FF; color: white; text-align: left;}
    td,th{border: 1px solid silver; padding: 3px; line-height: 25px; height: 25px;}
</style>
<div style="line-height: 28px; height: 28px; margin-left: 10px;"> <a href="./index.php">首页</a> &raquo; <a href="./index.php?search=index.html">搜索</a> {$datekeystr}</div>
<br />
<div style="text-align: center; margin: 10px;">
        <select name="types" style="border: 2px solid silver; padding: 1px;">
        <option value="0">所有栏目</option>
        <!--{loop $cat_array $key $val}-->
            <option value="{$val[c_id]}">{$val[c_name]}</option>
        <!--{/loop}-->
        </select>
<input type="text" accept="1" name="searchs" value="{$keys}" style="border: 2px solid silver; padding: 2px;" title="支持搜索标题" /> <input type="submit" onclick="get_search_data()" value="搜索" /></div>
<br />
<div style="margin: 10px;">
<table style="width: 100%; display: none;">
    <tr>
        <th>阅读</th>
        <th>栏目</th>
        <th>主题标题</th>
        <th>主题状态</th>
        <th>发表时间</th>
    </tr>
</table></div>
<br />
{template footer}