<%@ Page Language="C#"   AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Course.Qiniu" Codebehind="Qiniu.aspx.cs" %>
<html>
<head >
    <title>无标题页</title>
    <link href="<%=Request.ApplicationPath=="/"?"":Request.ApplicationPath%>/admin/images/style.css" rel="stylesheet" type="text/css" />
    <script src="../../admin/images/pannel/tabpane.js" type="text/javascript"></script>
    <link href="<%=Request.ApplicationPath=="/"?"":Request.ApplicationPath%>/admin/images/pannel/tabpane.CSS" rel="stylesheet" type="text/css" />
    <script src="<%=ResolveUrl("~/KS_Inc/Jquery.js") %>" type="text/javascript"></script>
    <script src="<%=ResolveUrl("~/KS_Inc/Kesion.Common.js") %>" type="text/javascript"></script>
    <script src="<%=ResolveUrl("~/KS_Inc/DatePicker/WdatePicker.js") %>"></script>
    <!--[if IE 6]>
  <script src="/admin/include/iepng.js" type="text/javascript"></script>
  <script type="text/javascript">
     try{
     EvPNG.fix('div, ul, img, li, input, em, a, p,i,b,span,em,' ); 
    }catch(e){
    }
  </script>
  <![endif]-->
  <style>
  body{ width:auto;}
  #Panel8{padding: 20px;margin-bottom: 20px;border: 1px solid #eee;background: #fff;}
  #Panel8 .add_file input{width: 280px;height: 31px;outline: none;line-height: 31px;border: 1px solid #dce2e4;border-radius: 3px;padding-left: 10px;float: left;}
  #Panel8 .out button{float: left; display: inline-block;padding: 0px 15px;height: 30px;line-height: 100%;background: #fff;border: 1px solid #69B7E4;text-align: center; margin-left: 10px;color: #69B7E4;font-size: 12px;border-radius: 3px;outline: none;}
  #Panel8 .add_file{margin: 20px 0;}
  #Panel8 .radio_transcodebox .radio_transcode input{ vertical-align:middle; margin-right:5px;}
  #Panel8 .radio_transcodebox .radio_transcode{ margin-right:10px;}
  .CTable{border: #eee solid 1px;margin-bottom: 20px;}
  .CTable tr td.righttd li{line-height:30px; margin-bottom: 10px; font-size:12px;}
  .CTable tr td.righttd li #key{width: 280px;height: 30px;outline: none;line-height: 31px;border: 1px solid #dce2e4;border-radius: 3px;padding-left: 10px;}
  .CTable tr td.righttd li #btn_upload{float: left;padding: 0px 15px;height: 30px;line-height: 100%;background: #fff;border: 1px solid #69B7E4;text-align: center;color:#69B7E4;font-size: 12px;border-radius: 3px;outline: none;}
  #textbody{    width: 280px;
    height: 31px;
    outline: none;
    line-height: 31px;
    border: 1px solid #dce2e4;
    border-radius: 3px;
    padding-left: 10px;}
   #upload{
	float:left;
    padding: 0px 15px;
    height: 30px;
    line-height: 100%;
    background: #fff;
    border: 1px solid #69B7E4;
    text-align: center;
    color: #69B7E4;
    font-size: 12px;
    border-radius: 3px;
    outline: none;
	margin-left:10px;}
	#Panel6{
    border: 1px solid #eee;
    background: #fff;
	padding:20px;
    margin-bottom: 20px;}
	#Panel6 h3{
    float: left;
    font-weight: normal;
    line-height: 30px;
    margin-right: 10px;
	    font-size: 12px;
    }
	.CTable tr td.righttd li #Bucket{
	height: 30px !important;
    border-radius: 3px;
    padding-left: 5px !important;
    width: inherit !important;
    -webkit-appearance: none;
    padding-right: 40px;
    background: #fff url(../course/images/xlbg.png) no-repeat center right;
    margin-right: 15px;
    cursor: pointer;
    outline: none;
    border: 1px solid #dce2e4 !important;}
	.button, .button_on {
    background: #69b7e4;
    color: #fff;
    padding: 0 8px;
    height: 26px;
    line-height: 26px;
    cursor: pointer;
    border: none;
    position: absolute;
    bottom: 20%;
    left: 48%;
}
  </style>
</head>
<body scroll="auto" style="overflow-x:hidden;padding:0 10px;padding-bottom:150px;">
<script>
		$(function(){
			$('#wrapAll').find('div:eq(1)').css({paddingTop:'100px'});
		});
	</script>
    <form id="form1" runat="server">
    <KS:topnav id="TopNav1" runat="server" text=""></KS:topnav>
   <asp:Panel ID="Panel2" runat="server" Visible="false">
  

<table class="hrPageTable table table-hover table-bordered">
    <thead>
    <tr>
        <th>视频名称</th>
        <th>上传进度</th>
        <th>上传速度</th>
        <th>上传状态</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td id="videoId"></td>
        <td id="videoProgress"></td>
        <td id="videoSpeed"></td>
        <td id="videoStatus"></td>
    </tr>
    </tbody>
</table>
<div>
    <input type="button" class="uploadBtn" id="uploadBtn" value="开始上传" />
    <input type="button" class="uploadBtn" id='fileSelecter' value="添加视频" />
</div>
<!--使用例子-->
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/html5Upload.js"></script>
<script type="text/javascript">
    $(function () {
        //添加视频
        $("#fileSelecter").addFile({
            addFile: function (data) { //添加文件时的回调
                $("#videoId").html(data.data.fileName);
                $("#videoProgress").html("0");
                $("#videoSpeed").html("0");
                $("#videoStatus").html("等待上传");
            },
            addFileError: function (data) { //添加文件时发生错误的回调
                alert("错误码：" + data.code + ";错误消息：" + data.msg);
            }
        });

        //开始上传
        $("#uploadBtn").upload({
            uploadInitUrl: "/Interface.asmx/html5UploadInit",//初始化上传地址
         
            uploadProgress: function (data) { //进度回调
                $("#videoProgress").html(data.progress);
                $("#videoSpeed").html(data.speed);
                $("#videoStatus").html("上传中");
            },
            uploadFinish: function (result) { //上传完成回调
                $("#videoProgress").html("100%");
                $("#videoSpeed").html("0");
                $("#videoStatus").html("已上传");
                $.ajax({
                    url: "?action=letvCoude&rnd=" + Math.random(),
                    context: document.body,
                    type: "GET",
                    success: function (data) {
                        $(top.frames["main"].document.getElementById("#TextAddress")).val(data);
                    }
                });              
              
            },
            uploadError: function (data) { //上传错误回调
                $("#videoStatus").html("上传错误！错误码：" + data.code + ";错误消息：" + data.msg);
            },
            uploadAbort: function (data) { //中断

            }
        });
    });
</script>
</body>

         </asp:Panel>

     <asp:Panel ID="Panel6" runat="server" Visible="false">
                <h3>视频上传</h3>
             
                <p style="display:none;"></p>
               
				
				<textarea id="textbody" name="textbody" rows="3" cols="50" style="margin: 0px; height:30px; width: 328px; float:left;" class="textInput readonly valid"></textarea>
                  <input type="button" id="upload" value="上传"  /> 
          <script src="http://v.polyv.net/file/plug-in/js/polyv-upload.js"></script>
                <script type="text/javascript">
                    var hash = "<%=hash%>";
                    var writeToken = "<%=ACCESS_KEY%>";
                    var readToken = "<%=SECRET_KEY%>";
                    var userid = "<%=userid%>";
                    var obj = {
                        uploadButtton: "upload",   //打开上传控件按钮id
                        writeToken: writeToken,
                        userid: userid,
                        ts: "<%=ts%>",
                        hash: hash,
                        readToken: readToken,
                        response: function (json) {
                            $(top.frames["main"].document.getElementById("#TextAddress")).val(json.vid);
                            var scriptdata = "<script>" +
                            "var player = polyvObject('#plv_" + json.vid + "').videoPlayer({\n" +
                                                        "'width':'100%',\n" +
                                                        "'height':'100%',\n" +
                                                        "'vid' : '" + json.vid + "'" +
                                                    "});<\/script>";

                            document.getElementById("textbody").value = document.getElementById("textbody").value + scriptdata;

                            //如果需要关闭窗口
                            upload.closeWrap();

                        }
                    }
                    var upload = new PolyvUpload(obj);
                    function aa() {

                    }
                </script>
				
				<div class="clear"></div>
     </asp:Panel>
   
 <asp:Panel ID="Panelist" runat="server" Visible="false" >
       <table id="Table1" width="100%" align="center" border="0" cellpadding="1" cellspacing="1" class="CTable"> 
       <tr>
             <td class="lefttd" height="30" align="right" style="width: 198px;background: #F1F2F7;"><b>开启同步：</b></td>
                <td class="righttd" style="padding: 20px;">
                  <asp:DropDownList ID="DropDownListType" runat="server">
         </asp:DropDownList>
                </td>
         </tr>
        <tr>
             <td class="lefttd" height="30" align="right" style="width: 198px"><b>显示视频目录：</b></td>
                <td class="righttd">
                  <asp:TextBox ID="TextBox1" runat="server"  CssClass="textbox"></asp:TextBox>
                </td>
         </tr>
          <tr>
             <td class="lefttd" height="30" align="right" style="width: 198px"></td>
                <td class="righttd">
                 <asp:Button ID="Button1" runat="server" Text="查看所有列表" OnClick="Button1_Click" />
                </td>
         </tr>
    </table>
    </asp:Panel>

      <asp:Panel ID="Panel9" runat="server" >
	     <script type="text/javascript" src="/ks_inc/qiniu.js"></script>
		  <table id="tbs" width="100%" align="center" border="0" cellpadding="1" cellspacing="1" class="CTable"> 
      
         <tr>
             <td class="lefttd" height="30" align="right" style="width: 198px;background: #F1F2F7;"><b>上传视频：</b></td>
          <td class="righttd" style="padding: 20px;">
       <ul>
               <li>
        <label for="key">上传目录:</label>
        <%=sb.ToString() %>必须正确填写否则上传失败
    </li>
     <li>
        <label for="key">浏览文件key:</label>
        <input id="key" name="key" class="ipt" value=""/>
    </li>
    <li>

        <label for="bucket">选择要上传文件:</label>
        <input id="file" name="file" class="ipt" type="file" />
    </li>
    <li>
        <input id="btn_upload" type="button" value="开始上传" >
    </li>
    <div id="progressbar"><div class="progress-label"></div></div>
</ul>
<div id="dialog" title="上传成功"></div>
   </td>
     </tr>
   </table>
     <script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

    
    <script>
 
        $(document).ready(function () {
            var Qiniu_UploadUrl = "http://upload.qiniu.com";
            var progressbar = $("#progressbar"),
                progressLabel = $(".progress-label");
            progressbar.progressbar({
                value: false,
                change: function () {
                    progressLabel.text(progressbar.progressbar("value") + "%");
                },
                complete: function () {
                    progressLabel.text("上传成功!");
                }
            });
            $("#btn_upload").click(function () {
                //普通上传
                var Qiniu_upload = function (f, token, key) {                 
                    var xhr = new XMLHttpRequest();
                    xhr.open('POST', Qiniu_UploadUrl, true);
                    var formData, startDate;
                    formData = new FormData();
                    if (key !== null && key !== undefined) formData.append('key', key);
                    formData.append('token', token);
                    formData.append('file', f);
                    var taking;
                    xhr.upload.addEventListener("progress", function (evt) {
                        if (evt.lengthComputable) {
                            var nowDate = new Date().getTime();
                            taking = nowDate - startDate;
                            var x = (evt.loaded) / 1024;
                            var y = taking / 1000;
                            var uploadSpeed = (x / y);
                            var formatSpeed;
                            if (uploadSpeed > 1024) {
                                formatSpeed = (uploadSpeed / 1024).toFixed(2) + "Mb\/s";
                            } else {
                                formatSpeed = uploadSpeed.toFixed(2) + "Kb\/s";
                            }
                            var percentComplete = Math.round(evt.loaded * 100 / evt.total);
                            progressbar.progressbar("value", percentComplete);
                            // console && console.log(percentComplete, ",", formatSpeed);
                        }
                    }, false);

                    xhr.onreadystatechange = function (response) {
                        if (xhr.readyState == 4 && xhr.status == 200 && xhr.responseText != "") {
                            var blkRet = JSON.parse(xhr.responseText);
                            console && console.log(blkRet);
                            $(top.frames["main"].document.getElementById("#TextAddress")).val(blkRet.key);
                       //  $("#dialog").html(xhr.responseText).dialog();
                        } else if (xhr.status != 200 && xhr.responseText) {

                        }
                    };
                    startDate = new Date().getTime();
                   // $("#progressbar").show();
                    xhr.send(formData);
                };
                var token = gettoken();
            
                if ($("#file")[0].files.length > 0 && token != "") {
                    var key = $("#key").val();
                    if ($("#key").val() == '') {
                        var dTime = new Date();                      
                        var lTime = dTime.getTime();//毫秒级     
                        var lTime = parseInt(dTime.getTime() / 1000);//秒级                                           
                        key = "qy_" + lTime;
                    }
                    Qiniu_upload($("#file")[0].files[0], token, key);
                } else {
                    console && console.log("form input error");
                }
            })
        })

    </script>
  <script type="text/javascript" src="http://cdn.sencha.io/ext-4.2.0-gpl/ext-all.js"></script>
  <script type="text/javascript" src="http://qtestbucket.qiniudn.com/demo/CryptoJS.js"></script>

    <script type='text/javascript'>
         App = {
                Bucket: "teodda",
                SignUrl: "token.php",
                //qiniu test account
                AK: "<%=ACCESS_KEY%>",
               SK: "<%=SECRET_KEY%>"
        }
    

            function utf16to8(str) {
                var out, i, len, c;
                out = "";
                len = str.length;
                for (i = 0; i < len; i++) {
                    c = str.charCodeAt(i);
                    if ((c >= 0x0001) && (c <= 0x007F)) {
                        out += str.charAt(i);
                    } else if (c > 0x07FF) {
                        out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
                        out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
                        out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
                    } else {
                        out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
                        out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
                    }
                }
                return out;
            }

            function utf8to16(str) {
                var out, i, len, c;
                var char2, char3;
                out = "";
                len = str.length;
                i = 0;
                while (i < len) {
                    c = str.charCodeAt(i++);
                    switch (c >> 4) {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                        case 5:
                        case 6:
                        case 7:
                            // 0xxxxxxx
                            out += str.charAt(i - 1);
                            break;
                        case 12:
                        case 13:
                            // 110x xxxx 10xx xxxx
                            char2 = str.charCodeAt(i++);
                            out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
                            break;
                        case 14:
                            // 1110 xxxx 10xx xxxx 10xx xxxx
                            char2 = str.charCodeAt(i++);
                            char3 = str.charCodeAt(i++);
                            out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));
                            break;
                    }
                }
                return out;
            }

            /*
             * Interfaces:
             * b64 = base64encode(data);
             * data = base64decode(b64);
             */
            var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
            var base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
                52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
                41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);

            function base64encode(str) {
                var out, i, len;
                var c1, c2, c3;
                len = str.length;
                i = 0;
                out = "";
                while (i < len) {
                    c1 = str.charCodeAt(i++) & 0xff;
                    if (i == len) {
                        out += base64EncodeChars.charAt(c1 >> 2);
                        out += base64EncodeChars.charAt((c1 & 0x3) << 4);
                        out += "==";
                        break;
                    }
                    c2 = str.charCodeAt(i++);
                    if (i == len) {
                        out += base64EncodeChars.charAt(c1 >> 2);
                        out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
                        out += base64EncodeChars.charAt((c2 & 0xF) << 2);
                        out += "=";
                        break;
                    }
                    c3 = str.charCodeAt(i++);
                    out += base64EncodeChars.charAt(c1 >> 2);
                    out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
                    out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
                    out += base64EncodeChars.charAt(c3 & 0x3F);
                }
                return out;
            }

            function base64decode(str) {
                var c1, c2, c3, c4;
                var i, len, out;
                len = str.length;
                i = 0;
                out = "";
                while (i < len) {
                    /* c1 */
                    do {
                        c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
                    } while (i < len && c1 == -1);
                    if (c1 == -1) break;
                    /* c2 */
                    do {
                        c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
                    } while (i < len && c2 == -1);
                    if (c2 == -1) break;
                    out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
                    /* c3 */
                    do {
                        c3 = str.charCodeAt(i++) & 0xff;
                        if (c3 == 61) return out;
                        c3 = base64DecodeChars[c3];
                    } while (i < len && c3 == -1);
                    if (c3 == -1) break;
                    out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
                    /* c4 */
                    do {
                        c4 = str.charCodeAt(i++) & 0xff;
                        if (c4 == 61) return out;
                        c4 = base64DecodeChars[c4];
                    } while (i < len && c4 == -1);
                    if (c4 == -1) break;
                    out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
                }
                return out;
            }
            var safe64 = function (base64) {
                base64 = base64.replace(/\+/g, "-");
                base64 = base64.replace(/\//g, "_");
                return base64;
            };
            var token;
          
            function gettoken() {
                var dTime = new Date();
                dTime = new Date(dTime.valueOf() +  60 * 60 * 1000);
                var lTime = dTime.getTime();//毫秒级     
                var lTime = parseInt(dTime.getTime() / 1000);//秒级
                var jso = '{"scope":"' + jQuery("#Bucket").val() + '","deadline":' + lTime + '}';  //构造JSON
                         
                var encoded = base64encode(utf16to8(jso));
            
                var hash = CryptoJS.HmacSHA1(encoded, App.SK);  //KEY
                var encoded_signed = hash.toString(CryptoJS.enc.Base64);
                var upload_token = App.AK + ":" + safe64(encoded_signed) + ":" + encoded;
              
                return upload_token;
            }

</script>
</asp:Panel>

  <asp:Panel ID="Panel8" runat="server" Visible="false">
        <div class="radio_transcodebox">
		
               <div class="input_area"><span>转 码: </span>
        开启<input type="radio" name="transcode" value="1" checked/>
        &nbsp;&nbsp;&nbsp;禁用<input type="radio" name="transcode" value="0"/>
    </div>
    <div class="input_area"><span>水 印: </span>
        开启<input type="radio" name="watermark" value="1"/>
        &nbsp;&nbsp;&nbsp;禁用<input type="radio" name="watermark" value="0" checked/>
    </div>  
      </div>
	    <div class="add_file">
	       <input type="text" name="classId" value=""/>
		   <div class="out" id='pickfiles_area' >
			 <button id="pickfiles" type="button">添加文件</button>
		   </div>
		   
	    </div>
     
		<div class="result" id="result"></div>
		<div class="count" id="count"></div>
		<div class="out btn-wrap" id="btnarea">
			<button id="start_upload" type="button">开始上传</button>
			<button id="stop_upload" type="button">取消上传</button>
			<button id="re_upload" type="button">重新上传</button>
		</div>
		<div class="out" id="error" style="color: red; width: 400px; text-align: left;">
		
		</div>
		<div class="clear"></div>
<script src="//qzonestyle.gtimg.cn/open/qcloud/js/vod/sdk/uploaderh5.js" charset="utf-8"></script>
<script type="text/javascript">
    
        (function () {
            var $ = qcVideo.get('$');
            var Version = qcVideo.get('Version');
            if (!qcVideo.uploader.supportBrowser()) {
                if (Version.IS_MOBILE) {
                    alert('当前浏览器不支持上传，请升级系统版本或者下载最新的chrome浏览器');
                } else {
                    alert('当前浏览器不支持上传，请升级浏览器或者下载最新的chrome浏览器');
                }
                return;
            }
            var secretId = "<%=ACCESS_KEY%>";     // $('#secret_id').val();
          
            accountDone( 'pickfiles',  secretId,$('input[name="transcode"]:checked').val(), $('input[name="watermark"]:checked').val(), null,$('input[name="classId"]').val());
          
        })();

        /**
         *
         * @param upBtnId 上传按钮ID
         * @param secretId 云api secretId
         * @param isTranscode 是否转码
         * @param isWatermark 是否设置水印
         * @param [transcodeNotifyUrl] 转码成功后的回调
         * @param [classId] 分类ID
         */
        function accountDone(upBtnId, secretId, isTranscode, isWatermark, transcodeNotifyUrl, classId) {
       
            //您的secretKey
            var $ = qcVideo.get('$')
                 , ErrorCode = qcVideo.get('ErrorCode')
                 , Log = qcVideo.get('Log')
                 , JSON = qcVideo.get('JSON')
                 , util = qcVideo.get('util')
                 , Code = qcVideo.get('Code')
                 , Version = qcVideo.get('Version')            ;

            var secret_key = "<%=SECRET_KEY%>";         //$('#secret_key').val() || '';
           
            qcVideo.uploader.init(
                    //1: 上传基础条件
                    {
                        web_upload_url: 'http://vod.qcloud.com/v2/index.php',
                        secretId: secretId, // 云api secretId
                     //   upBtnId: upBtnId, //上传按钮ID（任意页面元素ID）
                        //云api secretKey : 选填参数 （secretKey不能暴露给外部用户，建议只在内部系统使用该参数）
                        secretKey: secret_key,

                        /*
                         @desc 获取签名的方法

                         //server端实现逻辑
                         // 1:首先 将argStr ，使用secretKey做sha1加密，得到结果 result
                         // 2:最后 将result做base64后返回

                         //附nodejs示例实现
                         //   crypto.createHmac('sha1', '你的secretKey').update(argStr).digest().toString('base64');
                         //附php示例实现
                         //   base64_encode(hash_hmac('sha1', $argStr, $secretKey, true));
                         //附java示例实现 感谢 更深的蓝 友情赞助
                         //   http://video.qcloud.com/sdk/GetSKeyServlet.java.txt
                       
                         getSignature: function(argStr,cb){
                             //注意：出于安全考虑， 服务端接收argStr这个参数后，需要校验其中的Action参数是否为 "MultipartUploadVodFile",用来证明该参数标识上传请求
                             $.ajax({
                                'dataType': 'json',
                                'url': 'http://signature.qcloud.com/getSignature.php?args='+encodeURIComponent(argStr),
                                'success': function(d){
                                    cb(d['result']);
                                }
                             });
                         },
                           */
                        upBtnId: upBtnId, //上传按钮ID（任意页面元素ID）
                        isTranscode: isTranscode,//是否转码
                        isWatermark: isWatermark//是否设置水印
                        //,after_sha_start_upload: false//sha计算完成后，开始上传 (默认关闭立即上传)
                        //,sha1js_path: 'http://您的域名/您的设置目录/calculator_worker_sha1.js' //计算sha1的位置
                        , disable_multi_selection: false //禁用多选 ，默认为false

                        , transcodeNotifyUrl: transcodeNotifyUrl//(转码成功后的回调地址)isTranscode==true,时开启； 回调url的返回数据格式参考  http://www.qcloud.com/wiki/v2/MultipartUploadVodFile
                        , classId: classId
                    }
                    //2: 回调
                    , {

                        /**
                         * 更新文件状态和进度
                         * @param args { id: 文件ID, size: 文件大小, name: 文件名称, status: 状态, percent: 进度 speed: 速度, errorCode: 错误码,serverFileId: 后端文件ID }
                         */
                        onFileUpdate: function (args) {
                      
                            var $line = $('#' + args.id);
                            if (!$line.get(0)) {
                                $('#result').append('<div class="line" id="' + args.id + '"></div>');
                                $line = $('#' + args.id);
                            }
                          
                            var finalFileId = '';

                            if (args.code == Code.UPLOAD_DONE) {
                                finalFileId = '上传成功返回ID>>' + args.serverFileId;
                                $(top.frames["main"].document.getElementById("#TextAddress")).val(args.serverFileId);
                            //   $("#ctl00_KSContent_TextAddress", parent.document).val(args.serverFileId);
                                top.box1.close();
                            }

                            $line.html(''
                                    + '文件名：' + args.name
                                    + ' >> 大小：' + util.getHStorage(args.size)
                                    + ' >> 状态：' + util.getFileStatusName(args.status) + ''
                                    + (args.percent ? ' >> 进度：' + args.percent + '%' : '')
                                    + (args.speed ? ' >> 速度：' + args.speed + '' : '')
                                    + '<span data-act="del" class="delete">删除</span>'
                                    + finalFileId
                            );

                        },

                        /**
                         * 文件状态发生变化
                         * @param info  { done: 完成数量 , fail: 失败数量 , sha: 计算SHA或者等待计算SHA中的数量 , wait: 等待上传数量 , uploading: 上传中的数量 }
                         */
                        onFileStatus: function (info) {
                            $('#count').text('各状态总数-->' + JSON.stringify(info));

                        },

                        /**
                         *  上传时错误文件过滤提示
                         * @param args {code:{-1: 文件类型异常,-2: 文件名异常} , message: 错误原因 ， solution: 解决方法}
                         */
                        onFilterError: function (args) {
                            var msg = 'message:' + args.message + (args.solution ? (';solution==' + args.solution) : '');
                            $('#error').html(msg);
                        }

                    }
            )
        }

    (function () {
        //事件绑定
       
        $('#start_upload').on('click', function () {
                //@api 上传          
                qcVideo.uploader.startUpload();
            });

            $('#stop_upload').on('click', function () {
                //@api 暂停上传
                qcVideo.uploader.stopUpload();
            });

            $('#re_upload').on('click', function () {
                //@api 恢复上传（错误文件重新）
                qcVideo.uploader.reUpload();
            });

            $('#result').on('click', '[data-act="del"]', function (e) {
                        var $line = $(this).parent();
                        var fileId = $line.get(0).id;

                        Log.debug('delete', fileId);

                        $line.remove();
                        //@api 删除文件
                        qcVideo.uploader.deleteFile(fileId);
                    });       
       })();
</script>

    </asp:Panel>
  <div style="text-align:center;margin-top:5px;">
          <input type="button" value="确定并返回" accesskey="C" onClick="jQuery.dialog.close()" class="button" onMouseOver="this.className='button_on';" onMouseOut="this.className='button';" />
  </div>

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

