<%@ Page Language="C#" AutoEventWireup="true" Inherits="PowerEasy.Module.General.WebSite.User.Accessories.KeyWordList"
    CodeBehind="KeyWordList.aspx.cs" %>

<!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">
<head runat="server">
    <title>关键字列表</title>
    <base target="_self" />
</head>
<form id="MainForm" runat="server">
<% keywordInput = Request.QueryString["BackControlId"];%>
<div style="text-align: center">
    <table width="99%" border="0" cellpadding="2" cellspacing="0" class="model_info_table">
        <tr class="model_info_title" style="height: 22">
            <td valign="top" colspan="2">
                <b>
                    <asp:localize id="Localize1" text="<%$ Res: User_Accessories_KeyWordList_Localize1,已经选定的关键字： %>"
                        runat="server" />
                </b>
            </td>
        </tr>
        <tr class="listbg1">
            <td>
                <input type="text" id="KeyList" size="60" maxlength="200" readonly="readonly" class="inputxt" />
            </td>
            <td align="center">
                <input type="button" runat="server" name="del1" class="input_button" onclick="del(1)"
                    value="<%$ Res: User_Accessories_KeyWordList_del1,删除最后 %>" />
                <input type="button" runat="server" name="del2" class="input_button" onclick="del(0)"
                    value="<%$ Res: User_Accessories_KeyWordList_del2,删除全部 %>" />
            </td>
        </tr>
    </table>
    <br />
    <table width="99%" border="0" cellpadding="2" cellspacing="0" class="model_info_table">
        <tr class="model_info_title">
            <td>
                <b><font color="red"></font>
                    <asp:localize id="Localize2" text="<%$ Res: User_Accessories_KeyWordList_Localize2,列表： %>"
                        runat="server" />
                </b>
            </td>
            <td align="right">
                <asp:textbox id="TxtKeyWord" cssclass="inputxt" runat="server"></asp:textbox>
                &nbsp;&nbsp;<asp:button id="BtnSearch" runat="server" cssclass="input_button" text="<%$ Res: User_Accessories_KeyWordList_BtnSearch,查找 %>" />
            </td>
        </tr>
        <tr class="listbg1">
            <td valign="top" colspan="2" class="model_info_bottom">
                <asp:repeater id="RepKeyWords" runat="server" onitemdatabound="RepKeyWords_ItemDataBound">
                        <HeaderTemplate>
                            <table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#f9f9f9">
                                <tr>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <td align="center">
                                <span onclick="<%# "add('" + Eval("KeywordText") + "')"%>" title='<%# Eval("KeywordText").ToString()%>'
                                    style="cursor:pointer;">
                                    <%# Eval("KeywordText").ToString().Length < 6 ? Eval("KeywordText").ToString() : Eval("KeywordText").ToString().Substring(0, 6) + "..." %>
                                </span>
                            </td>
                           <% 
                            i++;
                            if (i == pagerecordCount)
                            {
                                for (int k = 0; k < missingCount; k++)
                                {
                        %>
                        <td>
                        </td>
                        <%}
                            }%>
                            <% if (i % 5 == 0 && i > 1)
                               {%>
        </tr>
        <tr>
            <%} %>
            </ItemTemplate>
            <footertemplate>
        </tr>
    </table>
    </FooterTemplate> </asp:Repeater> </td> </tr>
    <tr class="listbg1">
        <td align="center" colspan="2">
            <a href="javascript:" onclick="add('<%=allKeyword %>')">
                <asp:localize id="Localize4" text="<%$ Res: User_Accessories_KeyWordList_Localize4,增加以上所有关键字 %>"
                    runat="server" />
            </a>
        </td>
    </tr>
    </table>
    <div class="user_page">
        <pe:AspNetPager ID="Pager" runat="server" SimplePager="true" OnPageChanged="Pager_PageChanged">
        </pe:AspNetPager>
    </div>
</div>

<script language="javascript" type="text/javascript">
    document.getElementById("KeyList").value = parent.document.getElementById("<%= keywordInput %>").value;
    function add(obj) {
        if (obj == "") { return false; }
        if (parent.document.getElementById("<%= keywordInput %>").value == "") {
            parent.document.getElementById("<%= keywordInput %>").value = obj;
            document.getElementById("KeyList").value = parent.document.getElementById("<%= keywordInput %>").value;
            return false;
        }
        var singleKey = obj.split(" ");
        var ignoreKey = "";
        for (i = 0; i < singleKey.length; i++) {
            if (checkKey(parent.document.getElementById("<%= keywordInput %>").value, singleKey[i])) {
                ignoreKey = ignoreKey + singleKey[i] + " ";
            }
            else {
                parent.document.getElementById("<%= keywordInput %>").value = parent.document.getElementById("<%= keywordInput %>").value + " " + singleKey[i];
                document.getElementById("KeyList").value = parent.document.getElementById("<%= keywordInput %>").value;
            }
        }
        if (ignoreKey != "") {
            alert(ignoreKey + "<%= Resources.DynamicPageResources.User_Accessories_KeyWordList_JSErr %>");
        }
    }
    function del(num) {
        if (num == 0 || parent.document.getElementById("<%= keywordInput %>").value == "" || parent.document.getElementById("<%= keywordInput %>").value == " ") {
            parent.document.getElementById("<%= keywordInput %>").value = "";
            document.getElementById("KeyList").value = "";
            return false;
        }

        var strDel = parent.document.getElementById("<%= keywordInput %>").value;
        var s = strDel.split(" ");
        parent.document.getElementById("<%= keywordInput %>").value = strDel.substring(0, strDel.length - s[s.length - 1].length - 1);
        document.getElementById("KeyList").value = parent.document.getElementById("<%= keywordInput %>").value;
    }

    function checkKey(Keylist, thisKey) {
        if (Keylist == thisKey) {
            return true;
        }
        else {
            var s = Keylist.split(" ");
            for (j = 0; j < s.length; j++) {
                if (s[j] == thisKey)
                    return true;
            }
            return false;
        }
    }
</script>

</form>
</body>
</html>
