@model List<LuceneNet.Models.Books>
@{
    ViewBag.Title = "Find";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h3>关键字 @ViewBag.SearchWord 搜索结果</h3>
<div id="page">
    @if (Model != null && Model.Count > 0)
    {
        string[] num = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
        <ol class="round">
            @for (int i = 0; i < 9; i++)
            {
                <li class="@num[i]">
                    <h5>@Model[i].Title</h5>
                    @Html.Raw(Model[i].ContentDescription)
                    <a href="#@Model[i].Id">Learn more…</a>
                </li>
            }
        </ol>


        <div>
            <div class="pager-container">
                <ul>
                    @if (ViewBag.NowPages > 1)
                    {
                        <li class="prev"><a href="/Home/Find?q=@ViewBag.SearchWord&p=@(ViewBag.NowPages - 1)">&larr; 上一页</a></li>
                    }
                    else
                    {
                        <li class="prev" style="visibility:hidden"><a href="">&larr; 上一页</a></li>
                    }
                    @{
                    int begin = ViewBag.NowPages - 2 > 0 ? ViewBag.NowPages - 2 : 1;
                    int end = ViewBag.NowPages + 2 > ViewBag.TotalPages ? ViewBag.TotalPages : ViewBag.NowPages + 2;
                    for (int i = begin; i <= end; i++)
                    {
                        if (i == ViewBag.NowPages)
                        {
                            <li class="current"><a>@i</a></li>
                        }
                        else
                        {
                            <li><a href="/Home/Find?q=@ViewBag.SearchWord&p=@i">@i</a></li>
                        }
                    }
                    }

                    @if (ViewBag.NowPages < ViewBag.TotalPages)
                    {
                        <li class="next"><a href="/Home/Find?q=@ViewBag.SearchWord&p=@(ViewBag.NowPages + 1)">下一页 &rarr;</a></li>
                    }
                    else
                    {
                        <li class="next" style="visibility:hidden"><a href="#">下一页 &rarr;</a></li>
                    }
                </ul>
            </div>
        </div>
    }
</div>
<script>
    function but(i) {
        var q = @ViewBag.SearchWord;
        if (i > 0) {
            $('#page').load('@Url.Action("Ajax","Home")', { q:q,p:i });
        }
    }
</script>
