<%@ Page Language="C#" AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Course.Course.AddYunVideos" CodeBehind="AddYunVideos.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<link href="/admin/images/style.css" rel="stylesheet" type="text/css" />
<script src="../../admin/images/pannel/tabpane.js" type="text/javascript"></script>
<link href="/admin/images/pannel/tabpane.CSS" rel="stylesheet" type="text/css" />
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
<script src="/KS_Inc/jQuery.js"></script>
<script src="/KS_Inc/Kesion.Common.js"></script>
</head>
<body>
	<div id="manage_top" class="toptitle menu_top_fixed">
    	上传视频
    </div>
    <div class="menu_top_fixed_height"></div>
    <div class="content-area">
      
            <table width="100%" align="center" border="0" cellpadding="1" cellspacing="1" class="CTable">
              <tr>
                 <td align="right" class="lefttd" height="30"><font color="red">*</font>标题</td>
                   <td class="righttd" >  
                       <input id="TxtTitle" name="TxtTitle" type="text" value="" />
                   </td>
                </tr>
                 <tr>
                        <td align="right" class="lefttd" >tag(标签)</td>
                        <td class="righttd">
        
               
                     <input id="txttag" name="txttag" type="text" value="" />
                            <span class="tips">(多个标签用逗号隔开)</span> 
                        </td>
                  </tr>
                  <tr>
                        <td align="right" class="lefttd" height="30">视频分类</td>
                        <td class="righttd">
                            <select id="mySelect" name="mySelect">
                                <option value="0">--选择视频分类--</option>
                               <%=initialVideoCata() %>
                            </select>
                      
                        </td>
                   </tr>
                 
                <tr>
                  <td align="right" class="lefttd" height="30">视频文件描述</td>
                  <td class="righttd">
                         <input id="Txtcontext" name="Txtcontext" type="text"  value="" />
             
                  </td>
                </tr>
              <tr>
                    <td align="right" class="lefttd" height="30"><font color="red">*</font>上传视频文件</td>
                     <td class="righttd">
                   
                         <div class="uptips" id="showspeed"><div class="button" onMouseDown="return(upClick())"><span id="spanButtonPlaceholder"></span></div></div>
                        <span class="tips">支持：*.flv; *.avi; *.mpg; *.mp4; *.wmv; *.mov; *.3gp; *.asf</span>
                           
                   </td>
                 </tr>
                </table>
            
  
  
   

        <div id="tipss" style="display:none">
       <div id="UploadTips" style="padding:5px"><style>#UploadTips span{color:#ff6600;}</style><div style="display:none">Files Queued:<span id="tdFilesQueued"></span>Files Uploaded:	<span id="tdFilesUploaded"></span>Errors:	<span id="tdErrors"></span></div>当前速度:<span id="tdCurrentSpeed">0</span> 平均速度：<span  id="tdAverageSpeed">0</span><br/>已上传：<span id="tdPercentUploaded">0%</span> 大小：<span id="tdSizeUploaded">0</span>&nbsp;剩余时间：<span id="tdTimeRemaining">0</span> 已用时：<span id="tdTimeElapsed">0</span><br/><strong>正在上传中... 请耐心等待!!! 直到该提示框消失。</strong><span style="display:none">Moving Average Speed:<span id="tdMovingAverageSpeed"></span>Progress Event Count:<span id="tdProgressEventCount"></span></span></div></div>
       
        <%if(!string.IsNullOrEmpty(fieldID)){ %>
        <div class="pop-button">
          <input type="button" value="确定并返回" accesskey="C" onClick="jQuery.dialog.close()" class="button" onMouseOver="this.className='button_on';" onMouseOut="this.className='button';" />
  </div>

        <%} %>
  </div>
  
  
  


 <script>

     var limitSize = 3072000; //限制大小 KB
     var fileExt = "*.avi; *.wmv; *.mp4;*.mp3; *.mov; *.flv; *.mkv; *.rmvb" //限制扩展名

      </script>
        <script>
            

           var dir = '../../';  //安装目录
           var uploadUrl = "http://v.polyv.net/uc/services/rest?method=uploadfile";  //上传处理文件地址
           var buttonstyle = "color:#000000;";

           function upClick() {
               var title = $('#TxtTitle').val();
               var tag = $('#txttag').val();
               var desc = $('#Txtcontext').val();
               var cataid = document.getElementById('mySelect').value;

               if (cataid == '0') {
                   cataid = '1';
               }
               if ($.trim(title) == '' || title == undefined) {
					alert('请输入标题');
                   $('#TxtTitle').focus();
                   return false;
               }else {
				   
                   swfu.addPostParam("cataid", ''+cataid+'');
                   swfu.addPostParam("JSONRPC", '{"title": "'+title+'", "tag": "'+tag+'", "desc": "'+desc+'"}');
                   return true;
               }
              
           };
            
          

            var post_params = {
                'fcharset': 'ISO-8859-1',
                'writetoken': '<%=ACCESS_KEY%>',
                //'cataid': '1',  //视频分类id , 当cataid值为1时，表示用户上传空间的根目录
                //'JSONRPC': '{"title": "这里是标题44444444444", "tag": "标签", "desc": "视频文档描述"}'
            };
            
            function uploadSuccess(file, serverData) {

                var obj = eval('(' + serverData + ')');
                if (obj.error == '16') {
                    alert("空间已满");

                }
                else if (obj.error == '1') {
                    alert("找不到writetoken关联的user");
                }
                else if (obj.error == '2') {
                    alert("文件为空或者writetoken为空");
                }
                else if (obj.error == '3') {
                    alert("提交的json名字JSONRPC为null");
                }
                else if (obj.error == '4') {
                    alert("提交文件格式不正确");
                }
                else if (obj.error == '5') {
                    alert("readtoken为空");
                }
                else if (obj.error == '6') {
                    alert("分页输入出错");
                }
                else if (obj.error == '7') {
                    alert("vid不能为空");
                }
                else if (obj.error == '8') {
                    alert("找不到方法名");
                }
               
                else if (obj.error == '10') {
                    alert("userid不能为空");
                }
                else if (obj.error == '11') {
                    alert("上传目录为空");
                }
                else if (obj.error == '12') {
                    alert("远程URL文件不能访问");
                }
                else if (obj.error == '13') {
                    alert("远程视频文件格式无法识别");
                }
                else if (obj.error == '15') {
                    alert("参数异常");
                }
                else if (obj.error == '17') {
                    alert("用户无接口权限");
                }
                else if (obj.error == '18') {
                    alert("标题重复");
                }
                else if (obj.error == '19') {
                    alert("标题为空");
                }
                else if (obj.error == '20') {
                    alert("播放列表不存在");
                }
                else if (obj.error == '21') {
                    alert("参数错误");
                }
                else if (obj.error == '22') {
                    alert("参数签名错误");
                }
                else if (obj.error == '23') {
                    alert("视频不存在");
                }
                else if (obj.error == '24') {
                    alert("时间戳已过期");
                }
                else {

                    $.ajax({
                        url: "/Plus/course/AddYunVideos.aspx?action=getadd&VideoType=<%=VideoType%>&vid="+obj.data[0].vid + "&cataid=" + obj.data[0].cataid + "&firstimage=" + obj.data[0].first_image + "&desc=" + obj.data[0].context + "&title=" + obj.data[0].title + "&tag=" + obj.data[0].tag + "&ptime=" + obj.data[0].ptime + "&status=" + obj.data[0].status + "&duration=" + obj.data[0].duration + "&filesize=" + obj.data[0].filesize + "&times=" + obj.data[0].times + "&swflink=" + obj.data[0].swf_link + "&rnd=" + Math.random(),
                           context: document.body,
                           type: "get",
                           success: function (data) {
                               if (data == 'ok') {

                                   var strss = '<%=fieldID%>';
                                   if (strss == '') {

                                       KesionJS.Alert("恭喜，添加视频成功", "location.href='<%=KSCMS.GetInstallDir() + MyCache.GetCacheConfig(4)%>/Yun/KS.YunVideo.aspx?VideoType=<%=VideoType%>';");
                                   }
                                   else {
                                       var ff = '<%=from%>';
                                       if (ff == 'pc') {

                                           $(top.frames["main"].document.getElementById("<%=fieldID%>")).val(obj.data[0].vid);

                                       }
                                       else {
                                           $('iframe', parent.document).parents('body').find('#<%=KSCMS.S("fieldID")%>').val(obj.data[0].vid);

                                       }


                                   }
                                  
                               }
                               else if (data == 'have') {
                                   KesionJS.Alert("抱歉，添加视频已经上限啦");
                               }
                       }
                       });

  
                }



            }
            function SetAutoReName(obj) { if (obj.checked) { swfu.addPostParam("NoReName", "0"); } else { swfu.addPostParam("NoReName", "1"); } }
            function SetAddWaterFlag(obj) { if (obj.checked) { swfu.addPostParam("AddWaterMark", "1"); } else { swfu.addPostParam("AddWaterMark", "0"); } }
		</script>
		<script src="../../Plus/swfupload/swfupload/swfupload.js"></script>
		<script src="../../Plus/swfupload/swfupload/swfupload.queue.js"></script>
		<script src="../../Plus/swfupload/swfupload/swfupload.speed.js"></script>
</body>
</html>
