<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=popbox}-->
<!--{include file=elements/header.js.html type=swfupload}-->
<script src="js/picture.hd.js"></script>
<script >
window.onload = function() {
	var myupload = new SWFUpload({
		// Backend Settings
		upload_url: "index.php?r=picture.upload",
		file_post_name :"ImageFile",
		post_params: {
			"PHPSESSID" : "<!--{$PHPSESSIONID}-->",
			"picture_id": "<!--{$picture.id}-->"
		},

		// File Upload Settings
		file_size_limit : "20480", // 20MB
		file_types : "*.jpg;*.jpeg;*.gif;*.png",
		file_types_description : "图片文件",
		file_upload_limit : 0,
		file_queue_limit : 0,

		// Event Handler Settings (all my handlers are in the Handler.js file)
		swfupload_preload_handler : preLoad,
		swfupload_load_failed_handler : loadFailed,
		file_dialog_start_handler : fileDialogStart,
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,

		// Button Settings
		button_image_url : "js/swfupload/FullyTransparent_65x29.png",
		button_placeholder_id : "swfu",
		button_width: 80,
		button_height: 20,
		button_text: '<span class="theFont">本地上传</span>',
		button_text_style: ".theFont { cursor:pointer; }",
		button_text_left_padding: 12,
		button_window_mode:"transparent",

		// Flash Settings
		flash_url : "js/swfupload/swfupload.swf",
		flash9_url : "js/swfupload/swfupload_fp9.swf",
		custom_settings : {
			progressTarget : "fsUploadProgress1",
			cancelButtonId : "btnCancel1"
		},

		// Debug Settings
		debug: false
	});
 }
</script>
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>模块管理&nbsp;&gt;&nbsp;图片模块&nbsp;&gt;&nbsp;内容管理&nbsp;&gt;&nbsp;详细图片列表&nbsp;&gt;&nbsp;<!--{$picture.title}-->
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=Picture.picturelist" class="nolink">内管管理</a>
				<a href="index.php?r=SiteSet.pictureset" class="link">属性设置</a>
				<a href="index.php?r=Picture.pictureListLayout" class="link">列表页布局</a>
					<a href="index.php?r=Picture.picturePageLayout" class="link">内容页布局</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent3">
					<div class="operation">
						<span class="but4font" id="li_uploadpicture"><span id="swfu">本地上传</span></span>
						<button type="button" class="but4font" onclick="crawlpicture()">在线抓取</button>
					</div>
					<div id="swf-upload-cpanel" style="display:none;">
						<div class="fieldset flash" id="fsUploadProgress1">
						</div>
						<div style="padding-left: 5px;display:none;">
							<input id="btnCancel1" type="button" value="Cancel Uploads" onClick="cancelQueue(upload1);" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" />
						</div>
					</div>
				<!--<div class="div_hidden"><input id="input_picture_id" value="<!--{$picture.id}-->"/></div>-->
					<form name="addForm" action="index.php?r=Picture.addpicturedetail&picture_id=<!--{$picture_id}-->" method="post">
					<input type="hidden" name="action" value="do"/>
					<input type="hidden" name="returnParams" value="<!--{$returnParams}-->"/>
					<table class="tbl_list" id="tbl_uploadpicture" cellpadding="0" cellspacing="0" width="100%" border="0">
						<tr class="thead">
							<td width="40%">缩略图</td>
							<td width="15%">类型/大小(K)</td>
							<td width="15%">宽度</td>
							<td width="15%">高度</td>
							<td width="15%">操作</td>
						</tr>
						<!--{foreach from=$datalist item=item name=list}-->
						<tr onMouseOver="chgTrColor(this)" onMouseOut="chgTrColor(this)">
							<td><img src="<!--{$item.small_thumbnail_img_url|UT_FILE_PATH:true}-->"/></td>
							<td><!--{$item.file_type}-->/<!--{$item.file_size}--></td>
							<td><!--{$item.img_width}--></td>
							<td><!--{$item.img_height}--></td>
							<td id="td_deletePictureDetail<!--{$item.id}-->"><a href="javascript:deletePictureDetail('<!--{$item.id}-->')">删除</a></td>
						</tr>
						<!--{/foreach}-->
					</table>
					<div class="submitdiv">
						<button type="submit" class="butsubmit" onClick="submitPicture()">提交</button>
						<!--{if $backFlag eq 1}-->&nbsp;&nbsp;<button type="button" class="but2font" onClick="window.location.href='index.php?<!--{$returnParams}-->'">返回</button><!--{/if}--></div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
//删除
function deletePictureDetail(id){
	if (confirm('删除之后，信息无法恢复，是否确定删除？')) {
		var tdObj = $("#td_deletePictureDetail"+id);
		$(tdObj).html("<img src=\"images/ajax.gif\"/>");
		$.get("index.php?r=Picture.deletepicturedetail&id="+id, function(data){
			if (data == 1) {
				$(tdObj).parent().remove();
			} else {
				alert("删除失败");
			}
		});
	}
}

//修改
function editPictureDetail(id, detaillistReturnParams){
	$.popbox({title:"修改详细图片", content:popstr_search});
	$.ajax({
		type: "get",
		url: "index.php?r=Picture.editpicturedetail",
		data: {
			id: id,
			detaillistReturnParams: detaillistReturnParams
		},
		cache: false,
		success: function(data){
			$.popbox.setcontent({title:"修改详细图片", content:data});
		}
	});
}

//提交
function submitPicture(){
	var flag = 1;
	$(".required").each(function(){
		if (!$(this).val()) {
			flag = 0;
			$(this).next("span").html("&nbsp;*");
		} else {
			$(this).next("span").html("");
		}
	});
	if (flag == 1) {
		document.forms['addForm'].submit();
	} else {
		alert("请输入图片上传地址");
	}
}

//在线抓取
function crawlpicture(){
	var str = "<table class=\"tbl_edit\" width=\"100%\"><tr><td>输入远程图片地址</td></tr></table>";
	str += "<table id=\"tbl_crawlurl\" class=\"tbl_edit\" width=\"100%\"><tr><td><input type=\"text\" class=\"text\" name=\"url[]\"/></td></tr></table>";
	str += "<table class=\"tbl_edit\" width=\"100%\"><tr>";
	str += "<td class=\"noborder\"><button type=\"button\" class=\"but4font\" id=\"addcrawlbtn\">增加地址</button>&nbsp;&nbsp;<button type=\"button\" class=\"but2font\" id=\"crawlbtn\">抓取</button></td>";
	str += "</tr></table>";
	$.popbox({title:"在线抓取", content:str, height:300});
	$("#addcrawlbtn").click(function(){
		//if ($("input:text[name=url[]]").size() < 5) {
			$("#tbl_crawlurl").append("<tr><td><input type=\"text\" class=\"text\" name=\"url[]\"/></td></tr>");
		//} else {
		//	alert("一次最多只能抓取5张图片！");
		//}
	});
	$("#crawlbtn").click(function(){
		if ($(this).text() == "重新抓取") {
			$(this).attr("class", "but2font").text("抓取");
			$("#tbl_crawlurl").html("<tr><td><input type=\"text\" class=\"text\" name=\"url[]\"/></td></tr>");
			$("#addcrawlbtn").attr("disabled", false);
		} else {
			$("input:text[name=url[]]").each(function(){
				var remoteurl = $(this).val();
				var tdobj = $(this).parent();
				if (remoteurl != "") {
					tdobj.html("抓取"+remoteurl+"<img src=\"images/spinner.gif\"/>正在抓取...");
					$.ajax({
						type: "get",
						url: "index.php?r=Picture.savepicture",
						async: false,
						cache: false,
						data: {
							url: remoteurl,
							picture_id: <!--{$picture.id}-->
						},
						dataType: "json",
						success: function(data){
							if (data.status == 1) {
								updateTableList(data.data);
								tdobj.html("抓取"+remoteurl+"成功！");
							} else {
								tdobj.html("抓取"+remoteurl+"成功！");
							}
						}
					});
				} else {
					tdobj.html("没有输入地址...");
				}
			});
			$("#addcrawlbtn").attr("disabled", true);
			$(this).attr("class", "but4font").text("重新抓取");
		}
	});
}

function updateTableList(data){
	var str = "<tr>";
	str += "<td><img src='.."+data.thumb+"'/></td>";
	str += "<td>"+data.fileext+"/"+data.size+"</td>";
	str += "<td>"+data.width+"</td>";
	str += "<td>"+data.height+"</td>";
	str += "<td id=\"td_deletePictureDetail"+data.id+"\"><a class=\"link\" href=\"javascript:deletePictureDetail('"+data.id+"')\">删除</a></td>";
	str += "</tr>";
	$("#tbl_uploadpicture").append(str);
}
</script>
</html>