<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page import="com.lightinit.hsdataportal.dictionary.DicResourceType" %>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String basePath = request.getContextPath();
    String resourcePath = basePath + "/resource";
%>
<%
    String searchName = "";
    String paramSearchNameStr = request.getParameter("searchName");
    if (StringUtils.isNotEmpty(paramSearchNameStr)){
        searchName = paramSearchNameStr;
    }
%>
<%@ page isELIgnored="false" %>
<div class="top0">
    <div class="top-main1">
        <div class="top1-1">
            <a href="<%=basePath%>/"><img src="<%=resourcePath%>/images/logo.png" class="top1-1img"></a>
        </div>
        <div class="top2">
            <a href="#" style="color:#0f51b2;font-size: 16px;position: absolute;right: -16px;top: 58px" onclick="showGj()">高级搜索</a>
            <input type="text" id="searchName" name="searchName" placeholder="请输入您要搜索的内容" class="top2-1" value="<%=searchName%>"><button onclick="searchName()" class="top2-2">搜索</button>
            <p id="hot" class="top2-3">
                <c:if test="${tagsSearch.tags.size()>0}">
                    <c:forEach items="${tagsSearch.tags}" var="item" varStatus="status">
                        <a class="a1" >${item.catelogName}</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                    </c:forEach>
                </c:if>
            </p>
        </div>
        <div class="shangwuhezuo">
            <img src="<%=resourcePath%>/images/icon_swhz.png" class="shangwuhezuo-img">
            <span> 商务合作：0318-2316090</span>
        </div>
        <div class="clearfix"></div>
    </div>
</div>

<div class="fade" id="gaojiSearch" style="display: none">
    <div class="window" >
        <div class="top00">
            <span class="p">高级搜索</span>
            <img src="<%=resourcePath%>/images/icon_guanbi.png" alt="关闭" class="guanbi" onclick="closeGj()" >
        </div>
        <div class="form" style="padding-top:12px">
            <form id="gjFrom">
                <div class="application-font-0">
                    <span class="application-font-2"><span class="xinghao"></span>资源名称：</span>
                    <input type="text" class="area4" id="resourceName" name="resourceName" placeholder="请输入资源名称">
                    <div class="tishi4"></div>
                </div>
                <div class="application-font-0">
                    <span class="application-font-2"><span class="xinghao"></span>资源类型：</span>
                    <select name="resourceType" id="resourceType" style="width: 342px;height:30px;margin-left:96px;margin-top:14px;border:solid 1px #dcdfe5">
                                <option value="">全部</option>
                                <option value="<%=DicResourceType.API%>"><%=DicResourceType.API%></option>
                                <option value="<%=DicResourceType.DATA%>"><%=DicResourceType.DATA%></option>
                                <option value="<%=DicResourceType.MICROAPP%>"><%=DicResourceType.MICROAPP%></option>
                    </select>
                    <div class="tishi4"></div>
                </div>
                <div class="application-font-0">
                    <span class="application-font-2"><span class="xinghao"></span>服务标识：</span>
                    <input type="text" class="area4" id="resourceIdentity" name="resourceIdentity" placeholder="请输入服务标识">
                    <div class="tishi4"></div>
                </div>
                <div class="application-font-0">
                    <span class="application-font-2"><span class="xinghao"></span>主题：</span>
                    <select name="catelogTheme" id="catelogTheme" style="width: 342px;height:30px;margin-left:96px;margin-top:14px;border:solid 1px #dcdfe5">
                    </select>
                    <div class="tishi4"></div>
                </div>
                <div class="application-font-0">
                    <span class="application-font-2"><span class="xinghao"></span>部门：</span>
                    <select name="catelogSector" id="catelogSector" style="width: 342px;height:30px;margin-left:96px;margin-top:14px;border:solid 1px #dcdfe5">
                    </select>
                    <div class="tishi4"></div>
                </div>
                <div class="application-font-0">
                    <span class="application-font-2"><span class="xinghao"></span>标签：</span>
                    <input type="text" class="area4" id="serviceTag" name="serviceTag" placeholder="请输入标签">
                    <div class="tishi4"></div>
                </div>
                <div class="clearfix"></div>
                <div class="queding0">
                    <span class="quxiao" onclick="closeGj()">取消</span>
                    <span class="queding" onclick="gjSearch()">确定</span>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $.ajax({
            url:"<%=basePath%>/open/getThemes.action",
            type:"post",
            success:function (msg) {
                $("#catelogTheme").empty() ;
                $("#catelogTheme").append('<option value="0">全部</option>') ;
               if (msg.length>0){
                    for (var i =0;i<msg.length;i++){
                        $("#catelogTheme").append("<option value='"+msg[i].id+"'>"+msg[i].catelogName+"</option>") ;
                    }
               }
            }
        })

        $.ajax({
            url:"<%=basePath%>/open/getDepts.action",
            type:"post",
            success:function (msg) {
                $("#catelogSector").empty() ;
                $("#catelogSector").append('<option value="0">全部</option>') ;
                if (msg.length>0){
                    for (var i =0;i<msg.length;i++){
                        $("#catelogSector").append("<option value='"+msg[i].id+"'>"+msg[i].catelogName+"</option>") ;
                    }
                }
            }
        })
    }) ;
    function searchName() {
        var searchName = "" ;
        if($("#searchName").val()!=null&&$("#searchName").val()!=undefined&&$("#searchName").val()!=""){
            searchName = "?searchName="+$("#searchName").val() ;
            window.location.href="<%=basePath%>/open/"+searchName ;
        }
    }
    $("#hot a").click(function () {
        $("#searchName").val($(this).text());
        searchName();
    });

    function showGj() {
        $("#gaojiSearch").show() ;
    }

    function closeGj() {
        $("#gaojiSearch").hide() ;
    }

    function gjSearch(){


        window.location.href = "<%=basePath%>/open/advancedSearch.htm?resourceName="+$("#resourceName").val()+
                "&resourceType="+$("#resourceType").val()+
                "&resourceIdentity="+$("#resourceIdentity").val()+
                "&catelogTheme="+$("#catelogTheme").val()+
                "&catelogSector="+$("#catelogSector").val()+
                "&serviceTag="+$("#serviceTag").val() ;


    }

</script>