<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Course.Course.GetYunVideo" Codebehind="GetYunVideo.aspx.cs" %>

<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.BLL" %>
<asp:Content ID="Content2" ContentPlaceHolderID="KSContent" Runat="Server">
<link href="/admin/images/style.css" rel="stylesheet" />

	<style type="text/css">
    .style-inner .style-inner-item{padding: 15px;border-radius: 10px;border: 1px solid #eee; box-sizing:border-box; cursor:pointer;}
    .style-inner .style-versions { text-align:left !important;display: block;font-size: 12px; color:#f46344;}
	.style-item-thumbnail{ width:100%; display:block; margin:10px 0;height: 180px;}
	.style-inner .article_title{color:#666; line-height:22px; height:44px; font-size:15px; overflow:hidden; margin-bottom:10px;}
    .table td, .table th { border:none;}
    .font_color{ color:#f46344 !important;}
	.style-inner ul{margin: 0 -1.66% 20px;}
	.style-inner ul:after{ content:''; clear:both;display: block;}
	.style-inner li{ float:left;width: 30%;margin: 0 1.66% 20px;}
	.paging-box a {border: #ccc 1px solid;padding: 6px 10px;margin: 0 3px;color: #5C5C5C;background-color: #fff;border-radius: 2px;}
	.paging-box .icon-prev,
	.paging-box .icon-next{height: 34px;padding: 4px;}
	.paging-box .icon-prev:hover{ background:url(/admin/images/paging-prevh.png) no-repeat 50% 50%;}
	.paging-box .icon-next:hover{background:url(/admin/images/paging-nexth.png) no-repeat 50% 50%;}
	.paging-box .curr,
	.paging-box .curr:hover{color: #35a7ba;border: 1px solid #35a7ba;}
	.paging-box .icon-prev{background:url(/admin/images/paging-prev.png) no-repeat 50% 50%;}
	.paging-box .icon-next{background:url(/admin/images/paging-next.png) no-repeat 50% 50%;}
    </style>
    <script>
        $(function () {
            initialSelect();
        })
    
        function initialSelect() {
            $('.style-inner  li').click(function () {
                $(this).addClass('current').siblings().removeClass('current');
            })
        }
    
    </script>
    <script>
        jQuery(document).ready(function () {
           
            var classid = $("#classid").val();
            if(classid='undefined')
            {
                classid='0';
            }
            else 
            {

            }
            DoClass('<%=VideoType%>', classid);
            
        });
       

        function DoClass(id, classid) {
            var chanelid = id;
            var key = jQuery("#<%=this.TxtKey.ClientID %>").val();
            if (chanelid != '0') {
                $.ajax({
                    url: "/Plus/course/GetYunVideo.aspx?from=<%=from%>&action=getclass&VideoType=" + chanelid + "&classid=" + classid,
                    context: document.body,
                    type: "GET",
                    success: function (data) {
                      //  alert(classid);
                        $("#getclassid").show();
                        $("#getclassid").html(data);
                        loaddata('yunvideolist', key, chanelid, classid, 1);
                    }
                });

            } else {
                $("#getclassid").hide();
                loaddata('yunvideolist', key, chanelid, 0, 1);
            }

        }
    </script>
    <script>
        function onserch() {
            var key = jQuery("#<%=this.TxtKey.ClientID %>").val();
            var channelid ='<%=VideoType%>';
            var classid = jQuery("#classid").val();
            // alert(classid);
            loaddata('yunvideolist', key, channelid, classid, 1);
        }
        function loaddata(action, key, channelid, classid, page) {
            $.ajax({
                url: "/Plus/course/GetYunVideo.aspx?from=<%=from%>&action=" + action + "&rnd=" + Math.random() + "&key=" + key + "&VideoType=" + channelid + "&classid=" + classid + "&page=" + page,
                context: document.body,
                type: "GET",
                success: function (data) {
                    if (action == "yunvideolist") {
                        $("#LoadData").html(data);
                        initialSelect();
                    }
                }
            });
        }

    </script>
    <script>
        function SetClassUrl() {

           // alert("dd");
         
            var v = '';
            v = $('.style-inner  li.current').find("input[name='vid']").val();
         
           // alert(v);
            if (v == '' || v == undefined) {
                KesionJS.Alert('请选择视频!');



            }
            else {
                var ff = '<%=from%>';
                if (ff == 'pc') {
                    top.frames["main"].document.getElementById("<%=KSCMS.S("fieldID")%>").value = v;

                }
                else {

                    $('iframe', parent.document).parents('body').find('#<%=KSCMS.S("fieldID")%>').val(v);

                }
                <%if (KSCMS.S("fieldID")!=""){ %>
               
                jQuery.dialog.close();
                <%}else{%>
            <%} %>

            }
        }

         function RefAll() {

             
             $.ajax({
                url: "/plus/Course/GetYunVideo.aspx?action=RefAll&from=pc&fieldID=<%=KSCMS.S("fieldID")%>&VideoType=<%=VideoType%>&rnd=" + Math.random(),
                context: document.body,
                type: "get",
                success: function (data) {
                    
                    if (data == 'ok') {
                        alert("恭喜，视频分类同步成功");
                        window.location.reload();
                      
                    } else if (data == 'error') {
                        alert("抱歉，当前没有可以同步的分类");
                        window.location.reload();

                    }
                    else {
                        alert("对不起，同步失败");
                           window.location.reload();
                    }

                }
            });
            return false;
        }

    </script>
	<div class="table mt20">
		<div class="fr">
        	<Input class="button button_on mr15" type="button" value="确定" name=Submit onclick="SetClassUrl();">
			<%if ((from == "pc" & VideoType==5)||(from == "pc" & VideoType==8)||VideoType==6)
              { %>
            <%if (VideoType == 5)
                { %>
             <asp:Button ID="Button3" runat="server" Text="关联视频分类"  CssClass="button button_on" OnClientClick="return(RefAll())"/>
            <%} %>
            <asp:Button ID="Button1" runat="server" Text="云服务获取视频"  CssClass="button button_on" OnClick="Button1_Click1"/>
            <%} %>
        </div>
        <div class="style-column" id="tempsList">
            <div class="vtab tempsbox chooses">
                <div class="searcher md20">
                  <%if (VideoType == 5 || VideoType == 6)
                      { %>
                   	<span id="getclassid" style="margin-right:8px;"></span>
                    <%} %>
                    <asp:TextBox ID="TxtKey" runat="server" class="searchbox" style="margin-right:8px;"></asp:TextBox>
                    <input id="Button2" type="button" value="开始搜索" onclick="onserch()" class="button"/>
                </div>
                <div class="cb h5"></div>
                <div class="cb vtab-content" id="styleList">
                    <div class="style-inner clearfix item clearfix" id="LoadData">
                        <%=initialList()%>
                    </div>
                </div>
            </div>
      	</div>
	</div>

</div>


</asp:Content>
