<%@ Page language="c#" Codebehind="upload.aspx.cs" AutoEventWireup="True" Inherits="Webdisk.upload" %>
<%@ Register TagPrefix="Upload" Namespace="Mytaoyuan.Com.Upload" Assembly="Mytaoyuan.Com.Upload" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>上传文件</title>
		<% @ Import Namespace="Webdisk" %>
		<link href="<%=xml.GetStyle()%>" type=text/css rel=stylesheet>
        <link href="css/common.css" rel="stylesheet" type="text/css" />
		<link href="css/webdialog.css" type=text/css rel=stylesheet>
        <link rel="stylesheet" href="js/artDialog/css/ui-dialog.css" />
		<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script src="js/artDialog/dist/dialog-plus.js" type="text/javascript"></script>
        <style type=text/css>.STYLE1 { COLOR: #0000ff }
	.ProgressBar { BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: 0px; WIDTH: 100%; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; HEIGHT: 3em }
	</style>
    	<script type="text/javascript">
    	    function getUrlParam(paramName) {
    	        var s = location.search;
    	        if (s != null) {
    	            var sarr = s.substr(1).split("&");
    	            var tarr;
    	            for (i = 0; i < sarr.length; i++) {
    	                tarr = sarr[i].split("=");
    	                if (tarr.length == 2 && tarr[0].toLowerCase() == paramName) {
    	                    return tarr[1];
    	                }
    	            }
    	            return "";
    	        }
    	    }
    	    function tipWindowClose() {
    	        if (window.top.closeWindow) {
    	            window.top.closeWindow();
    	        } else {
    	            history.go(-1);
    	        }
    	    }
    	    function windowClose() {
    	            if (window.top.closeWindow) {
    	                window.top.closeWindow(true);
    	            } else {
    	                history.go(-1);
    	            }
			}
			function uploadSuccess (){
				 var d = dialog({ content: '<span style="color:#1ea7de;">上传文件成功!</span>', quickClose: true, align: 'top left' }).show(document.getElementById("btn_upload"));
				 setTimeout(function () {
				     windowClose();
				 }, 2000);
	        }
	        function downloadUploadSuccess() {
	            var d = dialog({ content: '<span style="color:#1ea7de;">上传文件成功!</span>', quickClose: true, align: 'top left' }).show(document.getElementById("progressStartButton"));
	            setTimeout(function () {
	                windowClose();
	            }, 2000);
	        }
    	    function setid() {
    	        var str;
    	        var count = $.trim($("#upcount").val());
    	        var upcountTag = $("#upcount");
    	        if ($("#type1").is(":visible")) {
    	            str = '';
    	            if (count == "") {
    	                count = 1;
    	                upcountTag.val(count);
    	            }
    	            if (count > 20) {
    	                alert('上传数目不能大于20！');
    	                return false;
    	            }
    	            var tmp = "";
    	            if (getUrlParam('path') != null) tmp += "&path=" + getUrlParam('path');
    	            if (getUrlParam('code') != null) tmp += "&code=" + getUrlParam('code');
    	            if (getUrlParam('out') != null) tmp += "&out=" + getUrlParam('out');
    	            if (getUrlParam('rtn') != null) tmp += "&rtn=" + getUrlParam('rtn');
    	            window.location = 'upload.aspx?count=' + count + tmp;
    	        } else {
    	            str = '';
    	            if (count == "") {
    	                count = 1;
    	                upcountTag.val(count);
    	            }
    	            if (count > 20) {
    	                alert('添加数目不能大于20！');
    	                return false;
    	            }
    	            for (i = 1; i <= document.form1.upcount.value; i++){
    	               /* str += '<li class="list"><div class=""><span class="label">下载地址 :</span>\
					<input type="text" class="input-text" name=textBoxFileURL id=textBoxFileURL/></div>\
					<div class=""><span class="label">文件描述 :</span>\
					<textarea class="input-textarea" id=note2 name=note2 ></textarea></div></li>';<span class="input-label">上传路径 :</span>
							<input type="text" class="input-text" name="textBoxFileURL" id="textBoxFileURL" style="width:400px;"><br>
							<span class="input-label">文件描述 :</span>
							<textarea class="input-textarea" id="note2" name="note2" style="width:400px;height:50px"></textarea>*/
					str += '<div style="margin-top:5px;"><label class="input-label">下载地址 ：</label><input type="text" class="input-text" name=textBoxFileURL id=textBoxFileURL  style="width:320px;"/>\
								<label class="input-label">文件描述 ：</label><input class="input-textarea" id="note2" name="note2" style="width:300px;height:35px"></input></div>';
								}
    	            $("#download td").empty().append(str);
    	        }
    	    }
    	    function filenote() {
    	        var valueStr = "";
    	        var inputs = document.getElementsByTagName("input");
    	        for (var i = 0; i < inputs.length; i++) {

    	            if (inputs[i].name == "note") {
    	                valueStr += inputs[i].value + ",";
    	            }
    	        }
    	        document.all.hidurl.value = valueStr;
    	    }
    	    function outlink() {
    	        var valueStr = "";
    	        var inputs = document.getElementsByTagName("input");
    	        for (var i = 0; i < inputs.length; i++) {

    	            if (inputs[i].name == "url") {
    	                valueStr += inputs[i].value + ",";
    	            }
    	        }
    	        document.all.hidurl.value = valueStr;
    	    }
    	    function show1() {
    	        $("#type1").show();
    	        $("#type2").hide();
    	    }
    	    function show2() {
    	        $("#type1").hide();
    	        $("#type2").hide();
    	    }
    	    function show3() {
    	        $("#type1").hide();
    	        $("#type2").show();
    	    }
    	    function EditOpt() {
    	        Webdisk.upload.EditOpt(document.all.autorename.checked);
    	    }
    	    function getUrlParam(paramName) {
    	        var s = location.search;
    	        if (s != null && s.length > 1) {
    	            var sarr = s.substr(1).split("&");
    	            var tarr;
    	            for (i = 0; i < sarr.length; i++) {
    	                tarr = sarr[i].split("=");
    	                if (tarr.length == 2 && tarr[0].toLowerCase() == paramName) {
    	                    return tarr[1];
    	                }
    	            }
    	            return null;
    	        }
    	    }
    	    function StartEverything(callingButton) {
    	        if (document.getElementById('progressStartButton').value == ' 停 止 ') {
    	            document.getElementById('progressStartButton').value = ' 下 载 ';
    	            document.getElementById('progressNotices').innerHTML = '';
    	            document.getElementById('progressBarArea').style.display = 'none';
    	            window.frames['progressIFrame'].location.href = 'about:blank';
    	        }
    	        else {
    	            document.getElementById('progressNotices').innerHTML = '正在处理，请稍候……';
    	            window.frames['progressIFrame'].location.href = UniqueUrl(AppendArgument("downworker.aspx"));
    	        }
    	    }
    	    var objMessage = null;
    	    var objBar = null;
    	    var maxReached = false;
    	    function SetProgress(percentage, message) {
    	        if (percentage <= 100) {
    	            if (objMessage == null) {
    	                objMessage = document.getElementById('progressNotices');
    	            }
    	            if (objBar == null) {
    	                objBar = document.getElementById('progressBar');
    	            }
    	            if (message != null && message != '') {
    	                objMessage.innerHTML = message;
    	            }
    	            if (percentage > 0) {
    	                objBar.innerHTML = '.';
    	            } else {
    	                objBar.innerHTML = '';
    	            }
    	            objBar.style.width = percentage.toString() + '%';
    	            if (percentage == 100) {
    	                SetDisplay(false);
    	            }
    	        } else {
    	            maxReached = true;
    	        }
    	    }
    	    function SetDisplay(progressIsRunning) {
    	        var progressBarArea = document.getElementById('progressBarArea');
    	        progressBarArea.style.display = (progressIsRunning ? 'block' : 'none');
    	        document.getElementById('progressStartButton').value = (progressIsRunning ? ' 停 止 ' : ' 下 载 ');
    	    }
    	    function Say(message) {
    	        if (message == null || message == '') {
    	            message = '(null)';
    	        }
    	        alert(message);
    	    }
    	    function AppendArgument(url) {
    	        if (url.indexOf('?') > 0) {
    	            url += '&';
    	        } else {
    	            url += '?';
    	        }
    	        url += "file";
    	        var argValue = '';
    	        var argNote = '';
    	        var inputs = document.getElementsByTagName("input");
    	        for (var i = 0; i < inputs.length; i++) {
    	            if (inputs[i].id == "textBoxFileURL") argValue += inputs[i].value + ",";
    	            if (inputs[i].id == "note2") argNote += inputs[i].value + ",";
    	        }
    	        if (argValue != null && argValue != '') {
    	            if (url.indexOf('=') != (url.length - 1)) {
    	                url += '=';
    	            }
    	            url += escape(argValue);
    	        }
    	        else {
    	            alert('请输入下载文件的外部地址！');
    	            return;
    	        }
    	        url += '&path=' + getUrlParam('path');
    	        url += '&note=' + escape(argNote);
    	        if (getUrlParam('out') != null) url += '&out=' + getUrlParam('out');
    	        if (document.all.autorename.checked) url += '&auto=1';
    	        SetDisplay(true);
    	        return url;
    	    }
    	    function UniqueUrl(url) {
    	        var randomNum, uniqifier;
    	        if (url == null || url == '') {
    	            url = 'UrlUndefined';
    	        } else if (url.indexOf('Unique') > 0) {
    	            randomNum = Math.random();
    	            url = ReplaceArgumentValue(url, 'Unique', randomNum.toString().substr(2));
    	        } else {
    	            randomNum = Math.random();
    	            uniqifier = 'Unique=' + randomNum.toString().substr(2);
    	            if (url.indexOf('?') > 0) {
    	                url += '&' + uniqifier;
    	            } else {
    	                url += '?' + uniqifier;
    	            }
    	        }
    	        return url;
    	    }
    	    function ReplaceArgumentValue(searchArgs, argName, newArgValue) {
    	        var newSearchArgs;
    	        argName += '=';
    	        var indexStart = searchArgs.indexOf(argName);
    	        if (indexStart >= 0) {
    	            var indexEnd = searchArgs.indexOf('&', indexStart);
    	            newSearchArgs = searchArgs.substr(0, indexStart + argName.length);
    	            newSearchArgs += newArgValue;
    	            if (indexEnd > indexStart) {
    	                newSearchArgs += searchArgs.substr(indexEnd);
    	            }
    	            return newSearchArgs;
    	        } else {
    	            return searchArgs;
    	        }
    	    }
			$(function(){
				$(".input-file [type='file']").live("change",function(){
					$(this).parent().find(".upload-text").text($(this).val());
				});
				$("#upcount").focus();
			});
	</script>
	</HEAD>
	
	<body style="background:#fff;">
		<form id=form1 method=post runat="server">
			<table class="wfrom-table">
				<tbody>
					<tr>
					<td colspan="2">
						<%--<div class="wtips" id="dlock" runat="server"> <img src="pics/tip.gif" align="absMiddle">
							&nbsp;当前为上传码上传文件，由于您已登录，可以
							<asp:LinkButton id=btnselcode runat="server" Font-Underline="True" ForeColor="Black" >
							直接选择自己空间内文件复制到上传码目录</asp:LinkButton></div>--%>
						<asp:CheckBox ID="cbIsEncrypt" runat="server" Text="是否加密" Checked="false" OnCheckedChanged="showdpLevel" AutoPostBack="true" Visible="false" />
						<asp:label Visible="false" class="input-label" id="lbLevel" runat="server" Text="加密等级:"></asp:label>
						<asp:DropDownList ID="dpLevel" runat="server" Visible="false" AutoPostBack=true></asp:DropDownList>
						</td>
					</tr>
				</tbody>
			</table>
            <table class="wfrom-table" >
                <tbody>
                	<tr>
						<td colspan="2"><span class="input-label">上传路径:</span><br>
						<div class="wtips"><asp:label id=txtpath runat="server"></asp:label></div></td>
					</tr>
					<tr>
						<td class="label" style="width: 70px;">类型：</td>
						<td>
							<label class="input-check" ><input onclick=show1() type=radio CHECKED value=1 name=optshow>上传文件</label> 
							<label class="input-check" ><input onclick=show3() type=radio value=2 name=optshow > 外部下载</label> 
						</td>
					</tr>
					<tr>
						<td class="label">上传个数:</td>
						<td>
						<input class="input-text" id="upcount" type="text" size="7" value="5" name="upcount">
						<input class="wbtn-3" type="button" onclick="setid();" value="设定" name="Button">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
						<label class="input-check wtc-1EA7DE">
							  <INPUT type=checkbox CHECKED name=autorename id=autorename runat="server" onChange="EditOpt();"> 
							  重名文件自动更名
						</label> 
						</td>
					</tr>
                </tbody>
            </table>
			<table class="wfrom-table"  id=type1 >
				<tbody>
					<tr>
						<td colspan="2">
							<div style="margin-bottom:5px;">
								<label class="input-file"><span>选择文件</span><UPLOAD:INPUTFILE id="UpLoad1" runat="server" ></UPLOAD:INPUTFILE><span class="upload-text"></span></label><label class="input-label">文件描述：</label><input type="text" class="input-text" id=note name=note>
							</div>
                                <asp:placeholder id=Panel1 runat="server"></asp:placeholder>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<UPLOAD:PROGRESSBAR  id="inlineProgressBar" runat="server"  inline="true" Triggers="btn_upload"></UPLOAD:PROGRESSBAR>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<A class="get-page" href="uploadA.aspx<%=outstr%>" > <span class=" wtc-1EA7DE">点击这里使用浏览器插件上传（可选择多文件同时上传，支持大文件和断点续传）</span></A>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<input class="wbtn-1" id=btn_upload type=button value=" 上 传 " name=btn_upload runat="server" onserverclick="btn_upload_ServerClick" onclick="return btn_upload_onclick()"> 
							<input class="wbtn-2" id=btn_return type=button value="取 消" name=btn_return onclick="tipWindowClose()"> 
							&nbsp;&nbsp;&nbsp;&nbsp;<span class="wtc-999"><asp:label id=notype runat="server"></asp:label></span>
							<input id=Hidpath2 type=hidden size=1 name=Hidpath  runat="server">
							<input id=maxsize type=hidden name=maxsize runat="server"> 
							<input id=hidurl type=hidden name=hidurl runat="server">
						</td>
					</tr>
				</tbody>
			</table>
			<table class="wfrom-table"  id=type2 style="display:none;">
				<tbody>
					<tr id="download">
						<td colspan="2"><span class="input-label">下载地址 :</span>
							<input type="text" class="input-text" name=textBoxFileURL id=textBoxFileURL style="width:320px;"/>
							<span class="input-label">文件描述 :</span>
							<input class="input-textarea" id=note2 name=note2  style="width:310px;height:35px"></input>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<INPUT class="wbtn-1" id=progressStartButton onclick=StartEverything(this); type=button value=" 下 载 " name=progressStartButton> 
							&nbsp;<INPUT class="wbtn-2" id=btn_return2  type=button value="取消"  onclick="tipWindowClose()" name=btn_return1> 
							&nbsp;&nbsp;&nbsp;&nbsp;<span class="wtc-f00">（填写外部要下载到空间中的文件地址，为直接下载地址，如：http://www.xxx.com/xxx.zip） </span>
                             <p>
                            <p><asp:literal id=progressVariables runat="server"></asp:literal></p>
                            <div id=progressNotices style="FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: Verdana; HEIGHT: 14px" ></div>
                            <div id=progressBarArea style="DISPLAY: none"  >
								<div style="BORDER-RIGHT: gray 1px inset; PADDING-RIGHT: 1px; BORDER-TOP: gray 1px inset; PADDING-LEFT: 1px; PADDING-BOTTOM: 1px; MARGIN: 14px; BORDER-LEFT: gray 1px inset; PADDING-TOP: 1px; BORDER-BOTTOM: gray 1px inset" >
									<div id=progressBar style="WIDTH: 0%; COLOR: navy; HEIGHT: 22px; BACKGROUND-COLOR: navy" ></div></div>
								<asp:literal id=progressAlert runat="server"></asp:literal></div>
								<iframe id=progressIFrame style="POSITION: absolute" name=progressIFrame  src="about:blank" frameBorder=0 width=0 scrolling=no height=0></iframe>
						</td>
					</tr>
					</tbody></table>
			<div id="tip"></div>
	
		</form>

	</body>
</HTML>
