<!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=upload}-->
<!--{include file=elements/header.js.html type=swfupload}-->
<!--{include file=elements/header.js.html type=valid}-->
<script src="js/package.hd.js"></script>
<style>
div.button {color:#00f;display:inline;line-height:22px;margin-left:5px;padding:2px 0;}
div.button.hover {color:#f00;}
.typesizeinput {width:30px;}
.anchorinput {width:80px;}
</style>
<script>
window.onload = function() {
	var serialupload = new SWFUpload({
		// Backend Settings
		upload_url: "index.php?r=Game.gamepackageupload",
		file_post_name: "package_file",
		post_params: {
			"PHPSESSID": "<!--{$PHPSESSIONID}-->",
			"gameid": "<!--{$gameid}-->"
		},

		// File Upload Settings
		file_size_limit : "204800",	// 200MB
		file_types : "*.jar;*.jad;*.sis;*.sisx;*.zip;*.rar;*.mrp;*.apk",
		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 : "serial_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
	});

	function uploadScreenSuccess(file, serverData) {
		try {
			var od = eval('('+serverData+')');
			var progress = new FileProgress(file, this.customSettings.progressTarget);
			if(od.flag ==1){
				progress.setComplete();
				progress.setStatus(od.filename+"上传成功！");
				createScreenTD(od);
			}else{
				progress.setError();
				progress.setStatus(od.filename+"上传失败！");
			}
			progress.toggleCancel(false);
		} catch (ex) {
			this.debug(ex);
		}
	}
	
	var screenupload = new SWFUpload({
		// Backend Settings
		upload_url: "index.php?r=Game.gamepackageupload",
		file_post_name: "package_file",
		post_params: {
			"PHPSESSID": "<!--{$PHPSESSIONID}-->",
			"gameid": "<!--{$gameid}-->"
		},

		// File Upload Settings
		file_size_limit : "204800",	// 200MB
		file_types : "*.jar;*.jad;*.sis;*.sisx;*.zip;*.rar;*.mrp;*.apk",
		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 : uploadScreenSuccess,
		upload_complete_handler : uploadComplete,

		// Button Settings
		button_image_url : "js/swfupload/FullyTransparent_65x29.png",
		button_placeholder_id : "screen_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
	});
}

$(document).ready(function(){
	$("#serialuploadbutton").click(function(){
		serialcount = serialcount + 1;
		var str = "<tr>";
		str = str + "<input type=\"hidden\" name=\"screenid[]\" value=\"\"/>";
		str = str + "<input type=\"hidden\" name=\"packagetype[]\" value=\"1\"/>";
		str = str + "<input type=\"hidden\" name=\"downloadtype[]\" value=\"1\"/>";
		str = str + "<td><div style=\"display:inline;padding:2px 0 2px 4px;\"><span class=\"red\">*</span><input id=\"comminput1"+serialcount+"\" name=\"commpackage[]\" type=\"text\" class=\"anchorinput vcommpackage\" readonly/></div>";
		str = str + "<div id=\"commbutton1"+serialcount+"\" class=\"button\" indexno=\""+serialcount+"\">上传</div><div id=\"oldname1"+serialcount+"\" style=\"display:inline;\"></div></td>";
		str = str + "<td><div style=\"display:inline;padding:2px 0 2px 4px;\"><input id=\"jadinput1"+serialcount+"\" name=\"jadpackage[]\" type=\"text\" class=\"anchorinput\" readonly/></div>";
		str = str + "<div id=\"jadbutton1"+serialcount+"\" class=\"button\" indexno=\""+serialcount+"\">上传</div></td>";
		str = str + "<td><span class=\"red\">*</span><select class=\"vmustselect\" id=\"slc_brand"+serialcount+"\" onchange=\"changeSerial('"+serialcount+"')\">";
		str += $("#slc_brand").html();
		str += "</select></td>";
		str = str + "<td><span class=\"red\">*</span><select class=\"slc_serial vmustselect\" id=\"slc_serial"+serialcount+"\" name=\"serialid[]\" onchange=\"checkSerial('"+serialcount+"')\">";
		str = str + "<option value=\"\">机型系列</option>";
		str = str + "</select></td>";
		str = str + "<td><input id=\"typeinput1"+serialcount+"\" name=\"type[]\" type=\"text\" class=\"typesizeinput\" readonly/>&nbsp;";
		str = str + "<input id=\"sizeinput1"+serialcount+"\" name=\"size[]\" type=\"text\" class=\"typesizeinput\" readonly/></td>";
		str = str + "<td><input id=\"orderinput1"+serialcount+"\" name=\"showorder[]\" type=\"text\" class=\"typesizeinput\" value=\"99\"/></td>";
		str = str + "<td><a href=\"#\" id=\"delete1"+serialcount+"\" indexno=\""+serialcount+"\">删除</a><input id=\"old_filename1"+serialcount+"\" type=\"hidden\" name=\"old_filename[]\" value=\"\"/></td>";
		$("#serialuploader").prepend(str);
		$("#delete1"+serialcount).click(function(){
			/*var indexno = $(this).attr("indexno");
			var tdobj = $(this).parent();
			$(tdobj).html('<img src="images/ajax.gif"/>');
			if($("#comminput1"+indexno).val() || $("#jadinput1"+indexno).val()){
				$.post("index.php?r=Game.deletepackage",
						{
							download_url : $("#comminput1"+indexno).val(),
							download_additional_url : $("#jadinput1"+indexno).val()
						}, 
						function(data){
							$(tdobj).parent().remove();
				});
			} else {
				$(tdobj).parent().remove();
			}*/
			$(this).parent().parent().remove();
		});

		var commbutton = $("#commbutton1"+serialcount);
		new AjaxUpload(commbutton, {
			action: 'index.php?r=Game.gamepackageupload',
			name: 'package_file',
			data: {
				'gameid' : $("#gameid").val()
			},
			onSubmit : function(file, ext){
				if ((ext && /^(jad)$/i.test(ext))){
		        	alert(ext+'文件请用jad专用上传按钮上传！');
		        	return false;
				}
				this.disable();
				commbutton.html('<img src="images/ajax.gif"/>');
			},
			onComplete: function(file, response){
				commbutton.html('上传');
				this.enable();
				var data = eval("("+response+")");
				if(data.flag == 1){
					var indexno = $(commbutton).attr("indexno");
					$("#comminput1"+indexno).val(data.name);
					$("#oldname1"+indexno).html("("+data.filename+"."+data.fileext+")");
					$("#old_filename1"+indexno).val(data.filename);
					$("#sizeinput1"+indexno).val(data.size);
					$("#typeinput1"+indexno).val(data.fileext);
				} else if(data.flag == -2){
					alert("不能上传格式为" + data.fileext + "的文件!");
				} else if(data.flag == -3){
					alert("上传文件的大小超出指定范围!");
				} else {
					alert("上传文件失败!");
				}
			}
		});

		var jadbutton = $("#jadbutton1"+serialcount);
		new AjaxUpload(jadbutton, {
			action: 'index.php?r=Game.gamepackageupload',
			name: 'package_file',
			data: {
				'gameid' : $("#gameid").val()
			},
			onSubmit : function(file, ext){
				if (! (ext && /^(jad)$/i.test(ext))){
		        	alert('jad专用上传按钮不能上传'+ext+'文件！');
		        	return false;
				}
				this.disable();
				jadbutton.html('<img src="images/ajax.gif"/>');
			},
			onComplete: function(file, response){
				jadbutton.html('上传');
				this.enable();
				var data = eval("("+response+")");
				if(data.flag == 1){
					var indexno = $(jadbutton).attr("indexno");
					$("#jadinput1"+indexno).val(data.name);
				} else if(data.flag == -2){
					alert("不能上传格式为" + data.fileext + "的文件!");
				} else if(data.flag == -3){
					alert("上传文件的大小超出指定范围!");
				} else {
					alert("上传文件失败!");
				}
			}
		});
	});

	$("#serialanchorbutton").click(function(){
		serialcount = serialcount + 1;
		var str = "<tr>";
		str = str + "<input type=\"hidden\" name=\"screenid[]\" value=\"\"/>";
		str = str + "<input type=\"hidden\" name=\"packagetype[]\" value=\"1\"/>";
		str = str + "<input type=\"hidden\" name=\"downloadtype[]\" value=\"2\"/>";
		str = str + "<td>&nbsp;<span class=\"red\">*</span><input id=\"comminput2"+serialcount+"\" name=\"commpackage[]\" type=\"text\" class=\"anchorinput vcommpackage\"/></td>";
		str = str + "<td>&nbsp;<input id=\"jadinput2"+serialcount+"\" name=\"jadpackage[]\" type=\"text\" class=\"anchorinput\"/></td>";
		str = str + "<td><span class=\"red\">*</span><select class=\"vmustselect\" id=\"slc_brand"+serialcount+"\" onchange=\"changeSerial('"+serialcount+"')\">";
		str += $("#slc_brand").html();
		str += "</select></td>";
		str = str + "<td><span class=\"red\">*</span><select class=\"slc_serial vmustselect\" id=\"slc_serial"+serialcount+"\" name=\"serialid[]\" onchange=\"checkSerial('"+serialcount+"')\">";
		str = str + "<option value=\"\">机型系列</option>";
		str = str + "</select></td>";
		str = str + "<td><input id=\"typeinput2"+serialcount+"\" name=\"type[]\" type=\"text\" class=\"typesizeinput\"/>&nbsp;";
		str = str + "<input id=\"sizeinput2"+serialcount+"\" name=\"size[]\" type=\"text\" class=\"typesizeinput\"/></td>";
		str = str + "<td><input id=\"orderinput2"+serialcount+"\" name=\"showorder[]\" type=\"text\" class=\"typesizeinput\" value=\"99\"/></td>";
		str = str + "<td><a href=\"#\" id=\"delete2"+serialcount+"\">删除</a></td>";
		$("#serialuploader").prepend(str);
		$("#delete2"+serialcount).click(function(){
			$(this).parent().parent().remove();
		});
	});


	$("#screenuploadbutton").click(function(){
		screencount = screencount + 1;
		var str = "<tr>";
		str = str + "<input type=\"hidden\" name=\"serialid[]\" value=\"\"/>";
		str = str + "<input type=\"hidden\" name=\"packagetype[]\" value=\"2\"/>";
		str = str + "<input type=\"hidden\" name=\"downloadtype[]\" value=\"1\"/>";
		str = str + "<td><div style=\"display:inline;padding:2px 0 2px 4px;\"><span class=\"red\">*</span><input id=\"comminput3"+screencount+"\" name=\"commpackage[]\" type=\"text\" class=\"anchorinput vcommpackage\" readonly/></div>";
		str = str + "<div id=\"commbutton2"+screencount+"\" class=\"button\" indexno=\""+screencount+"\">上传</div><div id=\"oldname3"+screencount+"\" style=\"display:inline;\"></div></td>";
		str = str + "<td><div style=\"display:inline;padding:2px 0 2px 4px;\"><input id=\"jadinput3"+screencount+"\" name=\"jadpackage[]\" type=\"text\" class=\"anchorinput\" readonly/></div>";
		str = str + "<div id=\"jadbutton2"+screencount+"\" class=\"button\" indexno=\""+screencount+"\">上传</div></td>";
		str = str + "<td><span class=\"red\">*</span><select id=\"slc_screen"+screencount+"\" name=\"screenid[]\" class=\"slc_screen vmustselect\" onchange=\"checkScreen('"+screencount+"')\">";
		str = str + $("#slc_screen").html();
		str = str + "</select></td>";
		str = str + "<td><input id=\"typeinput3"+screencount+"\" name=\"type[]\" type=\"text\" class=\"typesizeinput\" readonly/>&nbsp;";
		str = str + "<input id=\"sizeinput3"+screencount+"\" name=\"size[]\" type=\"text\" class=\"typesizeinput\" readonly/></td>";
		str = str + "<td><input id=\"orderinput3"+screencount+"\" name=\"showorder[]\" type=\"text\" class=\"typesizeinput\" value=\"99\"/></td>";
		str = str + "<td><a href=\"#\" id=\"delete3"+screencount+"\" indexno=\""+screencount+"\">删除</a><input id=\"old_filename3"+screencount+"\" type=\"hidden\" name=\"old_filename[]\" value=\"\"/></td>";
		$("#screenuploader").prepend(str);
		$("#delete3"+screencount).click(function(){
			/*var indexno = $(this).attr("indexno");
			var tdobj = $(this).parent();
			$(tdobj).html('<img src="images/ajax.gif"/>');
			if($("#comminput3"+indexno).val() || $("#jadinput3"+indexno).val()){
				$.post("index.php?r=Game.deletepackage",
						{
							download_url : $("#comminput3"+indexno).val(),
							download_additional_url : $("#jadinput3"+indexno).val()
						}, 
						function(data){
							$(tdobj).parent().remove();
				});
			} else {
				$(tdobj).parent().remove();
			}*/
			$(this).parent().parent().remove();
		});

		var commbutton = $("#commbutton2"+screencount);
		new AjaxUpload(commbutton, {
			action: 'index.php?r=Game.gamepackageupload',
			name: 'package_file',
			data: {
				'gameid' : $("#gameid").val()
			},
			onSubmit : function(file, ext){
				if ((ext && /^(jad)$/i.test(ext))){
					alert(ext+'文件请用jad专用上传按钮上传！');
		        	return false;
				}
				this.disable();
				commbutton.html('<img src="images/ajax.gif"/>');
			},
			onComplete: function(file, response){
				commbutton.html('上传');
				this.enable();
				var data = eval("("+response+")");
				if(data.flag == 1){
					var indexno = $(commbutton).attr("indexno");
					$("#comminput3"+indexno).val(data.name);
					$("#oldname3"+indexno).html("("+data.filename+"."+data.fileext+")");
					$("#old_filename3"+indexno).val(data.filename);
					$("#sizeinput3"+indexno).val(data.size);
					$("#typeinput3"+indexno).val(data.fileext);
				} else if(data.flag == -2){
					alert("不能上传格式为" + data.fileext + "的文件!");
				} else if(data.flag == -3){
					alert("上传文件的大小超出指定范围!");
				} else {
					alert("上传文件失败!");
				}
			}
		});

		var jadbutton = $("#jadbutton2"+screencount);
		new AjaxUpload(jadbutton, {
			action: 'index.php?r=Game.gamepackageupload',
			name: 'package_file',
			data: {
				'gameid' : $("#gameid").val()
			},
			onSubmit : function(file, ext){
				if (! (ext && /^(jad)$/i.test(ext))){
					alert('jad专用上传按钮不能上传'+ext+'文件！');
		        	return false;
				}
				this.disable();
				jadbutton.html('<img src="images/ajax.gif"/>');
			},
			onComplete: function(file, response){
				jadbutton.html('上传');
				this.enable();
				var data = eval("("+response+")");
				if(data.flag == 1){
					var indexno = $(jadbutton).attr("indexno");
					$("#jadinput3"+indexno).val(data.name);
				} else if(data.flag == -2){
					alert("不能上传格式为" + data.fileext + "的文件!");
				} else if(data.flag == -3){
					alert("上传文件的大小超出指定范围!");
				} else {
					alert("上传文件失败!");
				}
			}
		});
	});

	$("#screenanchorbutton").click(function(){
		screencount = screencount + 1;
		var str = "<tr>";
		str = str + "<input type=\"hidden\" name=\"serialid[]\" value=\"\"/>";
		str = str + "<input type=\"hidden\" name=\"packagetype[]\" value=\"2\"/>";
		str = str + "<input type=\"hidden\" name=\"downloadtype[]\" value=\"2\"/>";
		str = str + "<td>&nbsp;<span class=\"red\">*</span><input id=\"comminput4"+screencount+"\" name=\"commpackage[]\" type=\"text\" class=\"anchorinput vcommpackage\"/></td>";
		str = str + "<td>&nbsp;<input id=\"jadinput4"+screencount+"\" name=\"jadpackage[]\" type=\"text\" class=\"anchorinput\"/></td>";
		str = str + "<td><span class=\"red\">*</span><select id=\"slc_screen"+screencount+"\" name=\"screenid[]\" class=\"slc_screen vmustselect\" onchange=\"checkScreen('"+screencount+"')\">";
		str = str + $("#slc_screen").html();
		str = str + "</select></td>";
		str = str + "<td><input id=\"typeinput4"+screencount+"\" name=\"type[]\" type=\"text\" class=\"typesizeinput\"/>&nbsp;";
		str = str + "<input id=\"sizeinput4"+screencount+"\" name=\"size[]\" type=\"text\" class=\"typesizeinput\"/></td>";
		str = str + "<td><input id=\"orderinput4"+screencount+"\" name=\"showorder[]\" type=\"text\" class=\"typesizeinput\" value=\"99\"/></td>";
		str = str + "<td><a href=\"#\" id=\"delete4"+screencount+"\">删除</a></td>";
		$("#screenuploader").prepend(str);
		$("#delete4"+screencount).click(function(){
			$(this).parent().parent().remove();
		});
	});

	$("#addForm").submit(function(){
		flag = 1;
		/*$(".vorder").each(function(){
			if($(this).val() && !(/^\d+$/.test($(this).val()))){
				flag = 0;
			}
		});
		$(".vsize").each(function(){
			if($(this).val() && !(/^\d+$/.test($(this).val()))){
				flag = 0;
			}
		});
		$(".vtype").each(function(){
			if(!$(this).val()){
				flag = 0;
			}
		});*/
		$(".vcommpackage").each(function(){
			if(!$(this).val()){
				flag = 0;
			}
		});
		$(".vmustselect").each(function(){
			if(!$(this).val()){
				flag = 0;
			}
		});
		if(flag == 0){
			alert("输入有误，红色*处为必填内容！");
			return false;
		}
	});
});

function deleteserialgamepackage(deleteanchor, id, serial){
	if (confirm('删除之后，信息无法恢复，是否确定删除？')) {
		var tdobj = $(deleteanchor).parent();
		$(tdobj).html('<img src="images/ajax.gif"/>');
		$.get("index.php?r=Game.deletegamepackage&id="+id, function(data){
			if(data == "1"){
				$(tdobj).parent().remove();
				for(i = 0; i < hasSerials.length; i++){
					if(serial == hasSerials[i].serial){
						hasSerials.remove(i);
						return true;
					}
				}
			} else {
				alert("删除失败！");
			}
		});
	}
}

function deletescreengamepackage(deleteanchor, id){
	if (confirm('删除之后，信息无法恢复，是否确定删除？')) {
		var tdobj = $(deleteanchor).parent();
		$(tdobj).html('<img src="images/ajax.gif"/>');
		$.get("index.php?r=Game.deletegamepackage&id="+id, function(data){
			if (data == 1) {
				$(tdobj).parent().remove();
			} else {
				alert("删除失败！");
			}
		});
	}
}

function packedit(id, pakListReturnParams){
	$.popbox({title:"修改游戏包", content:popstr_search});
	$.post("index.php?r=Game.packedit", {id: id, pakListReturnParams: pakListReturnParams}, function(str){
		$.popbox.setcontent({title:"修改游戏包", content:str, height:420});
	});
}
</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;游戏包管理
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=Game.resource" class="nolink">内管管理</a>
				<a href="index.php?r=SiteSet.gameset" class="link">属性设置</a>
				<a href="index.php?r=Layout.module&id=5" class="link">列表页布局</a>
				<a href="index.php?r=Layout.module&id=6" class="link">内容页布局</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent2">
					<div style="display:none">
						<select id="slc_brand">
							<option value="">手机品牌</option>
							<!--{foreach from=$brand item=item}-->
							<option value="<!--{$item.id}-->"><!--{$item.brand_name}--></option>
							<!--{/foreach}-->
						</select>
						<select id="slc_serial">
							<option value="">机型系列</option>
							<!--{foreach from=$serial item=item}-->
							<option value="<!--{$item.id}-->" brand_id="<!--{$item.mobile_brand_id}-->"><!--{$item.serial}--></option>
							<!--{/foreach}-->
						</select>
						<select id="slc_screen">
							<option value="">手机屏幕</option>
							<!--{foreach from=$screen item=item}-->
							<option value="<!--{$item.id}-->"><!--{$item.screen_size}--></option>
							<!--{/foreach}-->
						</select>
					</div>
					<div class="tabcontentThr">
						<a href="javascript:showSerial()" id="showseriallink" class="onlink">按系列上传</a>
						<a href="javascript:showScreen()" id="showscreenlink" class="link">按屏幕上传</a>
					</div>
					<form id="addForm" action="index.php?r=Game.editgamepackage" method="post">
						<input type="hidden" name="action" value="do"/>
						<input type="hidden" id="gameid" name="gameid" value="<!--{$gameid}-->"/>
						<!--{if $returnParams != null}--><input type="hidden" name="returnParams" id="returnParams" value="<!--{$returnParams}-->"/><!--{/if}-->
						<!--{if $redirectParams != null}--><input type="hidden" name="redirectParams" id="returnParams" value="<!--{$redirectParams}-->"/><!--{/if}-->
						<div id="seriallist">
							<div class="operation">
								<button type="button" class="but4font" id="serialuploadbutton">新增包</button>
								<button type="button" class="but4font" id="serialanchorbutton">新增链接</button>
								<span class="but4font"><span id="serial_swfu">批量上传</span></span>
								<button type="button" class="but4font" onclick="crawlgame('serial')">在线抓取</button>
								<button type="button" class="but4font" onclick="ftppopbox('serial')">FTP导入</button>
							</div>
							<table class="tbl_list" width="100%">
								<tr class="thead">
									<td width="20%">包上传/链接</td>
									<td width="20%">Jad上传/链接</td>
									<td width="15%">品牌</td>
									<td width="15%">系列</td>
									<td width="10%">类型/大小(K)</td>
									<td width="10%">顺序</td>
									<td width="10%">操作</td>
								</tr>
								<tbody id="serialuploader">
								<!--{foreach from=$packages item=data}-->
									<!--{if $data.package_type == 1}-->
										<tr onMouseOver="chgTrColor(this)" onMouseOut="chgTrColor(this)">
											<td style="word-break:break-all"><!--{$data.download_url}--></td>
											<td style="word-break:break-all"><!--{$data.download_additional_url}--></td>
											<td><!--{$data.brand_name}--></td>
											<td><!--{$data.serial}--><input type="hidden" class="input_serial" id="input_serial<!--{$data.id}-->" value="<!--{$data.mobile_serial_id}-->"/></td>
											<td><!--{$data.file_type}-->/<!--{$data.file_size}--></td>
											<td><!--{$data.show_order}--></td>
											<td><a href="javascript:packedit(<!--{$data.id}-->, '<!--{$pakListReturnParams}-->')">修改</a>&nbsp;<a href="#" onClick="deleteserialgamepackage(this, <!--{$data.id}-->, '<!--{$data.serial}-->')">删除</a></td>
										</tr>
									<!--{/if}-->
								<!--{/foreach}-->
								</tbody>
							</table>
						</div>
						<div id="screenlist" class="hidden">
							<div class="operation">
								<button type="button" class="but4font" id="screenuploadbutton">新增包</button>
								<button type="button" class="but4font" id="screenanchorbutton">新增链接</button>
								<span class="but4font"><span id="screen_swfu">批量上传</span></span>
								<button type="button" class="but4font" onclick="crawlgame('screen')">在线抓取</button>
								<button type="button" class="but4font" onclick="ftppopbox('screen')">FTP导入</button>
							</div>
							<table class="tbl_list" width="100%">
								<tr class="thead">
									<td width="20%">包上传/链接</td>
									<td width="20%">Jad上传/链接</td>
									<td width="25%">屏幕</td>
									<td width="15%">类型/大小(K)</td>
									<td width="10%">顺序</td>
									<td width="10%">操作</td>
								</tr>
								<tbody id="screenuploader">
								<!--{foreach from=$packages item=data}-->
									<!--{if $data.package_type == 2}-->
										<tr onMouseOver="chgTrColor(this)" onMouseOut="chgTrColor(this)">
											<td style="word-break:break-all;"><!--{$data.download_url}--></td>
											<td style="word-break:break-all;"><!--{$data.download_additional_url}--></td>
											<td><!--{$data.screen_size}--><input type="hidden" class="input_screen" id="input_screen<!--{$data.id}-->" value="<!--{$data.mobile_screen_id}-->"/></td>
											<td><!--{$data.file_type}-->/<!--{$data.file_size}--></td>
											<td><!--{$data.show_order}--></td>
											<td><a href="javascript:packedit(<!--{$data.id}-->, '<!--{$pakListReturnParams}-->')">修改</a>&nbsp;<a href="#" onClick="deletescreengamepackage(this, <!--{$data.id}-->, '<!--{$data.screen_size}-->')">删除</a></td>
										</tr>
									<!--{/if}-->
								<!--{/foreach}-->
								</tbody>
							</table>
						</div>
						<div class="submitdiv">
							<button type="submit" class="butsubmit">提交</button>
							<!--{if $returnParams != null}-->&nbsp;&nbsp;<button type="button" class="but2font" onClick="window.location.href='index.php?<!--{$returnParams}-->'">返回</button><!--{/if}-->
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</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>
</body>
<script>
var serialcount = 0;
var screencount = 0;

function showSerial(){
	$("#showseriallink").attr("class", "onlink");
	$("#showscreenlink").attr("class", "link");
	$("#seriallist").attr("class", "");
	$("#screenlist").attr("class", "hidden");
}
function showScreen(){
	$("#showseriallink").attr("class", "link");
	$("#showscreenlink").attr("class", "onlink");
	$("#seriallist").attr("class", "hidden");
	$("#screenlist").attr("class", "");
}

//显示系列
function changeSerial(i){
	if ($("#slc_brand"+i).val() == "") {
		$("#slc_serial"+i).html("<option value=\"\">机型系列</option>");
	} else {
		$("#slc_serial"+i).html($("#slc_serial").html());
		$("#slc_serial"+i).children().each(function(){
			if ($(this).val() != "" && $(this).attr("brand_id") != $("#slc_brand"+i).val()) {
				$(this).remove();
			}
		});
	}
}

//系列不能重复
function checkSerial(i){
	var serial = $("#slc_serial"+i);
	if (serial.val()) {
		$(".input_serial").each(function(){
			if ($(this).val() == serial.val()) {
				alert("系列不能重复");
				serial.val("");
			}
		});
		$(".slc_serial").each(function(){
			if ($(this).val() == serial.val() && $(this).val() != "" && $(this).attr("id") != serial.attr("id")) {
				alert("系列不能重复");
				serial.val("");
			}
		});
	}
}

//屏幕不能重复
function checkScreen(i){
	var screen = $("#slc_screen"+i);
	if (screen.val()) {
		$(".input_screen").each(function(){
			if ($(this).val() == screen.val()) {
				alert("屏幕不能重复");
				screen.val("");
			}
		});
		$(".slc_screen").each(function(){
			if ($(this).val() == screen.val() && $(this).val() != "" && $(this).attr("id") != screen.attr("id")) {
				alert("屏幕不能重复");
				screen.val("");
			}
		});
	}
}

function createTD(od){
	var create = true;
	$("input[name=old_filename[]]").each(function(){
		if($(this).val() == od.filename){
			if(od.fileext == 'jad'){
				$(this).parent().parent().find("input[name=jadpackage[]]").val(od.name);
			}else{
				$(this).parent().parent().find("input[name=commpackage[]]").val(od.name);
				$(this).parent().parent().find("span.oldname").html("("+od.filename+"."+od.fileext+")");
				$(this).parent().parent().find("input[name=type[]]").val(od.fileext);
				$(this).parent().parent().find("input[name=size[]]").val(od.size);
			}
			create = false;
		}
	});
	if (create) {
		serialcount = serialcount + 1;
		var index = serialcount;
		var str = "<tr>";
		str += "<td>&nbsp;<span class=\"red\">*</span><input class=\"anchorinput vcommpackage\" id=\"comminput1"+index+"\" name=\"commpackage[]\" readonly/><span id=\"oldname1"+index+"\" class=\"oldname\"></span></td>";
		str += "<td>&nbsp;<input class=\"anchorinput\" id=\"jadinput1"+index+"\" name=\"jadpackage[]\" readonly/></td>";
		str += "<td><span class=\"red\">*</span><select class=\"vmustselect\" id=\"slc_brand"+index+"\" onchange=\"changeSerial('"+index+"')\">";
		str += $("#slc_brand").html();
		str += "</select></td>";
		str += "<td><span class=\"red\">*</span><select class=\"slc_serial vmustselect\" id=\"slc_serial"+index+"\" name=\"serialid[]\" onchange=\"checkSerial('"+index+"')\">";
		str += "<option value=\"\">机型系列</option>";
		str += "</select></td>";
		str += "<td><input class=\"typesizeinput\" id=\"typeinput1"+index+"\" name=\"type[]\" readonly/>&nbsp;";
		str += "<input class=\"typesizeinput\" id=\"sizeinput1"+index+"\" name=\"size[]\" readonly/></td>";
		str += "<td><input class=\"typesizeinput\" name=\"showorder[]\" value=\"99\"/></td>";
		str += "<td><a href=\"#\" id=\"delete1"+index+"\">删除</a><input type=\"hidden\" name=\"packagetype[]\" value=\"1\"/><input type=\"hidden\" name=\"downloadtype[]\" value=\"1\"/><input type=\"hidden\" id=\"old_filename1"+index+"\" name=\"old_filename[]\"/></td>";
		str += "</tr>";
		$("#serialuploader").prepend(str);
		//删除事件
		$("#delete1"+serialcount).click(function(){
			var tdObj = $(this).parent();
			$(tdObj).parent().remove();
		});
		if (od.fileext == 'jad') {
			$("#jadinput1"+index).val(od.name);
		} else {
			$("#comminput1"+index).val(od.name);
			$("#oldname1"+index).html("("+od.filename+"."+od.fileext+")");
			$("#typeinput1"+index).val(od.fileext);
			$("#sizeinput1"+index).val(od.size);
		}
		$("#old_filename1"+index).val(od.filename);
	}
}

function createScreenTD(od){
	var create = true;
	$("input[name=old_filename[]]").each(function(){
		if($(this).val() == od.filename){
			if(od.fileext == 'jad'){
				$(this).parent().parent().find("input[name=jadpackage[]]").val(od.name);
			}else{
				$(this).parent().parent().find("input[name=commpackage[]]").val(od.name);
				$(this).parent().parent().find("span.oldname").html("("+od.filename+"."+od.fileext+")");
				$(this).parent().parent().find("input[name=type[]]").val(od.fileext);
				$(this).parent().parent().find("input[name=size[]]").val(od.size);
			}
			create = false;
		}
	});
	if (create) {
		screencount = screencount + 1;
		var index = screencount;
		var str = "<tr>";
		str += "<td>&nbsp;<span class=\"red\">*</span><input class=\"anchorinput commpackage\" id=\"comminput3"+index+"\" name=\"commpackage[]\" readonly/><span id=\"oldname3"+index+"\" class=\"oldname\"></span></td>";
		str += "<td>&nbsp;<input class=\"anchorinput\" id=\"jadinput3"+index+"\" name=\"jadpackage[]\" readonly/></td>";
		str += "<td><span class=\"red\">*</span><select class=\"slc_screen vmustselect\" id=\"slc_screen"+index+"\" name=\"screenid[]\" onchange=\"checkScreen('"+index+"')\">";
		str += $("#slc_screen").html();
		str += "</select></td>";
		str += "<td><input class=\"typesizeinput\" id=\"typeinput3"+index+"\" name=\"type[]\" readonly/>&nbsp;";
		str += "<input class=\"typesizeinput\" id=\"sizeinput3"+index+"\" name=\"size[]\" readonly/></td>";
		str += "<td><input class=\"typesizeinput\" name=\"showorder[]\" value=\"99\"/></td>";
		str += "<td><a href=\"#\" id=\"delete3"+index+"\">删除</a><input type=\"hidden\" name=\"packagetype[]\" value=\"2\"/><input type=\"hidden\" name=\"downloadtype[]\" value=\"1\"/><input type=\"hidden\" id=\"old_filename3"+index+"\" name=\"old_filename[]\"/></td>";
		str += "</tr>";
		$("#screenuploader").prepend(str);
		//删除事件
		$("#delete3"+screencount).click(function(){
			var tdObj = $(this).parent();
			$(tdObj).parent().remove();
		});
		if (od.fileext == 'jad') {
			$("#jadinput3"+index).val(od.name);
		} else {
			$("#comminput3"+index).val(od.name);
			$("#oldname3"+index).html("("+od.filename+"."+od.fileext+")");
			$("#typeinput3"+index).val(od.fileext);
			$("#sizeinput3"+index).val(od.size);
		}
		$("#old_filename3"+index).val(od.filename);
	}
}

//在线抓取
function crawlgame(type){
	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=Game.crawl",
						cache: false,
						data: {
							url: remoteurl,
							game_id: <!--{$gameid}-->
						},
						dataType: "json",
						success: function(data){
							if (data.status == 1) {
								if (data.file.file_type == 'jad') {
									$(".ftp_filename").each(function(){
										if (data.file.filename == $(this).val()) {
											$("#download_additional_url"+$(this).attr("index")).val(data.file.download_url);
										}
									});
								} else {
									if (type == "serial") {
										serialcount = serialcount + 1;
										var index = serialcount;
										var str = "<tr>";
										str += "<td>&nbsp;<span class=\"red\">*</span><input class=\"anchorinput vcommpackage\" id=\"download_url"+index+"\" name=\"commpackage[]\" value=\""+data.file.download_url+"\" readonly/>&nbsp;("+data.file.filename+"."+data.file.file_type+")</td>";
										str += "<td>&nbsp;<input class=\"anchorinput\" id=\"download_additional_url"+index+"\" name=\"jadpackage[]\" value=\""+data.file.download_additional_url+"\" readonly/></td>";
										str += "<td><span class=\"red\">*</span><select class=\"vmustselect\" id=\"slc_brand"+serialcount+"\" onchange=\"changeSerial('"+serialcount+"')\">";
										str += $("#slc_brand").html();
										str += "</select></td>";
										str += "<td><span class=\"red\">*</span><select class=\"slc_serial vmustselect\" id=\"slc_serial"+serialcount+"\" name=\"serialid[]\" onchange=\"checkSerial('"+serialcount+"')\">";
										str += "<option value=\"\">机型系列</option>";
										str += "</select></td>";
										str += "<td><input class=\"typesizeinput\" name=\"type[]\" value=\""+data.file.file_type+"\" readonly/>&nbsp;";
										str += "<input class=\"typesizeinput\" name=\"size[]\" value=\""+data.file.file_size+"\" readonly/></td>";
										str += "<td><input class=\"typesizeinput\" name=\"showorder[]\" value=\"99\"/><input type=\"hidden\" class=\"ftp_filename\" index=\""+index+"\" value=\""+data.file.filename+"\"/></td>";
										str += "<td><a href=\"#\" id=\"delete1"+serialcount+"\">删除</a><input type=\"hidden\" name=\"packagetype[]\" value=\"1\"/><input type=\"hidden\" name=\"downloadtype[]\" value=\"1\"/></td>";
										str += "</tr>";
										$("#serialuploader").prepend(str);
										$("#delete1"+serialcount).click(function(){
											$(this).parent().parent().remove();
										});
									} else {
										screencount = screencount + 1;
										var index = screencount;
										var str = "<tr>";
										str += "<td>&nbsp;<span class=\"red\">*</span><input class=\"anchorinput vcommpackage\" id=\"download_url"+index+"\" name=\"commpackage[]\" value=\""+data.file.download_url+"\" readonly/>&nbsp;("+data.file.filename+"."+data.file.file_type+")</td>";
										str += "<td>&nbsp;<input class=\"anchorinput\" id=\"download_additional_url"+index+"\" name=\"jadpackage[]\" value=\""+data.file.download_additional_url+"\" readonly/></td>";
										str += "<td><span class=\"red\">*</span><select class=\"slc_screen vmustselect\" id=\"slc_screen"+screencount+"\" name=\"screenid[]\" onchange=\"checkScreen('"+screencount+"')\">";
										str += $("#slc_screen").html();
										str += "</select></td>";
										str += "<td><input class=\"typesizeinput\" name=\"type[]\" value=\""+data.file.file_type+"\" readonly/>&nbsp;";
										str += "<input class=\"typesizeinput\" name=\"size[]\" value=\""+data.file.file_size+"\" readonly/></td>";
										str += "<td><input class=\"typesizeinput\" name=\"showorder[]\" value=\"99\"/><input type=\"hidden\" class=\"ftp_filename\" index=\""+index+"\" value=\""+data.file.filename+"\"/></td>";
										str += "<td><a href=\"#\" id=\"delete3"+screencount+"\">删除</a><input type=\"hidden\" name=\"packagetype[]\" value=\"2\"/><input type=\"hidden\" name=\"downloadtype[]\" value=\"1\"/></td>";
										str += "</tr>";
										$("#screenuploader").prepend(str);
										$("#delete3"+screencount).click(function(){
											$(this).parent().parent().remove();
										});
									}
								}
								tdobj.html("抓取"+remoteurl+"成功！");
							} else {
								tdobj.html("抓取"+remoteurl+"失败！");
							}
						}
					});
				} else {
					tdobj.html("没有输入地址...");
				}
			});
			$("#addcrawlbtn").attr("disabled", true);
			$(this).attr("class", "but4font").text("重新抓取");
		}
	});
}

//ftp导入
function ftppopbox(type){
	var ftpstr = "<table class=\"tbl_edit\" width=\"100%\"><tr>";
	ftpstr += "<td class=\"td_name\">请输入包地址</td>";
	ftpstr += "<td class=\"td_content\"><input type=\"text\" class=\"text\" id=\"ftpinput\" value=\"/uploads/game/\"/></td>";
	ftpstr += "</tr><tr>";
	ftpstr += "<td class=\"noborder\"></td>";
	ftpstr += "<td class=\"noborder\"><button type=\"button\" class=\"but2font\" onclick=\"ftpimport('"+type+"')\">导入</button></td>";
	ftpstr += "</tr></table><div id=\"ftpimport\"></div>";
	$.popbox({title:"FTP导入", content:ftpstr});
}
function ftpimport(type){
	$("#ftpimport").height(50).html(popstr_import);
	$.ajax({
		url: "index.php?r=Game.ftpimport&type="+type+"&ftppath="+$("#ftpinput").val(),
		type: "get",
		cache: false,
		success: function(data){
			if (type == "serial") {
				$("#serialuploader").prepend(data);
				$("#ftpimport").html("");
				$(".ftp_slc_brand").html($("#slc_brand").html());
				$(".ftp_slc_serial").html("<option value=\"\">机型系列</option>");
			} else {
				$("#screenuploader").prepend(data);
				$("#ftpimport").html("");
				$(".ftp_slc_screen").html($("#slc_screen").html());
			}
			$.fn.firesbox.close();
		}
	});
}
</script>
</html>